File: optional.tcl

package info (click to toggle)
critcl 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,680 kB
  • sloc: ansic: 41,058; tcl: 12,090; sh: 7,230; pascal: 3,456; asm: 3,058; ada: 1,681; cpp: 1,001; cs: 879; makefile: 333; perl: 104; xml: 95; f90: 10
file content (54 lines) | stat: -rw-r--r-- 1,403 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# optional.tcl --
#
#	A template demonstrating the handling of optional arguments to cproc.
#
# Copyright (c) 2012,2022 Andreas Kupries <andreas_kupries@users.sourceforge.net>

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.6 9
package require critcl 3.2

# # ## ### ##### ######## ############# #####################
## Administrivia

critcl::license {Andreas Kupries} BSD

critcl::summary {Optional arguments for cproc}

critcl::description {
    This package implements nothing. It serves only as a
    demonstration and template on how to declare cproc's
    with optional arguments.
}

critcl::subject demonstration {cproc optional arguments}
#critcl::config lines 0

# # ## ### ##### ######## ############# #####################
## C code.

critcl::cproc fixed {int a int b int c int d} void {
    printf ("F|%d|%d|%d|%d|\n", a,b,c,d);
    fflush(stdout);
}

critcl::cproc optional_head {int {a 1} int {b 2} int c int d} void {
    printf ("H|%d|%d|%d|%d|\n", a,b,c,d);
    fflush(stdout);
}

critcl::cproc optional_tail {int a int b int {c 1} int {d 2}} void {
    printf ("T|%d|%d|%d|%d|\n", a,b,c,d);
    fflush(stdout);
}

critcl::cproc optional_middle {int a int {b 1} int {c 2} int d} void {
    printf ("M|%d|%d|%d|%d|\n", a,b,c,d);
    fflush(stdout);
}

# ### ### ### ######### ######### #########
## Ready
package provide optional 1