pointers

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

Banjo wrote:

>  Is there any way a function can be pointed to by a variable ?
>  Would Function Pointers break the purity ?

I wouldn't mind being able to re-cast a few functions, and finally give
Euphoria forward referencing.

I think that the interpreted nature of Euphoria precludes access to
pointers, although I remember looking at a strange dump once and seeing
something like:

   function("foo")

which makes me think that internally Euphoria calls functions through a
high-level mechanism that passes strings, rather than by pointers.

You could obviously write something like:

    function do( sequence fName, argList )
       if    compare( fName, "foo" ) = 0 then   return foo( argList )
       elsif compare( fName, "bar" ) = 0 then   return bar( argList )
       elsif compare( fName, "grill") = 0 then  return grill( argList )
       else                                     err( "Unknown pointer " &
fName )
       end if
    end function

I hope we eventually get some sort of forward referencing, although I
suspect it would break a lot of the error checking that Euphoria can now do
fairly trivially. Pointers, I'm not so sure of. I've used them for years in
FORTH, but it seems one of the reasons that Java is so hailed is that it got
rid of the darned things.

 -- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu