Page 1 of 1

Macro parameters inside of nested procedure are shared?

Posted: Mon Oct 31, 2011 8:27 am
by Nituvious
I was playing around with macro's and wondered if I could create a function on the fly, I found that a function nested within a macro shared parameters with the macro, regardless of being declared shared, static, protected or not.

Also, I think my use of the term "nested" may be wrong?

Code: Select all

param = 0

Macro confuse_me(funcname, param)
	Procedure funcname()
		;Protected param.l
		;param = 1
		If param = 10
			Debug "param equal to 10."
		Else
			Debug "param not equal to 10."
		EndIf
	EndProcedure

	funcname()

EndMacro

confuse_me(nested, 10)
I don't think there is any use in this, I am just curious as to what is actually happening here I guess.

Re: Macro parameters inside of nested procedure are shared?

Posted: Mon Oct 31, 2011 10:51 am
by idle
there's nothing really confusing about it a macro is simply prepossessed
you told it to create a procedure and then call it

Code: Select all

Procedure nested()
  If 10 = 10
    Debug "param equal to 10."
  Else
    Debug "param not equal to 10."
  EndIf
EndProcedure


what you see is what you get!

but you can surely get confused when you macro macros

Re: Macro parameters inside of nested procedure are shared?

Posted: Mon Oct 31, 2011 11:16 am
by Nituvious
Ah I get it(Maybe, I'm probably lying to myself though, haha). I totally had macro figured completely wrong.
I had partially confused a macro parameter with a variable or something.

Re: Macro parameters inside of nested procedure are shared?

Posted: Mon Oct 31, 2011 8:15 pm
by idle
If your trying to get your head around macros just put an illegal character before the end it and then
you can examine it in the error window.