back2dos / tinkerbell

MIT License
83 stars 8 forks source link

feature request: put tink arguments at start of new() #20

Closed raould closed 11 years ago

raould commented 12 years ago

"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.

back2dos commented 12 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.

raould commented 12 years ago

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. :-}

raould commented 12 years ago

e.g. consider trying to add ?pos:haxe.PosInfos to the new() argument list.

back2dos commented 12 years ago

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.

raould commented 12 years ago

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.)

back2dos commented 12 years ago

Thanks for the feedback, I'll see what I can do ;)

back2dos commented 11 years ago

Seems #34 dealt with this.