tag:blogger.com,1999:blog-7175777398177936339.post1383850255720380870..comments2018-12-17T03:43:18.434+01:00Comments on Julia snippets: A small adventure into Julia macro landUnknownnoreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7175777398177936339.post-84089175149540974922018-02-27T00:23:08.831+01:002018-02-27T00:23:08.831+01:00This is exactly the point - macro does not have to...This is exactly the point - macro does not have to return an expression. And, for instance, this is what regex macro does. The reason why repeated calls to `push!(@intvec,1)` return `[1]` is that the macro is invoked every time you make this call, but if you would write for example `for i in 1:5 global x = push!(@intvec, i) end` at the end `x` will contain five elements as `@intvec` is invoked only once when the loop is parsed.Bogumił Kamińskihttps://www.blogger.com/profile/06250268799809238730noreply@blogger.comtag:blogger.com,1999:blog-7175777398177936339.post-53107229327203625232018-02-26T23:54:22.480+01:002018-02-26T23:54:22.480+01:00The manual says "A macro maps a tuple of argu...The manual says "A macro maps a tuple of arguments to a returned expression...". I found your results a bit confusing until I realized `@intvec` isn't returning an expression. If you use `macro intvec2() quote Int[] end end` you get a distinct array on each invocation. Why do repeated calls to `push!(@intvec,1)` always return `[1]` and not return Vectors of increasing size? I expect the latter from your `b = [@intvec() for i in 1:3]` example.FrontRangeGamerhttps://www.blogger.com/profile/06321958878058191681noreply@blogger.com