Re: OOP example

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

On  0, dstanger at belco.bc.ca wrote:
> 
> Thank you for answering my OOP questions.
> 
> I just had a breakthrough regarding classes. I had understood the concept of
> a class being variables and routine in one but I could not wrap my brain
> around how to create a class. Now I think that I figured it out:
> 
> constant TALK = 1
> 
> procedure talk(sequence s)
>     puts(1, s)
> end procedure
> 
> integer i
> i = routine_id("talk")
> 
> sequence foo
> foo = {i}
> 
> call_proc(foo[TALK], {"Hello World!"})
> 
> Is this how you arrived at the first example in your post?
> 
> David S.
> 

100% correct.

You could also emulate variables:

 constant TALK = 1, HELLO = 2
 
 procedure talk(sequence s)
     puts(1, s)
 end procedure
 
 integer i
 i = routine_id("talk")
 
 sequence foo
 foo = {i, "Hellow World!"}
 
 call_proc(foo[TALK], {foo[HELLO]})

jbrown



-- 
http://fastmail.fm/ - Access your email from home and the web

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

Search



Quick Links

User menu

Not signed in.

Misc Menu