Just the conversion of the expression into a string happens at compile time.
So 'ex' is a symbol or expression. The string(ex) call happens at compile time. It effectively converts the expression to a string form, does NOT evaluate the expression. This is just calling a string(..) method that takes an expression as a parameter. The $(string(ex)) then interpolates the resulting string into the final expression (which is quoted, with the initial colon) Note that the final expression that is returned from the macro contains the original expression (the $ex at the beginning) and the expression represented as a string. All that is quoted, and thus evaluated at runtime. Hope this helps. Disclaimer: I am by no means a metaprogramming expert. Just that thinking through this question has been instructive for me. On Wednesday, 19 February 2014 16:45:50 UTC, andrew cooke wrote: > > no that can't be right or $ex would be evaluated. sorry - confused... > > On Wednesday, 19 February 2014 13:45:08 UTC-3, andrew cooke wrote: >> >> ah, no. it forces evaluation at compile time, i think. >> >> On Wednesday, 19 February 2014 13:41:15 UTC-3, andrew cooke wrote: >>> >>> according to >>> http://julia.readthedocs.org/en/latest/manual/metaprogramming/ @assert >>> is defined as: >>> >>> macro assert(ex) >>> :($ex ? nothing : error("Assertion failed: ", $(string(ex))))end >>> >>> and i am wondering why there is a $(...) around the call to string. is >>> this to delay evaluation? >>> if so, why? >>> >>> thanks, >>> andrew >>> >>> >>> >>>
