Page 8 of 22
Re: Blog post !
Posted: Mon Mar 15, 2021 2:49 pm
by skywalk
@Fred
I expect optimized C to match ASM for simple stuff. Glad to hear it is working.
I also prefer to run final code from the ide no matter the delay.
My use case for a GetCaller() Macro is to avoid virtual tables with some libs.
I have Structures with embedded Prototypes to a Procedure.
I will wait to see the exposed C or inline C approach.
Re: Blog post !
Posted: Mon Mar 15, 2021 2:50 pm
by skywalk
@Fred - I assume we will have a selection panel or some code switches to set individual C optimizations?
Re: Blog post !
Posted: Mon Mar 15, 2021 2:51 pm
by User_Russian
Fred, what C code will be compiled from this PB code?
Code: Select all
Procedure.s Test(x, y, z.s)
ProcedureReturn Str(x+y)+z
EndProcedure
Fred wrote:There is a new compiler directive to control optimization from code: 'EnableCodeOptimizer'
GCC supports several levels of optimization (-O0, O1, etc.). Does the directive allow them to be set? Also GCC using __attribute__ can set the level of optimization of a function. Will this be possible in PB?
Code: Select all
__attribute__((optimize("-O2")))
void Test(void)
{
}
Re: Blog post !
Posted: Mon Mar 15, 2021 6:44 pm
by StarBootics
Hello everyone,
I have another question : Are the Interface/EndInterface will be impacted by this change ?
Best regards
StarBootics
Re: Blog post !
Posted: Mon Mar 15, 2021 7:01 pm
by Tenaja
jacdelad wrote:Is compilation speed really so important? I only have small projects which never take then more than 3 seconds or something, usually less.
Yes, it is, especially with a bloated system like GCC. For example, I was testing a compiler that generated asm macros, and short short code took very long for their length, with 99 percent of the compilation time in the assembler. It was so significant that I hand wrote my own macro expander... Then compilation was nearly instant.
Re: Blog post !
Posted: Mon Mar 15, 2021 8:01 pm
by Lord
User_Russian wrote:...
I think that gosub can be abandoned.
...
It's BASIC and should stay BASIC!
jacdelad wrote:Is compilation speed really so important?
...
YES!
Re: Blog post !
Posted: Mon Mar 15, 2021 8:57 pm
by Keya
i would've thought GOSUB and GOTO could easily be implemented with a single inline asm call or jmp respectively
Re: Blog post !
Posted: Mon Mar 15, 2021 9:55 pm
by Tenaja
Keya wrote:i would've thought GOSUB and GOTO could easily be implemented with a single inline asm call or jmp respectively
It probably can, but I'm with User_Russian... Gosub can be obsoleted. We've got procedures, for crying out loud...
Re: Blog post !
Posted: Mon Mar 15, 2021 11:40 pm
by User_Russian
In C there Goto and its scope as in PB.
That is, there should be no problems.
Re: Blog post !
Posted: Tue Mar 16, 2021 1:23 am
by kenmo
I think everyone should relax
Fred & team know PureBasic internals better than all of us. They know the pros and cons of what they're doing, and I'm sure they'll make it as backwards-compatible as possible. Also, it's the PB team... you know they love simplified toolchains and fast write-and-run cycles!
It's newly announced, and some people are already asking for specific C output for PB input snippets?! Too soon

Re: Blog post !
Posted: Tue Mar 16, 2021 2:11 am
by StarBootics
kenmo wrote:I think everyone should relax
Fred & team know PureBasic internals better than all of us. They know the pros and cons of what they're doing, and I'm sure they'll make it as backwards-compatible as possible. Also, it's the PB team... you know they love simplified toolchains and fast write-and-run cycles!
It's newly announced, and some people are already asking for specific C output for PB input snippets?! Too soon

I hope you are right, because I don't want to see my Dev-Object program generating broken code for future version of PureBasic. I know I can stick with the 5.73 LTS version from now on but I don't like to do that. That's why I have some questions, and from my perspective it is legitimate considering the many hours of hard work I put in my programming projects already (Dev-Object and my 3D game project just to name a few).
Best regards
StarBootics
Re: Blog post !
Posted: Tue Mar 16, 2021 4:25 am
by Rinzwind
skywalk wrote:@Fred
My use case for a GetCaller() Macro is to avoid virtual tables with some libs.
I have Structures with embedded Prototypes to a Procedure.
I will wait to see the exposed C or inline C approach.
Exactly why I want the option to extend structures with procedures so we get instance-style programming finally easy for the ones wanting it. Up to now we have to resort to hacks of various complexity and too much boiler plate code... one simple addition...
Also inline array declaration like in c is a must in select use cases...
Also a more efficient string type. Length prefixed. So it can contain binary data to. Never use special data to control the same data (0-termination...). There various c libs available that attempt to solve that while still having backward compatibility where needed.
Open minded

Re: Blog post !
Posted: Tue Mar 16, 2021 4:32 am
by BarryG
Tenaja wrote:Gosub can be obsoleted. We've got procedures
Don't forget that for speed-critical routines, calling Procedures is slower than using Gosub, and all variables inside a Procedure are set to 0/null when the Procedure starts (unless Global or Shared). I say keep it in for compatibility and speed options.
Re: Blog post !
Posted: Tue Mar 16, 2021 4:40 am
by Tenaja
BarryG wrote:Tenaja wrote:Gosub can be obsoleted. We've got procedures
Don't forget that for speed-critical routines, calling Procedures is slower than using Gosub, and all variables inside a Procedure are set to 0/null when the Procedure starts (unless Global or Shared). I say keep it in for compatibility and speed options.
There's no such thing as a local variable in a subroutine... So write your procedures with globals, and you have the same call speed... And the same visibility of their variables.
Re: Blog post !
Posted: Tue Mar 16, 2021 5:15 am
by BarryG
[Deleted]