foo = bar;
in addition to
local foo = bar;
as toplevel declarations? (both would initialize the property
foo
of the definition to which the script belongs to bar
.)Should
var a = [1, 2, 3]; a[-4];
throw or return nil? (a[-3] return 1, a[-1] returns 3.)
Should
var a = []; a[3];
increase the array length, or should one have to do
a[3]=nil;
? (It could also throw, but that wouldn't be helpful.)Opinions? Justified opinions?
>as toplevel declarations? (both would initialize the property foo of the definition to which the script belongs to bar.)
The idea behind that is to have a DefCore like syntax for properties, right? Fine with me
>throw or return nil? (a[-3] return 1, a[-1] returns 3.)
Throw imo. Otherwise someone will start checking whether an array has a specific size by comparing the element with nil. I see it coming!
(On the other hand I still think that a[-1] should be a[GetLength(a)], but, well)
>increase the array length, or should one have to do a[3]=nil;? (It could also throw, but that wouldn't be helpful.)
I would not like to have my array grow when I access members out of range. I'm for an exception there
>Should we have
>foo = bar;
>in addition to
>local foo = bar;
>as toplevel declarations? (both would initialize the property foo of the definition to which the script belongs to bar.)
Any reason for doing that? It may could cause confusing about the range of the variable. (Is it global or local?)
>Should
> var a = [1, 2, 3]; a[-4];
>throw or return nil? (a[-3] return 1, a[-1] returns 3.)
Throw since existing values can be nil, too. ( When nil is returned you can't really decide if it does not exists or is just nil.)
>Should
> var a = []; a[3];
>increase the array length, or should one have to do a[3]=nil;? (It could also throw, but that wouldn't be helpful.)
Again, is there any reason for that? It could create bugs where the length is increased unintentionally. (And thus do something unitended in "for(var x in array)" or other things which uses all values.)
> Any reason for doing that? It may could cause confusing about the range of the variable. (Is it global or local?)
We have local Name = "Name"; in about every Script, shortening that saves a significant amount of boilerplate. I don't think it'll be confusing, nobody is confused about whether functions are global or local either.
> Throw since existing values can be nil, too. ( When nil is returned you can't really decide if it does not exists or is just nil.)
With an exception you can't do anything either, you have to go change the script to check the array length before accessing it. You don't need an exception to write the check. The question it whether you'd make the code pretend that the value is nil, or substantially rewrite it because the exception highlighted a genuine error in the script.
> Again, is there any reason for that?
No, the engine just happens to do that at the moment.
>We have local Name = "Name"; in about every Script, shortening that saves a significant amount of boilerplate. I don't think it'll be confusing, nobody is confused about whether functions are global or local either.
I think we need a macro for that anyway. Having Name="$Name$" (and other standard properties) in every object does not seem very clean to me
>Should
> var a = []; a[3];
>increase the array length, or should one have to do a[3]=nil;? (It could also throw, but that wouldn't be helpful.)
in gwx, we throw because the example
a[1999999]
is a fault AND creates unwished results.
"exceptions" are handled as a runtime error and stop the whole execution of the script and you get an error as your function result.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill