A macro can't modify an argument, it always receives immutable objects or 
copies of Expr trees. This is not at all similar to how a function accepts 
a reference to an object. If you are using `eval` in your macro to mutate a 
variable, stop right now. Replace all your macros with functions. Then go 
read the chapter on macros.


On Saturday, May 14, 2016 at 2:52:08 AM UTC-4, Ford Ox wrote:
>
> Shouldn't macro use the same principle as functions? That is:
>
> If your macro changes the value of variable you passed as argument (say 
> @increment x), thus it works similar to a function accepting pointer, it 
> should be marked with "!" at the end? (@increment! x)
>
> If your macro changes variables that you even didn't pass in as an 
> argument (say @increment() always increments x from outer scope), then the 
> macro should be marked with "!!" at the end? (@increment!!) OR it could be 
> marked with "![variable name]![variable name].... (@increment!x(), 
> @increment!x!y!z() ...)
>
> I am not sure whether somebody wants to ever use the second type the 
> macro, but if yes, people should definitely know about that without the 
> need to read inner body of that macro.
>
> What do you think? Should we make it a rule similar to functions that 
> change their arguments?
>
> (I hope its not already in docs and I just skipped that chapter :D)
>

Reply via email to