3 ms·
say "Code took {now - INIT now} seconds to run"; # Code took 0.01111143 seconds to run `INIT now` ... aka COMEFROM.
by rjeli 11y ago
say "Code took {now - INIT now} seconds to run";
# Code took 0.01111143 seconds to run
`INIT now` ... aka COMEFROM.
- rcthompson 11y agoINIT isn't new in Perl 6, although I believe applying it to expressions within a line of code rather than to blocks is.
- Woodi 11y agoI don't thing so. It's not about "where" but about "time": 'now' is saved to ~value end used later
- labster 11y agoPerl 6 does offer COMEFROM, they're just called CATCH blocks.
- tyingq 11y agoIt's more like a label for code to run at start. Also shows the Perl 6 way to interpolate code within a string literal. Compare to the rough Perl 5 equiv, for versions of Perl 5 before say existed: sleep 2; print "Code took @{[time() - $then]} seconds to run\n"; INIT{$then=time();}
- zeveb 11y agoSounds more like an equivalent of Lisp's LOAD-TIME-VALUE [1]. [1] http://www.lispworks.com/documentation/HyperSpec/Body/s_ld_tim.htm#load-time-value http://www.lispworks.com/documentation/HyperSpec/Body/s_ld_t...