It would appear so...I swear that I tried that, but I guess I didn't try that permutation!
So what's it about the @eval macro that doesn't allow for regular string interpolation, that I have to use the string() function instead of an inline $? On Monday, November 17, 2014 9:50:55 PM UTC-5, Jacob Quinn wrote: > > Can you just do > > > funcname = (:get_help_configuration, :get_help_languages, > :get_help_privacy, :get_help_tos, :get_application_rate_limit_status) > endpoint = ("help/configuration.json", "help/languages.json", > "help/privacy.json", "help/tos.json", "application/rate_limit_status.json") > > for (func, endp) in Dict(funcname, endpoint) > @eval begin function ($func)(; options=Dict{String, String}()) > > r = get_oauth(string("https://api.twitter.com/1.1/", $endp), > options) > > return r.status == 200 ? JSON.parse(r.data) : r > > end > end > end > > > ? > > On Mon, Nov 17, 2014 at 9:35 PM, Randy Zwitch <randy....@fuqua.duke.edu > <javascript:>> wrote: > >> I've seen this type of function generation in other packages, and wanted >> to try it for myself. This file in Twitter.jl has 5 functions with the same >> overall structure: >> >> https://github.com/randyzwitch/Twitter.jl/blob/master/src/help.jl >> >> >> Here's what I ended up doing, which works, but I've got no idea why I had >> to write the string interpolation the way I did. I went through many >> permutations here, so if someone could explain why the `:($(string(" >> https://api.twitter.com/1.1/", $endp))` line needs to be written that >> way for string interpolation, it would be appreciated. And any improvements >> in general are welcome. >> >> >> >> funcname = (:get_help_configuration, :get_help_languages, >> :get_help_privacy, :get_help_tos, :get_application_rate_limit_status) >> endpoint = ("help/configuration.json", "help/languages.json", >> "help/privacy.json", "help/tos.json", "application/rate_limit_status.json") >> >> for (func, endp) in Dict(funcname, endpoint) >> @eval begin function ($func)(; options=Dict{String, String}()) >> >> r = get_oauth(:($(string("https://api.twitter.com/1.1/", >> $endp))), options) >> >> return r.status == 200 ? JSON.parse(r.data) : r >> >> end >> end >> end >> >> Thanks! >> > >