Autrijus Tang skribis 2005-04-21  5:31 (+0800):
> Bringing the topic back to perl6-language, I'd like to inquire
> how eval and inlining other languages works.  Here's some thoughts:
>     eval('printf("Hello!")', :language<C>);

Is that comma needed?

>     eval(:C('printf("Hello!")'));

Strange use of a pair - feels to me like you can provide alternatives:

    eval(
        C    => 'printf("Hello!")',
        Ruby => 'print "Hello!"',
        sh   => 'echo Hello\!'
    );

>     inline C => '...';
>     inline C => =<foo.c>;

Syntactic sugar that was nice for Perl 5, but is probably better to be
left alone.

eval(Str $code, +$lang) has my preference, syntax-wise, but that can
perhaps only work with Parroty languages, of which I think C isn't
one.

Sometimes you want to add a word in between terms for documentation. For
this reason, I've always wanted the arguments for index to be the other
way around, so I could think "index $needle, (in) $haystack".

It'd be fun to have a different spelling for comma (here I assume that
leading comma is ignored and that because of the special new leading
keyword, non-slurpy can come after slurpy), for example:

    multi eval ($code, "using" ?$lang) { eval($code, :lang($lang)) }
    eval 'printf("Hello!")' using "C";

    multi index ("of" $needle, "in" $haystack, +$offset) { index(...) }
    my $pos = index of "," in "Hello, world!";

    multi join ([EMAIL PROTECTED], "on" $separator) { ... }
    my $joined = join @fields on ":";
    
The same thing can almost be done with pairs, but these words don't make
good identifier names.
    
Can something like this be done without resorting to macros with hard to
construct regexes?


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to