Revision history for KeyPgDots


Revision [23734]

Last edited on 2019-11-06 04:27:08 by fxm [typo (marco instead of macro)]
Additions:
In the procedure body, ##[[KeyPgCvaList|cva_list]]## data type, and ##[[KeyPgCvaArg|cva_arg]]## macro can be used to expand the ellipsis parameter (##**...**##) to obtain the values of the arguments passed to the variadic procedure. The argument list, once initialized with ##[[KeyPgCvaStart|cva_start]]## or copied with ##[[KeyPgCvaCopy|cva_copy]]##, can be passed to another procedure taking a ##[[KeyPgCvaList|cva_list]]## parameter.
Deletions:
In the procedure body, ##[[KeyPgCvaList|cva_list]]## data type, and ##[[KeyPgCvaArg|cva_arg]]## marco can be used to expand the ellipsis parameter (##**...**##) to obtain the values of the arguments passed to the variadic procedure. The argument list, once initialized with ##[[KeyPgCvaStart|cva_start]]## or copied with ##[[KeyPgCvaCopy|cva_copy]]##, can be passed to another procedure taking a ##[[KeyPgCvaList|cva_list]]## parameter.


Revision [22839]

Edited on 2019-07-24 13:59:16 by fxm [added note in the "Variadic Macros" paragraph]
Additions:
**Note:** To distinguish between the different arguments passed by //variadic_parameter//, you can first convert //variadic_parameter// to a string using the ##[[KeyPgOpPpStringize|Operator # (Preprocessor Stringize)]]##, then differentiate in this string (//#variadic_parameter//) each passed argument by locating the separators (usually a comma).


Revision [22605]

Edited on 2019-03-10 14:13:39 by JeffMarshall [update with cva_* functions and links]
Additions:
__Variadic Procedures__
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list.
A first argument (at least) must always be specified and the procedure must be called with the C calling convention ##[[KeyPgCdecl|cdecl]]##.
In the procedure body, ##[[KeyPgCvaList|cva_list]]## data type, and ##[[KeyPgCvaArg|cva_arg]]## marco can be used to expand the ellipsis parameter (##**...**##) to obtain the values of the arguments passed to the variadic procedure. The argument list, once initialized with ##[[KeyPgCvaStart|cva_start]]## or copied with ##[[KeyPgCvaCopy|cva_copy]]##, can be passed to another procedure taking a ##[[KeyPgCvaList|cva_list]]## parameter.
On some targets, for backwards compatibility, ##[[KeyPgVaFirst|va_first]]##, ##[[KeyPgVaArg|va_arg]]## and ##[[KeyPgVaNext|va_next]]## can still be used to handle the variable arguments.
__Variadic Macros__
Using an ellipsis behind the last parameter in a ##[[KeyPgPpdefine|#define]]## or ##[[KeyPgPpmacro|#macro]]## declaration allows creation of a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //body// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
__Array Upper Bound__
- ##[[KeyPgCvaList|cva_list]]##
- ##[[KeyPgCvaArg|cva_arg]]##
Deletions:
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument (at least) must always be specified and the procedure must be called with the C calling convention ##[[KeyPgCdecl|cdecl]]##. In the procedure body, ##[[KeyPgVaFirst|va_first]]##, ##[[KeyPgVaArg|va_arg]]## and ##[[KeyPgVaNext|va_next]]## are used to handle the variable arguments.
Using an ellipsis behind the last parameter in a ##[[KeyPgPpdefine|#define]]## or ##[[KeyPgPpmacro|#macro]]## declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //body// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.


Revision [21878]

Edited on 2017-08-25 02:42:27 by fxm [Added in the syntax the "byref" optional specifier for returning by reference]
Additions:
[[KeyPgDeclare|declare]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //proc_name// [[KeyPgCdecl|cdecl]] ( //param_list//, **...** ) { | [ [[KeyPgByrefFunction|Byref]] ] [[KeyPgAs|As]] //return_type// }
Deletions:
[[KeyPgDeclare|declare]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //proc_name// [[KeyPgCdecl|cdecl]] ( //param_list//, **...** ) { | [[KeyPgAs|As]] //return_type// }


Revision [20205]

Edited on 2016-02-10 15:59:17 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] { [[KeyPgSub|sub]] | [[KeyPgFunction|function]] } //proc_name// [[KeyPgCdecl|cdecl]] ( //param_list//, **...** ) { | [[KeyPgAs|As]] //return_type// }
[[KeyPgDim|dim]] //array_symbol// ([//lbound// [[KeyPgTo|to]]] **...**) [[[KeyPgAs|as]] [[DataType|datatype]]] => { //expression_list// }
[[KeyPgPpdefine|#define]] //identifier//( [ //parameters//, ] //variadic_parameter//**...** ) //body//
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument (at least) must always be specified and the procedure must be called with the C calling convention ##[[KeyPgCdecl|cdecl]]##. In the procedure body, ##[[KeyPgVaFirst|va_first]]##, ##[[KeyPgVaArg|va_arg]]## and ##[[KeyPgVaNext|va_next]]## are used to handle the variable arguments.
Only numeric types and pointers are supported as variable arguments (all bytes and shorts passed on variable arguments are implicitly converted to integers, all singles passed on variable arguments are implicitly converted to doubles). ##[[KeyPgString|String]]##s can be passed, in which case a ##[[KeyPgZstring|Zstring]] [[KeyPgPtr|Ptr]]## to the string data is taken.
Using an ellipsis in place of the upper bound in an array declaration causes the upper bound to be set according to the data that appears in the ##//expression_list//##. When the ellipsis is used in this manner, an initializer must appear, and cannot be ##[[KeyPgAny|Any]]##.
Using an ellipsis behind the last parameter in a ##[[KeyPgPpdefine|#define]]## or ##[[KeyPgPpmacro|#macro]]## declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //body// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
- ##[[KeyPgCdecl|cdecl]]##
- ##[[KeyPgVaArg|va_arg]]##
- ##[[KeyPgVaFirst|va_first]]##
- ##[[KeyPgVaNext|va_next]]##
- ##[[KeyPgDim|dim]]##
- ##[[KeyPgStatic|static]]##
- ##[[KeyPgPpdefine|#define]]##
Deletions:
[[KeyPgDeclare declare]] { [[KeyPgSub sub]] | [[KeyPgFunction function]] } //proc_name// [[KeyPgCdecl cdecl]] ( //param_list//, **...** ) { | [[KeyPgAs As]] //return_type// }
[[KeyPgDim dim]] //array_symbol// ([//lbound// [[KeyPgTo to]]] **...**) [[[KeyPgAs as]] [[DataType datatype]]] => { //expression_list// }
[[KeyPgPpdefine #define]] //identifier//( [ //parameters//, ] //variadic_parameter//**...** ) //body//
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument (at least) must always be specified and the procedure must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##. In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.
Only numeric types and pointers are supported as variable arguments (all bytes and shorts passed on variable arguments are implicitly converted to integers, all singles passed on variable arguments are implicitly converted to doubles). ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.
Using an ellipsis in place of the upper bound in an array declaration causes the upper bound to be set according to the data that appears in the ##//expression_list//##. When the ellipsis is used in this manner, an initializer must appear, and cannot be ##[[KeyPgAny Any]]##.
Using an ellipsis behind the last parameter in a ##[[KeyPgPpdefine #define]]## or ##[[KeyPgPpmacro #macro]]## declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //body// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
- ##[[KeyPgCdecl cdecl]]##
- ##[[KeyPgVaArg va_arg]]##
- ##[[KeyPgVaFirst va_first]]##
- ##[[KeyPgVaNext va_next]]##
- ##[[KeyPgDim dim]]##
- ##[[KeyPgStatic static]]##
- ##[[KeyPgPpdefine #define]]##


Revision [17748]

Edited on 2015-09-03 02:43:48 by FxMwikki [Added the implicit numeric conversions applied on the variable arguments]
Additions:
Only numeric types and pointers are supported as variable arguments (all bytes and shorts passed on variable arguments are implicitly converted to integers, all singles passed on variable arguments are implicitly converted to doubles). ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.
Deletions:
Only numeric types and pointers are supported as variable arguments. ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.


Revision [17747]

Edited on 2015-08-31 11:42:02 by FxMwikki [Complemented syntax and description]
Additions:
Only numeric types and pointers are supported as variable arguments. ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.
A variadic procedure name can never be overloaded.
Deletions:
Only numeric types and pointers are supported as parameters. ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.


Revision [17746]

Edited on 2015-08-31 08:15:50 by FxMwikki [Complemented the syntax]
Additions:
[[KeyPgDeclare declare]] { [[KeyPgSub sub]] | [[KeyPgFunction function]] } //proc_name// [[KeyPgCdecl cdecl]] ( //param_list//, **...** ) { | [[KeyPgAs As]] //return_type// }
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument (at least) must always be specified and the procedure must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##. In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.
Deletions:
[[KeyPgDeclare declare]] { [[KeyPgSub sub]] | [[KeyPgFunction function]] } //proc_name// [[KeyPgCdecl cdecl]] ( //param// [[KeyPgAs as]] [[DataType datatype]], **...** )
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##. In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.


Revision [15462]

Edited on 2011-10-25 11:52:23 by CountingPine [Mention parameter type limitations]
Additions:
Only numeric types and pointers are supported as parameters. ##[[KeyPgString String]]##s can be passed, in which case a ##[[KeyPgZstring Zstring]] [[KeyPgPtr Ptr]]## to the string data is taken.


Revision [15312]

Edited on 2011-10-01 09:49:23 by DkLwikki [Put variadic #define example here]

No Differences

Revision [15311]

Edited on 2011-10-01 09:46:13 by DkLwikki [Put variadic #define example here]
Additions:
Using an ellipsis behind the last parameter in a ##[[KeyPgPpdefine #define]]## or ##[[KeyPgPpmacro #macro]]## declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //body// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
- ##[[KeyPgPpdefine #define]]##
Deletions:
Using an ellipsis behind the last parameter in a [[KeyPgPpdefine #define]] or [[KeyPgPpmacro #macro]] declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //macro_text// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.


Revision [15310]

Edited on 2011-10-01 09:45:10 by DkLwikki [Put variadic #define example here]
Additions:
[[KeyPgPpdefine #define]] //identifier//( [ //parameters//, ] //variadic_parameter//**...** ) //body//
Using an ellipsis behind the last parameter in a [[KeyPgPpdefine #define]] or [[KeyPgPpmacro #macro]] declaration allows to create a variadic macro. This means it is possible to pass any number of arguments to the //variadic_parameter//, which can be used in the //macro_text// as if it was a normal macro parameter. The //variadic_parameter// will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
Declare Function foo Cdecl (x As Integer, ...) As Integer
{{fbdoc item="filename" value="examples/manual/prepro/variadic.bas"}}%%(freebasic)
'' Using a variadic macro to wrap a variadic function
#include "crt.bi"
#define eprintf(format, args...) fprintf(stderr, format, args)
eprintf(!"Hello from printf: %i %s %i\n", 5, "test", 123)
'' LISP-like accessors allowing to modify comma-separated lists
#define car(a, b...) a
#define cdr(a, b...) b
Deletions:
[[KeyPgPpdefine #define]] //identifier//( [ //parameters//, ] //variadic_parameter//**...** ) //macro_text//
Using an ellipsis in a [[KeyPgPpdefine #define]] or [[KeyPgPpmacro #macro]] declaration allows to create a variadic macro, see [[KeyPgPpdefine #define]].
DECLARE FUNCTION FOO CDECL (X AS INTEGER, ...) AS INTEGER


Revision [14861]

Edited on 2010-10-12 08:37:27 by DkLwikki [Added variadic macros]
Additions:
[[KeyPgPpdefine #define]] //identifier//( [ //parameters//, ] //variadic_parameter//**...** ) //macro_text//
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##. In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.
Using an ellipsis in place of the upper bound in an array declaration causes the upper bound to be set according to the data that appears in the ##//expression_list//##. When the ellipsis is used in this manner, an initializer must appear, and cannot be ##[[KeyPgAny Any]]##.
Using an ellipsis in a [[KeyPgPpdefine #define]] or [[KeyPgPpmacro #macro]] declaration allows to create a variadic macro, see [[KeyPgPpdefine #define]].
Deletions:
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##.
In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.
The other usage for an ellipsis is in place of the upper bound in an array declaration, this causes the upper bound to be set according to the data that appears in the ##//expression_list//##. When the ellipsis is used in this manner, an initializer must appear, and cannot be ##[[KeyPgAny Any]]##.


Revision [13875]

Edited on 2008-11-09 10:14:26 by CountingPine [Minor edits, a couple of fixups, elaborate on variable argument usage slightly]
Additions:

[[KeyPgDim dim]] //array_symbol// ([//lbound// [[KeyPgTo to]]] **...**) [[[KeyPgAs as]] [[DataType datatype]]] => { //expression_list// }
The ellipsis (three dots, ##**...**##) is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##.
In the procedure body, ##[[KeyPgVaFirst va_first]]##, ##[[KeyPgVaArg va_arg]]## and ##[[KeyPgVaNext va_next]]## are used to handle the variable arguments.
The other usage for an ellipsis is in place of the upper bound in an array declaration, this causes the upper bound to be set according to the data that appears in the ##//expression_list//##. When the ellipsis is used in this manner, an initializer must appear, and cannot be ##[[KeyPgAny Any]]##.
{{fbdoc item="filename" value="examples/manual/array/ellipsis.bas"}}%%(freebasic)
Dim As Integer myarray(0 To ...) = {0, 1, 2, 3}
Print Lbound(myarray), Ubound(myarray) '' 0, 3
- New to ""FreeBASIC""
Deletions:
[[KeyPgDim Dim]] //array_symbol// ([//lbound// To] **...**) [AS [[DataType DataType]]] => { //expression// [, ...] }
The ellipsis (three dots "...") is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention ##[[KeyPgCdecl cdecl]]##.
The other usage for an ellipsis is in place of the upper bound in an array declaration, this causes the upper bound to be set according to the data that appears in the initializer. When ellipsis is used in this manner, an initializer must appear, and cannot be ANY.
%%(freebasic)
DIM AS INTEGER FOO(0 TO ...) = {0, 1, 2, 3}
PRINT LBOUND(FOO), UBOUND(FOO)
- New to FreeBASIC


Revision [13872]

Edited on 2008-11-09 08:46:51 by YetiFoot [new ellipsis form in array declarations]
Additions:
Used in place of procedure parameter to pass a variable number of arguments, or as the upper bound in an array declaration to denote that the number of elements will be determined by the initializer.
[[KeyPgDim Dim]] //array_symbol// ([//lbound// To] **...**) [AS [[DataType DataType]]] => { //expression// [, ...] }
The other usage for an ellipsis is in place of the upper bound in an array declaration, this causes the upper bound to be set according to the data that appears in the initializer. When ellipsis is used in this manner, an initializer must appear, and cannot be ANY.
%%(freebasic)
DIM AS INTEGER FOO(0 TO ...) = {0, 1, 2, 3}
PRINT LBOUND(FOO), UBOUND(FOO)
- ##[[KeyPgDim dim]]##
- ##[[KeyPgStatic static]]##
Deletions:
Used in place of procedure parameter to pass a variable number of arguments


Revision [10122]

The oldest known version of this page was created on 2007-07-27 10:45:47 by JeffMarshall [new ellipsis form in array declarations]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode