Page 1 of 1

Macro with wildcard for arguments

Posted: Wed Feb 22, 2006 2:47 pm
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

Posted: Wed Mar 08, 2006 6:05 pm
by helpy
Hi all,

What do you think about this idea? :roll:

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

cu, helpy

Posted: Wed Mar 08, 2006 6:16 pm
by Fred
The idea is interesting, i take good notes ;).

Posted: Mon Jul 23, 2007 7:46 am
by helpy
Hi Fred,

Do you have this idea still in mind?

cu, helpy

Posted: Mon Jul 23, 2007 7:28 pm
by Fred
Well, yes, but it's not very high in the list ;)

Posted: Mon Jul 23, 2007 8:12 pm
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..

Posted: Mon Jul 23, 2007 9:18 pm
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.

Posted: Mon Jul 23, 2007 9:30 pm
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....

Posted: Mon Jul 23, 2007 10:50 pm
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.

Posted: Tue Jul 24, 2007 9:26 am
by Kaeru Gaman
ouch!

...must have worn blinkers yerterday...

deeply sorry

Posted: Tue Jul 24, 2007 4:01 pm
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.

Posted: Tue Jul 24, 2007 4:30 pm
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.

Posted: Tue Jul 24, 2007 4:49 pm
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.