Page 1 of 1

Macro feature

Posted: Thu Mar 12, 2026 4:24 am
by Piero

Code: Select all

Macro m(a=0,b=0,c=0)
   Debug b
EndMacro

m(,1) ; b=1

Re: Macro feature

Posted: Thu Mar 12, 2026 9:51 am
by Piero
I would have proposed to implement it also for procedures, but probably it would be confusing to see:

Code: Select all

DoStuff(,,,2,,4,,"Pizza",,1)
directly in procedures… that's not the case with macros; they CAN be a little cryptic (# stuff etc.)

Code: Select all

DoStuff(,,,2,,4,, Pizza, ,1) ; ',     ,' same as ',,'
 
PS: in any case, THANKS Fre… OoOPS!
 

Re: Macro feature

Posted: Thu Mar 12, 2026 4:17 pm
by Quin
-1
Incredibly confusing and hard to read.

Re: Macro feature

Posted: Thu Mar 12, 2026 4:49 pm
by NicTheQuick
I would be okay with something like this:

Code: Select all

Macro m(a=0,b=0,c=0)
   Debug b
EndMacro

m(b=1) ; b=1
The same for procedures with multiple optional arguments:

Code: Select all

# OpenNetworkConnection(ServerName$, Port [, Flags [, TimeOut [, LokaleIP$ [, LokalerPort]]]])
OpenNetworkConnection("localhost", 80, LocalIP$="192.168.178.25")
But then the arguments also should kept in English in the documentation.

This way of using optional arguments reminds me of Python. It does it in a similar way.

Re: Macro feature

Posted: Thu Mar 12, 2026 8:04 pm
by Quin
Yes, being able to name positional arguments like Python does it would be incredibly nice. I would loooove that so much.
+100

Re: Macro feature

Posted: Thu Mar 12, 2026 8:47 pm
by Little John
Quin wrote: Thu Mar 12, 2026 8:04 pm I would loooove that so much.
Me too. I may be mistaken, but I believe named parameters have been requested here on several occasions. :)
As long as they are not implemented in PureBasic, we can help ourselves if necessary. :D