RE: 1 problem & 2 q's

new topic     » topic index » view thread      » older message » newer message

> -----Original Message-----
> From: gherson at snet.net [mailto:gherson at snet.net]
> 
> My question re: Euphoria is whether a pointer-to-function 
> scalar type or an 
> eval(euphoria code here) function is in the works.

You can do pointer-to-function in a couple of ways.  First, let's assume
you're talking about calling functions within Eu from Eu.  You could use
routine_id's for this.  It's not technically a pointer, but within a prog,
it basically works the same way.

There's also the call_back() facility.  This allows dll's and the like to
call functions in your app.  The call_back() is an actual pointer that calls
your Eu function.  Win32Lib, for instance uses both routine_id's and
call_back's all over the place.

You can call a routine to which you have a pointer using call(), but not if
the function takes any arguments.  This is mainly used for custom ASM.

If you want to call a function with arguments from a pointer, you'll have to
use something like fptr.e, which can be found in my EuCOM package (check the
archives).  This will let you call a function by pointer while passing
arguments.  It also gets around the 8 (now 9) argument limit for Eu
call_back's.  It works by using ASM to either call the function you specify,
or 'redirect' a function call to your function and store the arguments in
memory.  (NB: Bernie, I think this is all that's really needed to open up
interfacing with other languages--at least for C++ and VB, this is enough to
get you going.)

The eval() concept has been tossed around here quite a bit, but I don't
think it will happen unless someone [other than Rob]with the source figures
it out.  However, there's an Eu emulator written in pure Eu (by David Cuny,
of course) that I've used to create a scripting engine (I don't have access
to it right now, but I'm sure someone on the list has it handy if you're
interested).  I added custom access routines to the internal scripting
language to change actual program variables from the script.  The need for
this makes it less flexible (and a lot slower) than a general eval()
statement, but still gives you a lot of power.

Matt Lewis

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu