haxegon / zeedonk

Haxegon + Puzzlescript = Zeedonk!
http://www.zeedonk.net
12 stars 2 forks source link

discuss the several current ways of providing values to functions #321

Closed increpare closed 9 years ago

increpare commented 9 years ago

there are several ways of passing values to functions in haxegon, we should discuss this

//#1, via function parameters
Gfx.setpixel(1,2, Col.Red);

//#2, via static variables
Gfx.linethickness = 2;

//#3, via optional parameters
Font.setfont(Font.blah, 3); //second parameter is optional, set to 2

//#4, via structs
Text.display(x,y,bip,bop,{...blurgh...});
TerryCavanagh commented 9 years ago

It does seem a bit gross when you put it all together like that, but to me they all individually feel like the best way of doing what they're doing.

Getting rid of structs is tempting. One way to do that would be to have a lot of new functions which changed settings, settextalpha() and setimagerotation() and things like that. Maybe that's worth thinking about.

I'm ok with the optional parameters. Maybe we need a better notation for them in the documentation/autocomplete? Pico8 does this to denote optional parameters in it's documentation:

pset x y [c]
spr n x y [w h] [flip_x] [flip_y]
clip [x y w h]
print str [x y [col]]
TerryCavanagh commented 9 years ago

Ok, after discussing this over lunch, here's the plan:

But this can wait until after the 0.5 beta.