Google groups wouldn't let me send this by email.  I apologize if there is 
any duplication.

On May 9, 2014, at 10:37 AM, Adam Smith wrote:


My main reason for using eval() is to convert from a Symbol to a  

Type. If they supplied a full expression like (1 + 1) as the  

default value for an argument, well, Julia supports that anyway, so  

eval()ing it once inside the macro and saving the result for all  

future calls matches the behavior of python (I don't know if Julia  

matches python behavior here).


1 + 1 is still a constant.  What if the default value is not a  

constant?  Even worse, what if the default expression has side- 

effects when evaluated?


I'm really not sure what to make of your statement "the unfortunate  

need to throw in esc in a couple places to trick Julia into using  

the intended context for ptype and default." The macro seems to be  

working well right now; where do I need to add esc()?


I think the problem will show up if the macro is defined in one  

module and used by a function definition in another module and the  

default or the ptype uses symbols that are not visible in the module  

where the @maybe macro is defined.  Julia's hygiene does not  

currently really work in a correct way, so you have to insert esc  

calls here and there.  This makes Julia macros harder to use than is  

really necessary, but it has not been fixed yet.


By the way, instead of @assert argexpr.head == :(::) it would be  

better to handle the case where the ptype is not specified and  

defaults to Any, even though means the macro does not really need to  

do anything.  Don't you think that would be less surprising to users?

Reply via email to