Jump to content


Uninitialised "things"


  • This topic is locked This topic is locked
49 replies to this topic

#41 sabriath

sabriath

    12013

  • GMC Member
  • 3149 posts

Posted 09 April 2011 - 10:16 PM

If you want a fright, look up the SIMD instruction set, now there's a set of scary command names

Those aren't so scary....
pack
unpack
signed saturation
unsigned saturation
byte
word
double word
low
high
packed...
..add
..multilply
..subtract
..multiply then add
etc.

odds are it was part of a GOTO joke

Why does everyone hate 'goto' so much? How else do you break out of a second/third/Nth tier nested switch/for/otherloop block efficiently?



As for arguments in scripts...I just thought of something, what if you had:

execute_string("somevar = argument12;");

Obviously GM wouldn't know that "argument12" is being used...this severely breaks a vital piece of GM's coding ability, and what makes it versatile. Although I do agree that a boundary should be made, it should be left up to the programmer instead of automatic (Erik gives another example of such a failure in GM if used automatically).
  • 0

#42 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1643 posts
  • Version:GM:Studio

Posted 10 April 2011 - 12:20 AM

If you want a fright, look up the SIMD instruction set, now there's a set of scary command names

Those aren't so scary....
pack
unpack
signed saturation
unsigned saturation
byte
word
double word
low
high
packed...
..add
..multilply
..subtract
..multiply then add
etc.

odds are it was part of a GOTO joke

Why does everyone hate 'goto' so much? How else do you break out of a second/third/Nth tier nested switch/for/otherloop block efficiently?



As for arguments in scripts...I just thought of something, what if you had:

execute_string("somevar = argument12;");

Obviously GM wouldn't know that "argument12" is being used...this severely breaks a vital piece of GM's coding ability, and what makes it versatile. Although I do agree that a boundary should be made, it should be left up to the programmer instead of automatic (Erik gives another example of such a failure in GM if used automatically).


About GOTO, as far as I know, its like a singleton. It is supposedly not recommended, but yet it is known to be useful and simply works. And I'm guessing because of how known that story is, it got turned into joke material, similar to Chuck Norris.

About execute_string, that would suck to lose that function. I'd rather risk GM not being able to detect arguments being used in strings than to lose that function. But that's just me. Sadly enough, execute_string somewhat falls into the same category I mentioned above about GOTO and the singleton.
  • 0

#43 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9278 posts
  • Version:Unknown

Posted 10 April 2011 - 02:57 AM

Is there anything wrong with teaching the newbies that numbering in programming usually starts at 0?

While we're here, are we making character positions in strings start at 0? If we are teaching them numbering starts at 0, let's keep it consistent.
  • 0

#44 Desert Dog

Desert Dog

    GMC Member

  • Global Moderators
  • 6409 posts
  • Version:Unknown

Posted 10 April 2011 - 04:03 AM

After some thought, I give the array error thing a check.

I'm a bit more tentative about the fixed script argument thing, it reduces flexibility a touch, but the speed increase is worth it for me, so check that, too.

I am wondering about backwards compatability, though.
  • 0

#45 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9278 posts
  • Version:Unknown

Posted 10 April 2011 - 04:24 AM

The fixed script arguments aren't reduced in flexibility, as anything you could do before can still be done but you will need to use the argument array (argument[x]) instead of the argument variables (argument0, argument1...).

As far as backwards compatibility goes, there are very few reasons why people should be having an unknown number of arguments, so almost no one should be doing anything that will now cause errors. Those that are can simply change argument0 to argument[0] and all is fixed.
  • 0

#46 TheMagicNumber

TheMagicNumber

    GMC Member

  • GMC Member
  • 5247 posts
  • Version:Unknown

Posted 10 April 2011 - 05:18 AM

var realOrStr;
dim(array, 10, 0);
Why not be consistent and have:
var realOrStr;
var array[10];
variable_array_clear("array", 0);
You could always have the var statement accept initial values, and assume the initial value for an array is for all elements.

GM is already C and Pascal style, don't add on crap from BASIC now.

Edited by TheMagicNumber, 10 April 2011 - 05:18 AM.

  • 4

#47 Manuel777

Manuel777

    InvaderGames

  • GMC Member
  • 2957 posts
  • Version:GM:Studio

Posted 10 April 2011 - 04:05 PM

GM is already C and Pascal style, don't add on crap from BASIC now.

Sometimes we can aaall agree with you TMN, sometimes :)

going back to the arguments stuff, i really liked the argc and dim() implementations.. but letme get this straight; calling a script:
MyScriptName(value,x,y,"Hello");
will have four arguments, so the argc will be four, and thats it.. you dont need to go trough all the 15 arguments to initialize them as zero.. i really never saw the point on that since no other languaje does it and it may turn buggy (as mike stated)
So, an error when you try to access argument[5] in the function above would be a nice idea, something like "Uninitialized argument [5] on function MyScriptName [blah blah]"
An here is where dim() comes in, in case you want to define initialized arguments as zero? Am-i-rite?? (if so i like it a lot)
  • 0

#48 broadsword

broadsword

    GMC Member

  • New Member
  • 345 posts

Posted 10 April 2011 - 04:20 PM

My only concern with the argument change is that I currently use it to overload scripts in GM. For example consider this function/script:

show_dialog(x,y,string,width,height,txt_speed,skip_key);

by adding the following to that script:

var width, height; //,etc...
width = 200;
height = 100;

if (argument3) width = argument3;
if (argument4) height = argument4;
//etc...

I can call show_dialog like this to use default values:

show_dialog(x,y,string);

Will this new error handling remove this functionality and if so, will there be any other way to overload a script in GM?
  • 0

#49 kburkhart84

kburkhart84

    GMC Member

  • GMC Member
  • 1643 posts
  • Version:GM:Studio

Posted 10 April 2011 - 06:22 PM

My only concern with the argument change is that I currently use it to overload scripts in GM. For example consider this function/script:

show_dialog(x,y,string,width,height,txt_speed,skip_key);

by adding the following to that script:

var width, height; //,etc...
width = 200;
height = 100;

if (argument3) width = argument3;
if (argument4) height = argument4;
//etc...

I can call show_dialog like this to use default values:

show_dialog(x,y,string);

Will this new error handling remove this functionality and if so, will there be any other way to overload a script in GM?


It has already been stated that using the array method to access arguments(like argument[5]) would keep the old functionality.
  • 0

#50

  • Guests

Posted 11 April 2011 - 09:15 AM

okay... closing this one down now.

The rules are;

  • if you use argument0 to argument15, then you MUST supply up to that number in the argument list. So if you use argument2, you must supply 3 arguments - exactly.
  • If you use the argument array (argument[x]) then you are free to supply as many or as few arguments as you wish.
  • If you use both argumentX and argument[x], then you MUST supply up to argumentX, but are free to supply more if you wish. So if you use argument1 and argument[x], then you must supply at LEAST 2 arguments, but can then use any optional ones that have been passed in.
  • argument_count will hold the number of arguments passed. (0 is for no arguments passed)
  • accessing argument[argument_count] or higher, will throw an error.


If/When I come to do arrays (Prob won't get into 8.1, but not sure yet), I'll post those rules as well.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users