On Thu, Apr 21, 2005 at 05:31:05AM +0800, Autrijus Tang wrote:
: 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>);
:     eval(:C('printf("Hello!")'));
: 
:     inline C => '...';
:     inline C => =<foo.c>;
: 
: If there is some consensus on this, I'd like to change Pugs's
: existing `eval_perl5()` and `inline` syntax to agree with it.

I think eval($str) is just syntactic sugar for

    $?MYGRAMMAR.top($str).compile.run

or some such.  We could just leave eval meaning that, and let people
define their own shortcuts for other languages.  If someone is going
to do one eval in a different language, they're often going to
a lot of them, so a syntax like:

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

is going to be too heavyweight for that anyway, and people will write

    sub eval_C ($proggie) { CGrammar.top($proggie).compile.link.run.dump.gdb }

or whatever.  :-)

The other part we might want to replace is the .top, since .top is
probably going to create a new lexical scope, whereas .statement or
some such will presumably execute the new statement in the current
scope, so we have some way of writing an interactive eval loop that
doesn't throw away declarations.

Larry

Reply via email to