proc/MyProc(...)
If you are writing a procedure with variable arguments, you can insert "..." into the argument definition. This has no effect on the program, but is useful as a reminder that it takes variable arguments. Other programming languages have "..." as explicit, mandatory syntax for variable argument functions. DM gives you the choice.
Neat.
Jan 30 2007, 7:49 pm
|
|
Very.
|
Yeah, I figured that out one night when I was programming and I couldn't figure out what to name an argument so I just put '...' there until I could come back to it. Later on I forgot I had done it and was amazed it compiled.
|
I used to put ... under things I was going to finish later, matter of fact I still do.
:P |
So what does it do exactly? Just let the proc take args without specifying what they are? How is that useful?
|
Jmurph wrote:
So what does it do exactly? Just let the proc take args without specifying what they are? How is that useful? ... is simply totally ignored by the compiler. Whether you use ... or not, you can get a proc's arguments from the args[] list. |
It's main purpose is just to let you know it'll accept multiple arguments, probably from the args list.
|
Yeah. The thing I find neat about it is that it's like the braces: you don't have to include ... to specify variadic arguments in a function, unlike other programming languages which make them mandatory. You can either go with or without and it'll work perfectly either way; it's more of a convenience for the end user to know it accepts variable arguments.
The latest library I'm working on has two variadic argument procs, so I stuck it in there and gasped when it compiled and worked perfectly. [edit]Variadic isn't a word? Phooey. It's a word now. =P[/edit] |
I don't think this is doing what you think it's doing. :-)
... is just an acceptable variable name. It also works with Proc(....) or any number of dots really. Or even Proc(thisFunctionHasMultipleArguments) |
Well, "..." isn't really an acceptable variable name, given that variable names are identified as /[A-Za-z_][A-Za-z\d_]*/. Somehow, something had to permit periods in that sense.
Unless ... is actually an acceptable variable name in any other context as well, in which case this is actually the opposite of what we normally have: instead of a "bug" which is actually a feature, it's a "feature" which is actually a bug! |