3 ms·
That's exactly how Elixir and Julia do it (with quote and unquote operators), for example in Julia: clause = :(3 > 0) expr = :($(clause) ? 0 : 1 + 3) eval(ex
by ddragon 7y ago
That's exactly how Elixir and Julia do it (with quote and unquote operators), for example in Julia:
clause = :(3 > 0)
expr = :($(clause) ? 0 : 1 + 3)
eval(expr) # 0
Though Julia goes further than Elixir, and not only the quoted element is a struct (Julia's base data type) but also everything in the language is an expression that's represented by it, which lead to people arguing that Julia is homoiconic:
expr.head # :if
expr.args # [:(3 > 0), 0, :(1 + 3)]
Though if you're strict on the "homo"-"iconic" term definition it certainly isn't, it's "dual"-iconic with the surface syntax and the surface AST having different formats with one to one mapping and the AST being valid code (or even "tri"-iconic since Julia SSA IR is also accessible as a data type on the language).