Closed raould closed 11 years ago
I really don't know what to do about this to be honest.
I am hesitant to make this the default now, because it might break a lot of code. However I wouldn't mind making this in option, if you have a syntax to propose, that you'd be happy using.
yeah, i can see your point about it being dangerous. maybe you could use another sigil so that
var foo:Int = _ // append var foo:Int = __ // prepend
dunno, just a random thought. :-}
e.g. consider trying to add ?pos:haxe.PosInfos to the new() argument list.
Is that why you actually need the feature? If so, I could actually detect if the last argument is a haxe.PosInfos and keep it as the last argument. Would seem like a sensible thing to do.
nope, not only. :-)
i have a set of classes that are game state classes. they are kinda in a view hierarchy. there are some fairly standard arguments they would all take, and sometimes some extra arguments only some take.
some of those constructors don't actually need to retain the fields for ever in the instance, they are just passing some of the values immediately into another constructor. so using = is overkill, but i still want to get the value, so i would have to either use = and feel sad or would have to manually specify the arguments to the constructor function, then placement issue arises.
(if you still have that .zip, look at constructors of LevelState.hx vs. InLevelState.hx, might be an example case from my (questionable) code.)
Thanks for the feedback, I'll see what I can do ;)
Seems #34 dealt with this.
"All additional arguments are appended to the argument list in order of appearance."
it would be nice to have a prepend option. i actually find i want that more often, so far.