March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -1,9 +1,8 @@
|
|||
{{omit from|BBC BASIC}}
|
||||
Create a function which takes in a number of arguments which are specified by name rather than (necessarily) position, and show how to call the function. If the language supports reordering the arguments or optionally omitting some of them, note this.
|
||||
|
||||
'''Note:'''
|
||||
: Named parameters relies on being able to use the names given to function parameters when the function is defined, when assigning arguments when the function is called.
|
||||
: For example, if f a function were to be defined as <code>define func1( paramname1, paramname2)</code>; then it could be called normally as <code>func1(argument1, argument2)</code> and in the called function paramname1 would be associated with argument1 and paramname2 with argument2.
|
||||
: For example, if a function were to be defined as <code>define func1( paramname1, paramname2)</code>; then it could be called normally as <code>func1(argument1, argument2)</code> and in the called function paramname1 would be associated with argument1 and paramname2 with argument2.
|
||||
: <code>func1</code> '''must also be able to be called in a way that visually binds each parameter to its respective argument, irrespective of argument order''', for example: <code>func1(paramname2=argument2, paramname1=argument1)</code> which ''explicitly'' makes the same parameter/argument bindings as before.
|
||||
: Named parameters are often a feature of languages used in safety critical areas such as [[wp:Verilog|Verilog]] and [[wp:VHDL|VHDL]].
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
100 IF LAST$ = "" THEN PRINT "?";
|
||||
110 IF LAST$ < > "" THEN PRINT LAST$;
|
||||
120 IF FIRST$ < > "" THEN PRINT ", "FIRST$;
|
||||
200 FIRST$ = ""
|
||||
210 LAST$ = ""
|
||||
220 RETURN
|
||||
20
Task/Named-parameters/Bracmat/named-parameters.bracmat
Normal file
20
Task/Named-parameters/Bracmat/named-parameters.bracmat
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
( ( testproc
|
||||
= i x y z
|
||||
. out$"Calling testproc"
|
||||
& (=~):(=?i:?x:?y:?z) { initialise variables to 'failure' }
|
||||
& !arg
|
||||
: (? (i,?i) ?|?) { if "i" found, assign value to i. Otherwise just match with no side effect. }
|
||||
: (? (x,?x) ?|?) { if "x" found, assign value to x. Otherwise just match with no side effect. }
|
||||
: (? (y,?y) ?|?) { likewise }
|
||||
: (? (z,?z) ?|?) { likewise }
|
||||
& (~!i|put$(" i:=" !i)) { if variable doesn't fail, show its value }
|
||||
& (~!x|put$(" x:=" !x))
|
||||
& (~!y|put$(" y:=" !y))
|
||||
& (~!z|put$(" z:=" !z))
|
||||
& put$\n { add new line }
|
||||
)
|
||||
& testproc$((x,1) (y,2) (z,3))
|
||||
& testproc$((x,3) (y,1) (z,2))
|
||||
& testproc$((z,4) (x,2) (y,3)) { order is not important }
|
||||
& testproc$((i,1) (y,2) (z,3))
|
||||
);
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@interface Demo : Object {
|
||||
@interface Demo : NSObject {
|
||||
// Omitted ...
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue