On Wednesday, September 10, 2014 11:20:59 AM UTC-5, Gray Calhoun wrote: > > Hi everyone, I'm writing code using expressions fairly heavily (mainly as > a learning exercise), and am using lots of constructions like: >
Not directly related to any of your questions, but there's a predicate form of head-checking in Base.Meta called `isexpr()`: Meta.isexpr(key, :call) && return ... It's exported from the Meta module, so you can use "using Meta" to avoid having to qualify the name. Related, as a style matter, is that return is a statement as in C, not a function. This means that you don't need the parentheses, since it isn't a call--in the AST, the head is ":return" rather than ":call" julia> :(return 5) :(return 5) julia> :(return(5)) :(return 5) julia> Meta.show_sexpr(:(return 42)) (:return, 42) julia> Meta.show_sexpr(:(fn(42))) (:call, :fn, 42)
