RE: The Euphorian Way

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

Hello SR.Williamson,


>But one of the primary dreams of OOP was to enable code re-use, no
>matter if you're writing accounting, GUIs, games, simulations
>(especially useful for simulations). I think the Eu includes work BETTER in 
>some ways for code re-use, but some things they just don't get at.
>
>For example, I cut my simulation teeth on a traffic simulator in school, 
>written in something called SLAM-II. This was even before C++, back in the 
>80s. But you could define an object ( a car or a redlight, for example) 
>that would have specific attributes. But you couldn't change just one 
>attribute ( e.g. make all lights have a minimum red of 1 minute) and have 
>it filter to all lights. You had to change each one by hand. Fine for the 
>academic exercise, since we only had to simulate 3
>lights. But for a real simulation, with maybe 100 or more, it would be 
>exhausting.
>
>In C++, I can make that change. In Eu, AFAIK, I have to do it by hand 
>again, though I suspect there might be a way to avoid that if you're 
>clever.

There is if you use LOOP lib: my Euphoria OOP library. It doesn't
take too much cleverness either. :) When you create a property or
assign an already created property to a new class, you are required
to provide a default value. You supply the value that you think
would be the most common for that particular class. An example:

constant TrafficLight = NewClass(0) -- 0 means now superclass
  constant MinRedTime = NewProp( 60 ) -- seconds

Now all objects created of the class "TrafficLight" have the default value 
of 60 in their 'MinRedTime' property unless you change it.

Other convieniences of LOOP include:
  changing property values at object-creation-time
  Setting more than 1 property at a time;
  Getting more than 1 property at a time.


later,
Lewis Townsend

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

Search



Quick Links

User menu

Not signed in.

Misc Menu