Macro `@eval ex` works, but `@eval(ex)` doesn't.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro `@eval ex` works, but `@eval(ex)` doesn't.

Ismael Venegas Castellรณ
I was fooling around with my ~/.juliarc.jl, and I found this:

julia> [@eval ($๐Ÿ”ฃ)() = run($๐Ÿ”ก) for (๐Ÿ”ฃ, ๐Ÿ”ก) โˆˆ (:๐Ÿ => `python`, :๐Ÿ™ => `hy`, :ฮป => `clojure`, :๐Ÿ’Ž => `irb`, :๐Ÿ’ป => `cling`, :๐ŸŽฎ => `nethack`)]
6-element Array{Any,1}:
ย ๐Ÿ
ย ๐Ÿ™
ย ฮป
ย ๐Ÿ’Ž
ย ๐Ÿ’ป
ย ๐ŸŽฎ

julia> [@eval(($๐Ÿ”ฃ)() = run($๐Ÿ”ก)) for (๐Ÿ”ฃ, ๐Ÿ”ก) โˆˆ (:๐Ÿ => `python`, :๐Ÿ™ => `hy`, :ฮป => `clojure`, :๐Ÿ’Ž => `irb`, :๐Ÿ’ป => `cling`, :๐ŸŽฎ => `nethack`)]
ERROR: syntax: unhandled expr (kw (call ๐Ÿ) (block (line 1 REPL[7]) (call run #<julia: Main.Base.Cmd(exec=Array{Union{UTF8String, ASCIIString}, 1}["python"], ignorestatus=false, flags=0x00000000, env=nothing, dir="")>)))
ย in eval(::Module, ::Any) at ./boot.jl:237
ย [inlined code] from ./boot.jl:236
ย in anonymous at ./<no file>:4294967295
ย in eval(::Module, ::Any) at ./boot.jl:237

julia> VERSION
v"0.5.0-dev+3505"

If I use

@eval(ex)

instead of

@eval ex

ย It doesn't work! Why? Should I report this as aย ๐Ÿž?


Reply | Threaded
Open this post in threaded view
|

Re: Macro `@eval ex` works, but `@eval(ex)` doesn't.

Jameson Nash
it's a difference in the expression type. in `@eval a = b`, it's an assignment. whereas in `@eval(a=b)` it's a kwargs call.
e.g. the minimum repro is:
```
julia> @eval(a=b)
ERROR: syntax: unhandled expr (kw a b)
ย in eval(::Module, ::Any) at ./boot.jl:236
ย in eval(::Any) at boot.jl:235
ย in eval(::Module, ::Any) at ./boot.jl:236
```
however, i think Jeff may have had plans to normalize the two expression heads here?

On Sat, Apr 16, 2016 at 12:46 AM Ismael Venegas Castellรณ <[hidden email]> wrote:
I was fooling around with my ~/.juliarc.jl, and I found this:

julia> [@eval ($๐Ÿ”ฃ)() = run($๐Ÿ”ก) for (๐Ÿ”ฃ, ๐Ÿ”ก) โˆˆ (:๐Ÿ => `python`, :๐Ÿ™ => `hy`, :ฮป => `clojure`, :๐Ÿ’Ž => `irb`, :๐Ÿ’ป => `cling`, :๐ŸŽฎ => `nethack`)]
6-element Array{Any,1}:
ย ๐Ÿ
ย ๐Ÿ™
ย ฮป
ย ๐Ÿ’Ž
ย ๐Ÿ’ป
ย ๐ŸŽฎ

julia> [@eval(($๐Ÿ”ฃ)() = run($๐Ÿ”ก)) for (๐Ÿ”ฃ, ๐Ÿ”ก) โˆˆ (:๐Ÿ => `python`, :๐Ÿ™ => `hy`, :ฮป => `clojure`, :๐Ÿ’Ž => `irb`, :๐Ÿ’ป => `cling`, :๐ŸŽฎ => `nethack`)]
ERROR: syntax: unhandled expr (kw (call ๐Ÿ) (block (line 1 REPL[7]) (call run #<julia: Main.Base.Cmd(exec=Array{Union{UTF8String, ASCIIString}, 1}["python"], ignorestatus=false, flags=0x00000000, env=nothing, dir="")>)))
ย in eval(::Module, ::Any) at ./boot.jl:237
ย [inlined code] from ./boot.jl:236
ย in anonymous at ./<no file>:4294967295
ย in eval(::Module, ::Any) at ./boot.jl:237

julia> VERSION
v"0.5.0-dev+3505"

If I use

@eval(ex)

instead of

@eval ex

ย It doesn't work! Why? Should I report this as aย ๐Ÿž?