Hi,
I'm working on FixedSizeArrays, which does pretty much what you have tried 
here.
Simplified version from constructors.jl 
<https://github.com/SimonDanisch/FixedSizeArrays.jl/blob/master/src/constructors.jl>
 :
macro gentype(N, typename)
    fields = [:($(symbol("I_$i"))::T) for i=1:N]
    quote
        immutable $(typename){T}
            $(fields...)
        end
    end
end


Am Donnerstag, 5. März 2015 11:02:51 UTC+1 schrieb Kaj Wiik:
>
> I have been trying to write a macro that would generate fields in a 
> for-loop.
>
> However, when I try to generate the first line I get an error:
>
> julia> macro deftype(name,artype,num)
>        ex1 = :(esc( immutable $name))
> ERROR: syntax: unexpected ")"
>
> julia> macro deftype(name,artype,num)
>        ex1 = :(esc(quote immutable $name end))
> ERROR: syntax: extra token ")" after end of expression
>
>
> There must be a way to do this, I cannot find how...
>
> Thanks,
> Kaj
>
>

Reply via email to