Macros.
B::Generate already has most (all?) of the nouce required to make macros available in Perl 5 right now. I wish I could pursuade it to build on win32.
As a very loose spec, something like this ought to work.
use Macro 'min( $x, $y )' => q[ ( $x < $y ? $x : $y ) ], 'max( $x, $y )' => q[ ( $x > $y ? $x : $y ) ], ; ... my( $p, $q, $r ) = ( 1, 2, 3); my $i = min( $p, $q ); my $j = max( $q, $r );
This can be almost done now by evaling the strings and storing a coderef in a hash, and declaring an empty sub with the macro name. Then at INIT{} time, walk the codetree looking for calls to the subs and substitute the code generated earlier for the subcalls.
In reply to Re: (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
by BrowserUk
in thread (Sort of) poll: what Perl6 features do you consider {likely,desirable} to leak into P5?
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |