in reply to Re: Perl oddities
in thread Perl oddities
In fact, the braces are much more important in Perl 6 because they almost always indicate a closure, or at least a potential closure. That's important because the braces indicate delayed evaluation. A closure is treated as an argument to the control construct, so you could also write the above as:if $condition { do_something() }
But the converse is also true, that if you define your own statement:<foo> with the same signature, you can call it as:statement:<if>($condition, { do_something() });
just as if it were a built-in control construct. To do this in Perl 5 requires chewing gum and bailing wire, plus assorted smoke and mirrors.foo $condition { do_something() }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Perl oddities
by Tanktalus (Canon) on Mar 01, 2005 at 22:30 UTC | |
by tye (Sage) on Mar 01, 2005 at 23:23 UTC | |
by Tanktalus (Canon) on Mar 02, 2005 at 00:30 UTC | |
by TimToady (Parson) on Mar 02, 2005 at 01:25 UTC | |
by theguvnor (Chaplain) on Mar 02, 2005 at 03:41 UTC | |
by lidden (Curate) on Mar 01, 2005 at 23:50 UTC | |
by TimToady (Parson) on Mar 02, 2005 at 00:50 UTC |