develooper Front page | perl.perl6.language | Postings from April 2005

Re: Inline code (was: Closure/block/sub multiplier)

Thread Previous | Thread Next
Larry Wall
April 20, 2005 15:07
Re: Inline code (was: Closure/block/sub multiplier)
Message ID:
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


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) {$proggie) }

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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About