|
|
"MessyBlob" <nomail@nomail> wrote:
>
> Doesn't JavaScript have the ability to assign properties to objects as they are
> being instantiated?, e.g.
>
> Sph = new Sphere( {
> radius: 1,
> position: [0,0,1]
> } );
A host of languages has this.
The problem is still the scope: However you toss and turn it, you can't just go
ahead and do some stuff in the new object's scope (or "namespace" or however
you want to call it) without some added hassle.
The problem is that all mainstream languages do initialization of an object by
passing some expressions as parameters, with the expressions being evaluated in
the scope of the calling block. Plus they're evaluated before the object is
created, so can't have side effects on the object.
Post a reply to this message
|
|