does not need to be "dim(
)'d", as it's already implicitly setup by the calling function and has filled in all the values for you. My preference would be to have accessing argument[argument_count+1]
throw an error, because once you have access to the number of arguments there is no excuse to go outside them. Anyone got a valid reason?
Unfortunately, all this is RUNTIME, not compile time. This means you'll get a runtime error. Not my preference, but it's the simplest way of implementing it. If I did it any other way, it would take for ever to write; so runtime it is. Sorry.
Aside from that; yes. If you access only one argument; say argument12
, then I'll expect 13 arguments to be passed. If you use argument[x]
instead, then it simply won't bother checking argument counts.
) - yes. Good point. I'll have to check, but I think I can have variable numbers of args in system functions.dim
is a well known BASIC function. It's also short, and easy to remember. I see no reason to call it array_init()
. I'm happy to keep it lower case, and happy to rename argc
(which, in C means arg
ount) to argument_count
I've already said this. If you WANT to drop arguments, you'll be able to use the syntax argument[x]
I'm currently making no further changes to the image editor.
Rusky, this is a quick fix. We have countless issues with this kind of error. It's bad practice, and it's a bug waiting to happen for most folk. Everyone will simply forget to type the right number of parameters in now and then. So we're going to fix it now. The better and cleaner the code, the more we can do with it later.
I've also already said we won't be doing named arguments in this version.
Erik Leppen: I don't really care about backwards compatibility when the thing I'm breaking is bad coding and bugs.
LOL - it's hardly a GUESS!! You've accessed up to argument3 in your script, so you NEED to pass 4 arguments. Hows that a secret guess? You've already dictate how many arguments you'll be using by... well... using them in your script!argument_count
it is. I have no problem calling it that. (That said. Programming is FULL of abbreviation and funny names, you really should get used to them. If you want a fright, look up the SIMD instruction set, now there's a set of scary command names.)
I'll look into a way to free an array. I agree, it would be nice! Of course... we could make dim() resize it down as well.... dim(1)
would be the smallest.
I would love to have one of these...var arr[x][x]
dim array[x][x], 0array[1..10]=??
could be interesting too.
However, all these would take significant work, not the least making sure we haven't broken everything else!! They modify the base syntax, where as dim() is just another command. So for this version, dim() it is. Sorry.
I've also already said we won't be adding extra parameters. We'd like to, but there are big issues with that. You'll only get that once we rewrite it all.
I agree. If some one only uses argument0
, then I say that's a bug, as clearly they'd have to pass 4 arguments for that code to work correctly! As I said before... not forcing this is a bug waiting to happen. Also consider newbies using argument1
instead of argument0
, simply because they think it starts at 1.