|
4.16.3 procs with different argument types
- Syntax:
branchTo ( string_expression , ... proc_name )
- Purpose:
- branch to the given procedure if the argument types matches the
types given as strings (which may be empty - matching the empty argument list).
The main procedure (
p in the example) must be defined without an argemnt list, and branchTo statement must be the first statement within
the procedure body.
- Example:
| proc p1(int i) { "int:",i; }
proc p21(string s) { "string:",s; }
proc p22(string s1, string s2) { "two strings:",s1,s2; }
proc p()
{ branchTo("int",p1);
branchTo("string","string",p22);
branchTo("string",p21);
ERROR("not defined for these argument types");
}
p(1);
==> int: 1
p("hu");
==> string: hu
p("ha","ha");
==> two strings: ha ha
p(1,"hu");
==> ? not defined for these argument types
==> ? leaving ::p
|
See
proc.
|