Okay, looks like I continue to have problems. 

julia> macro modcreate(name, block)
               Expr(:module, false, esc(name::Symbol), Expr(:begin))
               for ex in block.args
                   eval(esc(name), ex)
               end
       end

julia> @modcreate foobar begin
           arf = 6
           barf = 6
       end
ERROR: type: eval: expected Module, got Expr

I feel like this should work. Am I completely off or is there some dumb 
mistake I'm making?

On Wednesday, 2 July 2014 23:21:33 UTC-5, Jameson wrote:
>
> macro modcreate(name)
>     Expr(:module, false, esc(name::Symbol), Expr(:begin))
> end
>
>
> On Thu, Jul 3, 2014 at 12:00 AM, Eric Davies <[email protected] 
> <javascript:>> wrote:
>
>> Hi all,
>>
>> I'm working on a multipass configuration file package and I'm having 
>> difficulty executing my ideas (I'm not great at the metaprogramming stuff 
>> yet). I want to create a baremodule in a macro and have it available to the 
>> scope containing the macro. I want to be able to pass the name of the 
>> baremodule as an argument to the macro. Unfortunately, every (probably 
>> terrible) strategy I try seems to give the error "name not defined" (where 
>> name is the argument to the macro containing the desired module name).
>>
>> I want it to work like this (toy example):
>>
>> julia> @modcreate foo
>>
>> julia> typeof(foo)
>> Module
>>
>> Can anyone suggest possible contents for the macro that might produce the 
>> above behaviour?
>>
>> Thanks,
>> Eric
>>
>
>

Reply via email to