Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by vincentpiel

I noticed a bug that got me crazy for an hour or so.
If you extend a class, and within that class you define a property using another constructor, say : myThing : new Thing(), then it will be a static member for all
instance e.g. firstObject.myThing === anotherObject.myThing.
BUT if you declare it null : myThing : null, then you initialize in the constructor ('init') : this.myThing = new Thing; you now have one 'Thing' per object.
I think this behaviour is misleading, and should at least be notified, but even better corrected. I understand it is most usefull to have sounds, images, ... to be static, but it should not be default behaviour.

1 decade ago by dominic

Sadly, it's impossible to copy a Class instance while maintaining the whole prototype chain. I tried it a few month ago, but couldn't get it working in a cross browser way.

I could probably throw a warning when ig.copy skips over a Class instance; ig.Image and friends should be silenced though.

Any other ideas how to make this behavior more obvious?

1 decade ago by vincentpiel

Well after thinking it through i though that it's not a bug, it is PURELY conventionnal : when you extend a Class, and then you set your
bonusManager = new BonusManager(),
do you intend to :
(A) give bonusManager a value, like for an integer (numberOfBonus = 6), that will then be used for all instances ?
OR do you intend,
(B) on each instanciation of the class, that each new instance builds its own instance of BonusManager ??????
The languages i use (vb.net / C# ) do use the (B) convention.
--->>> Just document that it is the (A) convention for the moment.

(( I did a few tries to have it work in the (B) way, with object.constructor, but having it work + having it to work on all platforms is out of reach for me now... :-) ))
Page 1 of 1
« first « previous next › last »