Calculations in procedure declarations

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Calculations in procedure declarations

Post by freak »

Trond, you can poke holes in just about everything :D

> A macro code demonstrates that "ReplaceImageColor(0, 0)" is actually NOT literally turned into "ReplaceImageColor(0, 0, <default value>)"

Well yes. The compiler resolves the literal value at the declaration and then just places it into the call. Just look at the asm output and you see that the procedure is always called with the full set of arguments. My point was that in order to allow a function call, you cannot resolve the value when the declaration is compiled and so would run exactly into the kind of problem you tried to show with the macro code.

In the end, it would not be technically impossible, but it would be a lot more messy than it looks at first sight.

> This has to be a bug?

Yes. The compiler should complain about the Declare not matching the actual procedure.
quidquid Latine dictum sit altum videtur
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Calculations in procedure declarations

Post by PB »

> Trond, you can poke holes in just about everything :D

+1

I'm constantly amazed by the reports that Trond posts. Sometimes I yell at the screen, "who cares?" when he posts a really obscure bug (you know, the ones where you have to be sitting a meter away from the keyboard and drinking only Lite Beer at precisely midnight for the bug to occur ;) ) but at the end of the day they ARE bugs and need fixing. So, good work, Trond. :) You're the bloodhound of the forum.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Calculations in procedure declarations

Post by blueznl »

Wow :shock:

Not sure if it matters, but damnit Trond, why are you not with CSI?

:P
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply