This is the talk page for discussing improvements to the Variadic function article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||
|
To-do list for Variadic function:
|
Removed from the article for discussion:
Optional arguments (optargs) do not make a function variadic, even though it may look that way if you examine only the calling code. When a function with optargs is executed, each of the args is bound to some value -- be it a supplied value from the function call, a default value from the function definition, or a null value in the absence of a default value.
The same is true for keyword arguments (kwargs), as in Python or Common Lisp -- a keyword argument gets populated with a value from the call, or it doesn't and defaults to a null value, but it's still bound in the environment under which the function-body is evaluated.
What's going on in variadic functions (varargs, rest args) is that passed-in arguments are not each used to supply a value for a variable. The handling of the list of passed-in arguments is under the control of the function code itself. Instead of binding a bunch of variables, the arguments are passed in as a list. (Or, in some languages, a list and a length.) This is why C bozos can walk off the end of a varargs list and end up smashing the stack. --FOo 23:17, 26 May 2005 (UTC)
In the case of Python, isn't this a case of a distinction without a difference in that a function ends up with a variable number of arguments that it can access. Putting aside the default arguments, Python does have variadic functions. --Paddy (talk) 12:48, 23 June 2008 (UTC)
The code example in this section is not commented at all, nor is there a caption explaining what its purpose is. This should be corrected. --Walkeraj 22:06, 3 October 2007 (UTC)
I was hoping to find an example here of how to create a variadic function wrapping another such function.
Label *createLabel(Object *owner, const char * format, ...) { char labelDescription[200]; snprintf(labelDescription, 200, format, /* What goes here?? */); return new Label(owner, labelDescription); }
99.67.239.69 (talk) 01:09, 3 May 2011 (UTC)
I've added the ((manual)) tag to the section on specific implementations. A brief, prose overview with perhaps one or two examples might be useful, but what we have is just a sprawling reference manual on how to use variadic parameter passing in multiple languages, and that's not what a Wikipedia article is for. -Miskaton (talk) 12:54, 11 April 2008 (UTC)
What is the use of such a classification?
The list on its own is of very little use and should be deleted. --Paddy (talk) 05:35, 30 July 2010 (UTC)
Is there any advantage to using a vadiadic function over say, a list? Perhaps it's more useful in a language like C where you can't construct lists easily? What are the advantages/disadvantages? Language bloat? —Preceding unsigned comment added by 99.224.181.247 (talk) 00:16, 12 May 2011 (UTC)