Re: Call for Opinions

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

Juergen Luethje wrote:
> 
> Matt Lewis wrote:
> 
> > Juergen Luethje wrote:
> >>
> >> Matt Lewis wrote:
> >>>
> >>> global euclass Byte( integer b )
> >>> 	procedure Store( atom ptr )
> >>> 		poke( ptr, this )
> >>                         ^^^^
> >> ... for instance, what does "this" mean.
> >> I also saw it in OOEU example programs, but couldn't find an explanation.
> >
> > Mario answered your questions, but I thought I'd give my 2cents, too.
> 
> Thanks to you and Mario, and all others who posted helpful hints here.
> I'll consider your warning, Tommy.
> 
> > OOP basically combines the concepts of data and program logic.  In this
> > case, the data is the object of yype Byte, and the program logic is
> > the procedure Byte::Store() (to use a C++-like notation).  So the program
> > logic should 'know' about the data.  Most OOP languages have an implicit
> > variable that you can refer to.  In ooeu, that variable is 'this'.  So
> > assuming you have something like:
> > }}}
<eucode>
> > Byte b
> > -- ...
> > b.Store( ptr )
> <font color="#330033">> </eucode>
{{{
</font>
> > It's important that Byte::Store() know about 'b', and so it must be
> > passed.  In the ooeu code, the b comes before the store, and dot notation
> > is used.  This is similar to how C++ handles it.  You can call C++ from
> > C or Euphoria (this is what I do in wxEuphoria or EuCOM, for instance),
> > but you have to explicitly pass as a parameter the object.
> 
> In the code snippet above, the parameter 'b' is never used. But this is
> the value that should be stored, isn't it? From a "procedural point of
> view", then I'd like to write:
>    poke( ptr, b )
> but you wrote
>    poke( ptr, this )
> 
> So is 'this' identical to 'b' in this case? If so, could we actually
> write 'b' rather than 'this'?
> 
> >>> struct = MyStruct.New( 0, 0, "Hello, World" )
> >>
> >> Another point that I don't understand:
> >> 'MyStruct.New()' is declared with 2 parameters, but here you call it
> >> with 3 parameters ...
> >
> > Sometimes, you may want to call a method without having a real object,
> > like a constructor.  That's what you're looking at there.  Since there
> > may be more than one function named 'New', you have to let ooeu know
> > that you're interested in MyStruct.New().
> 
> OK. smile
> 
> > However, MyStruct is the name
> > of the euclass, so where does the data come from?  In this case, ooeu
> > requires that you pass the 'this' parameter explicitly.  In the call above,
> > I'm not passing real data, because the whole point is to initialize the
> > object.
> 
> In other words: One parameter (the first?) is passed to the class 'MyStruct',
> and the other two are passed to its method 'New'?
> 
> > It's a somewhat kludgy way to go about this.  In the future, I'm
> > planning on adding a more elegant solution, so that:
> > }}}
<eucode>
> > struct@New( 0, "Hello World" )
> > -- is equivalent to:
> > struct = MyStruct.New( 0, 0, "Hello World" )
> >
> > -- and this:
> > struct~SomeMethod()
> > -- is equivalent to:
> > struct = struct.SomeMethod()
> <font color="#330033">> </eucode>
{{{
</font>
> >
> > Hope that helps clear it up for you.
> 
> I probably should look into a OOP tutorial for beginners, preferably in
> German. The problem is, that this will not tell me how things are
> concrete done in OOEU.
> 
> Thanks,
>    Juergen
> 
> 


I think Euphoria is just fine as a procedural language. With threads and a few
other language improvements, Euphoria would be fine. OOP is cool in modified
interpreters, but I would not like it in official Euphoria, and would probably
move completely away from the language if it did happen.

Regards,
Vincent

--
Without walls and fences, there is no need for Windows and Gates.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu