Re: Euphoria being OO Survey.

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

On Thu, May 15, 2003 at 09:49:30AM -0700, Mike Nelson wrote:
<snip>
> 
> While
> 
> x=myObject.myMethod(theParameter)
> 
> is cleaner syntax than
> 
> x=call_method(myObject,"myMethod",{theParameter})
> 
> as is correct Diamond syntax, the latter is hardly unusable.

I do agree, but a cleaner syntax makes for easier time programming,
and easier time reading the source code (for newbies at least ;]).

> 
> I am putting the finishing touches on Diamond 3.0, with many improvements.
> My next project will be a preprocessor enabling dot notation.

Sounds great.

> 
> I need to figure out a notation for events--in Diamond, events are not
> properties or methods, they are a third thing.

Hmm ... how many other OO languages have events? how many non-OO langs have
it for that matter?

and what syntax do they use?

> 
> x.y=z   means set_property(x,"y",z)
> x=y.z   means x=get_property(y,"z")
> x=y.z() means x=call_method(y,"z",{})
> 

Sounds natural enough. ;]

> What would be good notation for
> link_handler(x,"y#1",z) and raise_event(x,"y",{z}) ?
> 
> (The "y#1" in link_handler is because events can be overloaded based on the
> number of parameters--it is needed because x might also have a y#0 or y#2
> event.)
> 
> I'm leaning towards
> 
> x!y(1)=z   and   x!y(z)
> 
> Any suggestions?

Why use special symbols? Perhaps these are more readable and more obvious:

1.

link_handler(x, y(a), z)
raise_event(x, y, z)

this is basicly the above
routines with some minor clean up in it. y(a) lists the number of parameters,
y() is y#0, y(a) is y#1, y(a,b) is y#2, etc. and, raise_event() is meant to
look like it has variable parameters. Naturally, the preprocessor would
convert y(x) to "y#1" and raise_event(a, b, c, d, e) into
raise_event(a, "b", {c, d, e})

2.

link handler z to x.y(a)
raise event x.y(z)

this is a more altered syntax, basicly removes the functions and instead
adds new keywords. Looks more natural as wel.

3.

x.link_handler(y(a), z)
x.raise_event(y, z)

this is basicly 1. but altered so that the functions look like methods of the
object x.

I'd prefer 2. myself, it seems the most natural of all 3 i've suggested and also
more natural than the awkward 'x!y()' syntax you proposed.

> 
> -- Mike Nelson
> 

jbrown

-- 
 /"\  ASCII ribbon              | http://www.geocities.com/jbrown1050/
 \ /  campain against           | Linux User:190064
  X   HTML in e-mail and        | Linux Machine:84163
 /*\  news, and unneeded MIME   |

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

Search



Quick Links

User menu

Not signed in.

Misc Menu