Macro feature

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Piero
Addict
Addict
Posts: 1240
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Macro feature

Post by Piero »

Code: Select all

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

m(,1) ; b=1
User avatar
Piero
Addict
Addict
Posts: 1240
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Macro feature

Post 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!
 
Quin
Addict
Addict
Posts: 1165
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Macro feature

Post by Quin »

-1
Incredibly confusing and hard to read.
User avatar
NicTheQuick
Addict
Addict
Posts: 1586
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Macro feature

Post 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.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Quin
Addict
Addict
Posts: 1165
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Macro feature

Post by Quin »

Yes, being able to name positional arguments like Python does it would be incredibly nice. I would loooove that so much.
+100
Little John
Addict
Addict
Posts: 4876
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Macro feature

Post 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
Post Reply