Hi there,

I'm new to this list. In fact, I just subscribed since I'm planning to write 
a new ILSM, in order to support Befunge.

For those of you who don't know what Befunge is, it's a toy language, but a 
"serious" toy language ;) Its main characteristic is that it's a 2D 
topological stack-based language, where you can move the Instruction Pointer 
the way you want (from left to right / right to left / top to bottom / bottom 
to top / or even diagonal). There are official specifications for Funge-98, 
you can find them at: http://dufflebunk.iwarp.com/JSFunge/spec98.html

I just wrote a Language::Befunge module that implements those specs (as you 
may have seen if you're watching the "recent uploads" in www.perl.com).
But now, I think it would be cool to provide an Inline::Befunge module. 

Since I currently allow the following for my Language::Befunge module:
    my $interp = new Language::Befunge;
    $interp->store_code( <<'END_OF_CODE' );
    < @,,,,"foo"a
    END_OF_CODE
    $interp->run_code;
I think it won't be too painful to wrap the whole stuff in an interface �-la 
Inline.
  
Therefore, I fetched the Inline module, read the Inline-API and Inline::Foo.
But I have some questions, and maybe you can help me:

* Befunge does not support named subroutines. So I have to provide a way in 
order to simulate this. I thought about the following:

      use Inline Befunge;
      print "9 + 16 = ", add(9, 16), "\n";
      print "9 - 16 = ", subtract(9, 16), "\n";
      __END__
      __Befunge__
      BF add
      +q
      BF substract
      -q

This means I'm parsing (via the Inline::Befugne::build() sub) the Befunge 
space and split on the pattern /BF (.+)/, creating a hash ref:
    { add => '+q',
      substract => '-q' }
that I'm storing in the Inline object in the ILSM section.
Then, when called (in the Inline::Befunge::load() sub), I just need to create 
a new Language::Befunge object (I can even create it in the build() sub and 
use always the same interpreter), store the relevant part of code in the 
object and run the given code.
But my question is: how can I get the name of the called subroutine?


* Maybe you have another more "inlinish" solution to solve this problem 
(maybe more than one __Befunge__ space, or whatever). If so, I'll be glad to 
hear about it...


* Another question. Let's assume the calling part work. Since Befunge is 
stack based, I have to push the params onto the stack. Furthermore, since it 
only understands integers, I have to translate strings into "0gnirts" (that 
is, a zero terminated serie of integers mapping the ordinal values of the 
chars). So, how can I fetch the args provided to the sub?


Thanks for your help.


Jerome
-- 
[EMAIL PROTECTED]

Reply via email to