use POE qw/Wheel::ReadLine/; BEGIN { package R2::Thread; use Inline Guile => <{kont} = $l->[0]; return $new; } sub do { my ($self, $code) = @_; my $string = new Guile::SCM string => $code; my $l = postreturn($self->{kont}, $string); $self->{kont} = $l->[0]; return $l->[1]; } } ####### END BEGIN BLOCK POE::Session->create( inline_states => { _start => \&init, line => \&input_line } ); sub init { $_[HEAP]->{wheel} = POE::Wheel::ReadLine->new( InputEvent => 'line' ); $_[HEAP]->{prompt} = ':'; $_[HEAP]->{wheel}->put("Welcome to R2"); $_[HEAP]->{wheel}->get($_[HEAP]->{prompt}); $_[HEAP]->{thread} = new R2::Thread; } sub input_line { my ($heap, $input, $exception) = @_[HEAP, ARG0, ARG1]; if (defined $input) { my $res = $_[HEAP]->{thread}->do("($input)"); $_[HEAP]->{wheel}->put($res); } else { print "Argh!\r\n"; delete $_[HEAP]->{wheel}; return; } $_[HEAP]->{wheel}->get($_[HEAP]->{prompt}); } POE::Kernel->run(); exit;