Class creation

Khadija EL MAHRSI khadija.elmahrsi at
Thu Jun 14 21:55:28 CEST 2012

Yes I've noticed this and I've tried creating another method and called it
instead of init but got an error along the lines of method not defined even
though I made sure over and over that I wrote the method properly. However,
after seeing your reply, maybe I should take another look at my code, maybe
I missed something.

2012/6/14 Jorge Marques Pelizzoni <jorge.pelizzoni at>

> Khadija,
> You might have not noticed but there is no such thing as constructor
> methods proper in Oz. The language only requires that you should
> specify some method (with arguments) to be called upon creation of an
> object. That is the whole point of the second argument to New, and it
> can be virtually any method of your choice. So you can create as many
> constructors as you see fit. For example (please pardon my Oz. It's
> ages since I last wrote Oz programs):
> class C
>   attr someattr
>   meth init1
>      someattr := unit;
>   end
>   meth init2(V)
>      someattr := {NewCell V}
>   end
>   meth get($)
>       @someattr
>   end
> end
> C1 = {New C init1}
> C2 = {New C init2(10)}
> C3 = {New C get(_)}
> Cheers,
> Jorge.
> 2012/6/14 Khadija EL MAHRSI <khadija.elmahrsi at>:
> > Hi,
> > what you said is close to what I meant: a way to create instances of a
> same
> > class that don't necessarily share the same number of passed arguments to
> > the init method (and eventually respond differently to the passed
> > arguments).
> > I've also thought about some of the solutions you've listed but to be
> honest
> > I thought it would be such a hassle when it could've been made alot
> easier
> > by allowing something close to multiple constructors where you could have
> > different initialization methods to call according to your need.
> > Thanks for the reply. I just wanted to make sure I had no other choice
> > before resorting to other solutions.
> _________________________________________________________________________________
> mozart-users mailing list
> mozart-users at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the mozart-users mailing list