Re: [julia-users] constants environment

2014-09-13 Thread Yakir Gagnon
Works! I placed it in a freshly made juliarc.jl. Thanks! On Sunday, September 14, 2014 10:35:58 AM UTC+10, Patrick O'Leary wrote: > > On Saturday, September 13, 2014 11:06:25 AM UTC-5, Isaiah wrote: >> >> Macros are useful for this sort of thing. >> > > I'm on an isexpr() evangelism mission. Also

Re: [julia-users] constants environment

2014-09-13 Thread Patrick O'Leary
On Saturday, September 13, 2014 11:06:25 AM UTC-5, Isaiah wrote: > > Macros are useful for this sort of thing. > I'm on an isexpr() evangelism mission. Also going to use if statements for additional exposition. using Base.Meta macro allconst(args...) exp = Expr(:block)

Re: [julia-users] constants environment

2014-09-13 Thread Yakir Gagnon
Wah! Right, I can't even read that. I'll try and learn more about the metaprogramming. Thanks! On Sunday, September 14, 2014 2:06:25 AM UTC+10, Isaiah wrote: > > Macros are useful for this sort of thing. > > ``` > macro allconst(args...) >exp = Expr(:block) >args[1].he

Re: [julia-users] constants environment

2014-09-13 Thread Isaiah Norton
Macros are useful for this sort of thing. ``` macro allconst(args...) exp = Expr(:block) args[1].head == :block && for a in args[1].args a.head == :(=) && push!(exp.args, Expr(:const, Base.esc(a) )) end exp end @allconst begin

[julia-users] constants environment

2014-09-13 Thread Yakir Gagnon
I often define a bunch of constants at the beginning of a program. Wouldn't it be nice if we could start an environment of constants to avoid writing `const` before every one of the rows at the beginning of a program? Kind of like: ```Julia begin const a = 1 b = 2 c = "neverChange" end ``` in