Macro with wildcard for arguments

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Macro with wildcard for arguments

Post by helpy »

It would be very helpful to have a wildcard for arguments. Here an example:

Code: Select all

Macro NEW(ObjectName,*)
	ObjectName#_Constructor(*)
EndMacro
In this way, I could use the Macro for different Interfaces/Object_Constructors):

Code: Select all

obj1.Interface1 = NEW(OBJECT_1, initPar1)
obj2.Interface2 = NEW(OBJECT_2, initPar1, initPar2, initPar3)
obj3.Interface3 = NEW(OBJECT_3)
cu, helpy
Last edited by helpy on Wed Mar 08, 2006 6:08 pm, edited 2 times in total.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Hi all,

What do you think about this idea? :roll:

(... or did I have just a stupid idea :? )

cu, helpy
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The idea is interesting, i take good notes ;).
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Hi Fred,

Do you have this idea still in mind?

cu, helpy
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Well, yes, but it's not very high in the list ;)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

sorry, I dont get the point...

if I say...

Code: Select all

Macro (one, two)
  one#_bla (two)
EndMacro
where would be the difference?
isn't it handled already?

no joke.. really curious..
oh... and have a nice day.
codemaniac
Enthusiast
Enthusiast
Posts: 289
Joined: Mon Apr 02, 2007 7:22 am
Location: Finland

Post by codemaniac »

Kaeru Gaman wrote:sorry, I dont get the point...

if I say...

Code: Select all

Macro (one, two)
  one#_bla (two)
EndMacro
where would be the difference?
isn't it handled already?

no joke.. really curious..
Maybe it's more practical to have a wildcard than list the max arguments in the macro.
Cute?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

hm... but I did not see the * meaning more than one argument,in the codes posted above.
still ask: where is the point?


...I think there IS a point, if even Fred dealt with it.
....I just couldn't get it... mea culpa....
oh... and have a nice day.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Kaeru Gaman wrote:hm... but I did not see the * meaning more than one argument,in the codes posted above.
still ask: where is the point?
Please read the first post again, this time take some time to carefully look through the code parts of the post.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

ouch!

...must have worn blinkers yerterday...

deeply sorry
oh... and have a nice day.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

But if '*' char was wildcard, how should the compiler distinguish beetween that and the '*' char in front of pointers (like in *pointer.l)?

EDIT: Sorry, I though that '*' was the '#' (I havent studied the macro stuff good enough yet, and I was tired) sign for macros. :lol:
I did't read the argument thing.
Last edited by Bonne_den_kule on Tue Jul 24, 2007 6:55 pm, edited 1 time in total.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

I like the idea.
Bonne_den_kule wrote:But if '*' char was wildcard, how should the compiler distinguish beetween that and the '*' char in front of pointers (like in *pointer.l)?
I think the * was just an example. However, have you seen a pointer with the name "*"? Remember, the argument passed was just * not *something.

AND on the other hand macro parsing is completely different from the others, and macro's do not use types for parameters.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

I just found a way to do the wildcard thing for the specific problem:

Code: Select all

Macro NEW(ObjectName, arguments=())
	ObjectName#_Constructor#arguments
EndMacro
In this way, I could use the Macro for different Interfaces/Object_Constructors):

Code: Select all

obj1.Interface1 = NEW(OBJECT_1, (initPar1))
obj2.Interface2 = NEW(OBJECT_2, (initPar1, initPar2, initPar3))
obj3.Interface3 = NEW(OBJECT_3)
Although a wildcard would be nice for other things, where no such workaround would help.
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Post Reply