On Wed, Dec 9, 2015 at 5:12 PM, <vish...@stanford.edu> wrote: > sorry ok, I see - it's > Expr.head > and > Expr.args > > Man, I really wish Julia had something like python's help(Expr) to see all > the methods/fields of a class... >
``` help?> Expr search: Expr export nextprod expanduser expm exp2 exp expm1 exp10 expand exponent No documentation found. Summary: type Expr <: Any Fields: head :: Symbol args :: Array{Any,1} typ :: Any ``` > > On Tuesday, December 8, 2015 at 8:26:35 PM UTC-8, vis...@stanford.edu wrote: >> >> Situations where the printed form of an expression (i.e, what you'd type >> into julia REPL, for example) are equivalent aren't "equal" per julia's >> standards: >> >> Expr(:call, :<, 1, 2) --> :(1 < 2) >> Meta.show_sexpr(:(1 < 2)) --> (:comparison, 1, :<, 2) >> Expr(:call, :<, 1, 2) == :(1 < 2) --> FALSE >> >> I figure that's expected because the s-expressions behind the scenes >> aren't accurate. >> So the workaround is: >> >> Expr(:call, :<, 1, 2) == :(<(1,2)) --> TRUE >> >> This isn't ideal, but at least there's a way to express the Expr object I >> want in terms of julia's syntax. >> Is there another way to make these two semantically equivalent >> representations actually be equal? >> >> Second - a much weirder problem: >> >> Meta.show_sexpr(:(symbol.x())) --> (:call, (:., :symbol, (:quote, :x))) >> >> >> Ok, so make an expression: >> >> Meta.show_sexpr(Expr(:call, Expr(:., :symbol, Expr(:quote, :x)))) --> >> (:call, (:., :symbol, (:quote, :x))) >> >> >> Cool. So this time the expression object and the actual julia >> representation are the exact same. >> >> However: >> >> Expr(:call, Expr(:., :symbol, Expr(:quote, :x))) == :(symbol.x()) --> >> FALSE >> >> >> And stragely >> >> >> Meta.show_sexpr(Expr(:call, Expr(:., :symbol, Expr(:quote, :x)))) == >> Meta.show_sexpr(:(symbol.x())) --> TRUE >> >> >> What is going on!? And how do I get these expressions to agree? >> >> >> Vishesh >> >> >> >> >> >