Re: Structures; etc.
- Posted by Michael Nelson <mike-nelson-ODAAT at WORLDNET.ATT.NET> Jan 31, 2000
- 508 views
David Cuny wrote: >If Euphoria had classes, you wouldn't need structures. The data would be >encapsulated into the classes, not in sequences. So you'd avoid having to >add all that overhead to sequences. > >I vote Yes. Implementing namespace *is* OOP. For example: > > class = include file > objects = scoped variables > methods = scoped routines > inheritance = scoped include files > >-- BEGIN EXAMPLE -- > > -- point.e > integer x, y > > procedure init( initX, initY ) > x = 0 > y = 0 > end procedure > > procedure plus( integer dx, dy ) > x += dx > y += dy > end procedure > >-- END EXAMPLE -- > >The above example, declares a Point class. Currently, we only get a single >instance of the class. Namespaces clarifies that we really *are* dealing >with a class: > > point.init( 10, 20 ) > point.add( 3, 4 ) > ? { point.x, point.y } > >The only thing that we won't have is the ability to create more than one >instance. If you add that, you've got a complete OOP system: > > module point declares class point > point point1, point2 > > point1.init( 10, 20 ) > point2.init( -30, 10 ) > >Note that: > > - types don't have to be added to sequences > - old code doesn't break > - people don't *have* to use OOP > >-- David Cuny > David, I find your ideas fascinating--would you be will to provide some more detailed examples? The idea class=include file seems very Java-Like to me. --Mike Nelson