1. Heaven help me, I miss the C++ class (not a question,

Well, a little. Actually not so much. But I do miss some of the things it
can do.

Sequences are really powerful little dudes. If I want to code a simulation,
I can set up a sequence, say
sequence people

and give them properties say
sequence thoughts, feelings, actions

So far, I can duplicate what I do in C++. Just in C++ it would be approx.
class people{
int thoughts, feelings

But the EU way is better because I can decide later what thoughts,
feelings, and actions really are (though I can do that clumsily in C++
using overloading, I guess).

Now here's the sticky part (speaking of which, thanks for sticking with
this wordy message so far....). In C++, I can define procedures to go with
my people. And using inheritance, I can make them different. Say I want to
initiate a subclass of people, call them Good, and another subclass, call
them Bad.

class Good::people { //(or something like it)
void beGood();
void strut();

class Bad::people {
void partyTooMuch();
void getStuffed();

My Good::people and Bad::people are exactly the same except for their
actions (and maybe their thoughts and feelings if I want), but these folks
all inherit from the same generic people class.

Now in EU, I can see doing something similar in a different way, almost
upside down. I've already got
sequence people

I can add
constant good = 1
constant bad = 2

sequence EUMailingList, LinusT, BillG, CShultz, Satan, HellsAngels

people[good] = {EUMailingList, LinusT, CShultz}
/*okay, I'm a suckup*/
people[bad] = {BillG, Satan, HellsAngels}

But my problem comes in when I now have to give them behaviors and
attributes. I have to do it individually. I could use a procedure with a
sequence passed in, like this

procedure beGood(sequence aPeople)
aPeople[good] = blah, blah, blah

and that would help cut down on errors (but not make them almost out of the
question, like in C++). And the C++ statement is very elegant

good.beGood()

And it does it for all good people. (I think)

Is there an easy, elegant way to do this in EU?

Is there a way to emulate this using sequences that I'm missing? Would it
be impossible, or useless, or worse, dangerous, to be able to have a
*procedure or function* be part of a sequence, say in a future release?
Reasoning being, then I could write

sequence people, thoughts, feelings, actions
constant
good = 1
bad = 2

people[good] = {thoughts[good], feelings[good], actions[good]}
actions[good] = {procedure beGood, procedure strut}

people[bad] = {thoughts[bad], feelings[bad], actions[bad]}
actions[bad] = {procedure partyTooMuch, procedure getStuffed}

So I guess you can see where I'm going with this. In a way, I think this is
more intuitive than the C++ class system. And it almost certainly wouldn't
lead to code bloat and bogging the way C++ can.

Comments? Corrections? Disdain?

Remember, I'm worse than stupid -- I know just enough to blow something up.
And I really do program by voodoo. My last computer class was an
engineering simulations class over 10 years ago. Be gentle, go slow, and
hide your laughter. Think of me as your dog. Oh, and sorry this was so long.
Sherm

new topic     » topic index » view message » categorize

2. Re: Heaven help me, I miss the C++ class (not a question,

I have acomplished this feat!
if you want my OOP library(which is very simple) please Email ME at
whoisian at hotmail.com.

You won't be disapointed.
just make sure to credit Ian Smith or No Solution when you use it in your
programs. (Ian Smith is Me, No Solution is another Alias I go by for my
website)

dude. OOP is the way.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

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

3. Re: Heaven help me, I miss the C++ class (not a question,

On Thu, 24 Feb 2000, SR Williamson wrote:

> <snip>
> Now here's the sticky part (speaking of which, thanks for sticking with
> this wordy message so far....). In C++, I can define procedures to go with
> my people. And using inheritance, I can make them different. Say I want to
> initiate a subclass of people, call them Good, and another subclass, call
> them Bad.

> My Good::people and Bad::people are exactly the same except for their
> actions (and maybe their thoughts and feelings if I want), but these folks
> all inherit from the same generic people class.
> ....
> But my problem comes in when I now have to give them behaviors and
> attributes. I have to do it individually. I could use a procedure with a
> sequence passed in, like this
>
> procedure beGood(sequence aPeople)
> aPeople[good] = blah, blah, blah
>
> and that would help cut down on errors (but not make them almost out of the
> question, like in C++). And the C++ statement is very elegant
>
> good.beGood()
>
> And it does it for all good people. (I think)
>
> Is there an easy, elegant way to do this in EU?
>
> Is there a way to emulate this using sequences that I'm missing? Would it
> be impossible, or useless, or worse, dangerous, to be able to have a
> *procedure or function* be part of a sequence, say in a future release?

I can't say whether you'll consider this elegant, but it's quite possible to
define a sequence to contain function or procedure id's:

constant NAME = 1, GETS_RICH = 2, BECOMES_FAMOUS = 3, GREED = 4

function DoGood(object person)
 -- do stuff
 return person
end function
constant NICE = routine_id("DoGood")

function DoEvil(object person)
 person[GREED] += 1
 HireMoreLawyers()
 return person
end function
constant NAUGHTY = routine_id("DoEvil")

constant -- create a generic person
 person = {"",      -- name
               NICE, -- default action when "gets rich"
               NICE, -- default action when "becomes famous"
               .0,      -- greed factor
               ...}      -- other attributes

sequence
 CShultz, BillG

 CShultz = person -- make a copy of the generic person
 CShultz[NAME] = "Charles"
 -- CShultz inherits the "NICE" action from the generic person,
 -- as well as the greed factor and other attributes

 BillG = person
 BillG[NAME] =  "Wild Bill"
 BillG[GETS_RICH] = NAUGHTY -- overrides the default niceness

function react_to(object person, integer event)
 return call_func(person[event],{person})
end function

 BillG = react_to(BillG,GETS_RICH)
 CShultz = react_to(CShultz,GETS_RICH)

So, you're basicaily defining varied responses to the same event.
Usually the event will be a mouse click or something.
In these calls, I am returning a modified (self), so
that, for example, when BillG makes money, the DoEvil function can increment
this person's greed factor, and return an even more greedy BillG.
---
Legal Disclaimer: the variables above are not intended to bear any resemblance
to  persons living.
---
Irv

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

4. Re: Heaven help me, I miss the C++ class (not a question,

At 07:52 AM 02/25/2000 -0500, you wrote:
>On Thu, 24 Feb 2000, SR Williamson wrote:
>
<SNIP!>
>Legal Disclaimer: the variables above are not intended to bear any resemblance
>to  persons living.
>---
>Irv

So that leaves resemblence to the DEAD?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu