1. pointers

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 message » categorize

2. Re: pointers

Cuny, David wrote:
>
> I wouldn't mind being able to re-cast a few functions, and finally give
> Euphoria forward referencing.
>
A hearty "amen" to that idea! I've spend many frustrating hours
restructuring programs to get around this problem that could have been
solved in a few minutes with forward referencing. Some may argue that
this was just bad planning on my part, which is probably true. Still, it
would be a nice weapon to be able to add to my Euphoria arsenal...even
if it is only used to fix structuring errors on the programmer's part.
:)

> I think that the interpreted nature of Euphoria precludes access to
> pointers, although I remember looking at a strange dump once and
<snip>
Once again, we are in agreement. While pointers can be very useful in
certain instances, I haven't yet found a case where I couldn't work
around it.
--
   ______   _______   ______
  /_____/\ /______/\ /_____/\
  \  ___\/ \  ___ \ \\  ___\/_
   \ \ \    \ \/_\ \ \\ \____/\
    \ \ \____\  ___ \ \\____ \ \
     \ \/___/\\ \/_\ \ \ /__\ \ \
      \_____\/ \______\/ \_____\/
       S003CBS at ALPHA.WRIGHT.EDU

new topic     » goto parent     » topic index » view message » categorize

3. pointers

I can think of 2 cases where pointer would be helpful
for me.

1: Conversion of languages such as C & Pascal
2: Accessing of 1D sequences such as {1, 2, 3, 4, 255, 0}.
    I could use it to copy 1D sequences to video memory.
    I could use it to create masks using the sequence
    operators such as and_bits.  This would keep me from
    having to peek() and poke() to do operations on
    sequences in memory.

I realize that Multi-Dimensional Sequences can't be supported.
I also realize that the 1D sequence would not be allowed to
be altered in size AND that the 1D sequences could only contain
values from 0 to 255.  These values are bytes. All other values
are multiple bytes and MUST be represented differently.

What I ask seems simple from MY stand point BUT.
I don't know how the structure of sequences is handle.
I don't know if the information for sequences is hanlded with
header type information OR some sort of Multiple header type.
If there is one header at the very begining of the sequence then
there shouldn't be any problem.
BUT if there are little headers maintained through out the
sequence structure then that would quickly and easily corrupt
the sequence.


As You see Robert.
        I fully understand the Possible complications
involved with pointers to sequences.

I can also see where there could be complications involving
atoms, and integers.

objects would be simply impossible.

Another problem I just thought of is his dynamics for saving
space in sequences.

<CODE>
sequence s1, s2

s1 = {1, 2, 3, 4}
s2 = s1
<CODE>

s2 is only pointing to s1 so pointing to s2 and then
changing s1 would corrupt the pointing.

All of these problems can be overcome but they Might take
a lot more effort than others realize or relized before this
message.

Sincerely, Lucius L. Hilley III
        A thrilled little Euphoria programmer.

--Lucius Lamar Hilley III
--  E-mail at luciuslhilleyiii at juno.com
--  I support transferring of files less than 60K.
--  I can Decode both UU and Base64 format.

new topic     » goto parent     » topic index » view message » categorize

4. Re: pointers

Hilley wrote: (not complete)

>
> I can think of 2 cases where pointer would be helpful
> for me.
>
> 1: Conversion of languages such as C & Pascal

Not necessary. I've translated some programs form Pascal and C into
Euphoria. You only have to translate the pointer structure to a
sequence and it works. Euphoria can do (almost) everything what
Pascal and C can if you take the time to do it the Euphoria way....

> 2: Accessing of 1D sequences such as {1, 2, 3, 4, 255, 0}.
>     I could use it to copy 1D sequences to video memory.
>     I could use it to create masks using the sequence
>     operators such as and_bits.  This would keep me from
>     having to peek() and poke() to do operations on
>     sequences in memory.
> SNIP....

Yes, but still no need for pointers. It will confuse the whole
language.

Marcel

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu