Monday, April 10, 2006

 

SmartEiffel with embedded Perl

Recent development versions of SmartEiffel highlight the ability to embed scripting language interpreters. Embedded Perl is implemented, and there is a tutorial example using embedded Perl.

Perl? When they could have chosen Ruby or Python? Oh well.

Hello World, in embedded Perl, is as simple as this:
   perl.instruction(once "use strict;print(%"Hello!\n%");")
You can execute an expression and retrieve its value, without breaking command-query separation on the Eiffel side:
   perl.expression(once "2**10")
io.put_integer(perl.last_integer)
io.put_new_line
You can manipulate Perl variables, to test for their existence, test whether they are defined, set them and read them.

There's more to it than that, of course. For more details, see subversion checkins 7072, 7073 and 7074.

Comments:
Colin, yes you can get information back.

The problem with your Parrot class was more in the practicalities than the principle - I'm sure we could solve the issues of signature compatibility etc.

The problems, of course, were at the Parrot end rather than on your end. Parrot has evolved considerably since then, and I think it would be more straightforward now.

But this does make me consider whether I should integrate Amber with SmartEiffel instead of with Parrot.

The thing is: the idea behind Amber is to have an Eiffel-like scripting langauge that can access the hundreds of libraries already available for modern scripting languages. But if I integrate Amber with SmartEiffel, then it would still be necessary to embed one of Perl/Python/Ruby to gain access to the libraries.

Parrot is developing rapidly, which is good news except that the changes break Amber on a regular basis. I'll have to consider whether Parrot is still the most suitable platform for Amber.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?