Re: Structures; etc.

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

Everett Williams wrote:

> ... I think that most of [OOP] could be
> accomplished through pre-processor if
> Euphoria had adequate namespace and
> structure capabilities with built-in type
> checking for sequences.

That was my thinking when I was writing my 'dot' pre-processor, but
polymorphism is a problem. For example:

   procedure foo( object bar )
      bar.print()
   end procedure

Casting 'bar' as an object causes it to lose any sense of identity. The same
thing is true if you place the object in a sequence:

   s[1].print()

The pre-processor has no clue what class to apply. In fact, you don't know
what the class of the object is going to be until runtime. To get it to
work, you need to place all the class methods in a lookup table:

   routine print()
      -- code goes here
   end procedure
   set_method( "foo", "print", routine_id("print" ) )

The calls then have to resolve the method at runtime. For example,

      bar.print()

become:

      call_method( "print", bar, {} )

You don't even need namespaces to implement this, but it does a quite a bit
of overhead.

> Classes and Object orientation do not answer the
> need for structures.

It's not clear to me why not. For example:

   foo.bar

represents an object's value that can be typed to anything. That should give
the granularity you're asking for.

Or am I missing something?

-- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu