Larry Wall skribis 2005-04-20 11:25 (-0700): > : It shouldn't treat a sub call differently, so that a called sub can in a > : useful manner return a closure, which is then executed several times. > : The same annoying special syntax can be found in perl 5's goto, that > : can't go to a returned subref using "goto sub_that_returns_a_subref();". > Doesn't this work in Perl 5? > goto &{sub_that_returns_a_subref()}; > If not, I'd say it's a bug.
Hm, it does. But it's not something I thought of when I needed it. But it's one of those cases that have case-specific special syntax, and I think it's best to avoid that. The same thing goes for all those places where a variable is expected that begins with $, like foreach. You can't easily use an lvalue sub. The workaround is like your goto workaround: for ${\thatsub()} (1..10) { ... } Although admittedly, I only encountered this when playing with a non-readonly undef ;) (This is something I can recommend to anyone: redefining true, false and undef leads to very spectacular code, where anything's possible, and defined(undef) can be a true that stringifies as "false".) Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html