Quote-friendly way to express keyword Expr?

72 views
Skip to first unread message

Penn Taylor

unread,
Oct 30, 2016, 12:47:01 AM10/30/16
to julia-users
Is there a quote-friendly way to write the following keyword Expr, or must I directly manipulate raw Expr's to get this?

Expr(:kw, :foo, 2)


By "quote-friendly", I mean a form such as

:(stuff)

# or

quote
 stuff
end

Isaiah Norton

unread,
Oct 30, 2016, 9:55:32 PM10/30/16
to julia...@googlegroups.com
Not really clear what you are trying to do. These are inserted by the parser whenever keyword arguments are used in (function) call syntax. So:

julia> quote f(x= 10) end |> dump
Expr
  head: Symbol block
  args: Array{Any}((2,))
    1: Expr
      head: Symbol line
      args: Array{Any}((2,))
        1: Int64 1
        2: Symbol REPL[6]
      typ: Any
    2: Expr
      head: Symbol call
      args: Array{Any}((2,))
        1: Symbol f
        2: Expr
          head: Symbol kw
          args: Array{Any}((2,))
            1: Symbol x
            2: Int64 10
          typ: Any
      typ: Any
  typ: Any

Penn Taylor

unread,
Oct 31, 2016, 11:45:21 AM10/31/16
to julia-users
I'm manipulating keyword args inside a macro. Just wanted to check whether I was missing a syntax option for building those expressions.
Reply all
Reply to author
Forward
0 new messages