* Roy Vegard Ovesen -- Friday 06 April 2007:
> I assumed that it was possible to name the arguments when calling the
> function, like in Python. And that you could then give them in arbitrary
> order.
No, that's not the case in Nasal.
> How do I add a <repeat> argument to the aircraft.light.new method? If I add
> it
> before <switch> then that will certainly break things. If I add it after
> <switch> then <switch> is no longer optional.
And that's the reason for the type checking. :-)
> Another solution would be to set the last element of the pattern to the
> number
> of times to repeat the pattern, -1 meaning repeat forever. [...]
> Third option is to set the last element in pattern to the negative number of
> times to repeat. [0.5, 0.5, -3],
No. I don't think that this belongs to the constructor at all. It's
an action on the light/flasher device, and nothing that defines the device.
I think the best way is to interpret the switch() method parameter like so:
foo.switch(1) ... turn on (or any other value >0)
foo.switch(0) ... turn off
foo.switch(-2) ... turn on for two cycles
This doesn't break compatibility (who used negative number?), and it even
looks like "up to 2 times", or from 0-2. And if you want that to be define
at construction time, then you can still write:
var foo = aircraft.light.new("something", [1,1,1,1]).switch(-10);
... as the switch method returns "me".
m.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel