~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to man/programming/overloading.cat

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
overloading         Scilab Group         Scilab keyword         overloading
2
 
NAME
3
 
   overloading - display, functions and operators overloading capabilities
4
 
  
5
 
DESCRIPTION
6
 
   In scilab, variable display, functions and operators may be defined for
7
 
  new objects using  functions (scilab coded or primitives).
8
 
  
9
 
 Display         : The display of new objects defined by tlist structure
10
 
                 may be overloaded (the default display is similar to
11
 
                 list's one). The overloading function must have no output
12
 
                 argument a single input argument. It's name is formed as
13
 
                 follow %<tlist_type>_p where %<tlist_type> stands for the
14
 
                 first entry of the tlist type component.
15
 
                 
16
 
 Operators       : Each operator which is not defined for given operands
17
 
                 type may be defined. The overloading function must have a
18
 
                 single output argument and one or two inputs according to
19
 
                 the number of operands. The function name is formed as
20
 
                 follow:
21
 
                 
22
 
                for binary operators:
23
 
                 %<first_operand_type>_<op_code>_<second_operand_type>
24
 
                 
25
 
                for unary operators: %<operand_type>_<op_code>
26
 
                 
27
 
                extraction and insertion operators which are n-nary
28
 
                 operators are described below.
29
 
                 
30
 
                <operand_type>, <first_operand_type>,
31
 
                 <second_operand_type>  are sequence of characters
32
 
                 associated with each data type as described in the
33
 
                 following table:
34
 
                 
35
 
                |string        |c           |
36
 
                |polynomial    |p           |
37
 
                |function      |m           |
38
 
                |constant      |s           |
39
 
                |list          |l           |
40
 
                |tlist         |<tlist_type>|
41
 
                |boolean       |b           |
42
 
                |sparse        |sp          |
43
 
                |boolean sparse|spb         |
44
 
                
45
 
                 
46
 
                <op_code> is a single character associated with each
47
 
                 operator as described in the following table:
48
 
                 
49
 
                | '            |t|
50
 
                | +            |a|
51
 
                | -            |s|
52
 
                | *            |m|
53
 
                | /            |r|
54
 
                | \            |l|
55
 
                | ^            |p|
56
 
                | .*           |x|
57
 
                | ./           |d|
58
 
                | .\           |q|
59
 
                | .*.          |k|
60
 
                | ./.          |y|
61
 
                | .\.          |z|
62
 
                | :            |b|
63
 
                | *.           |u|
64
 
                | /.           |v|
65
 
                | \.           |w|
66
 
                | [a,b]        |c|
67
 
                | [a;b]        |f|
68
 
                | () extraction|e|
69
 
                | () insertion |i|
70
 
                | ==           |o|
71
 
                | <>           |n|
72
 
                | |            |g|
73
 
                | &            |h|
74
 
                | .^           |j|
75
 
                | ~            |5|
76
 
                | .'           |0|
77
 
                | <            |1|
78
 
                | >            |2|
79
 
                | <=           |3|
80
 
                | >=           |4|
81
 
                
82
 
                 
83
 
                The overloading function for extraction syntax
84
 
                 b=a(i1,...,in) has the following calling sequence:
85
 
                 b=%<type_of_a>_e_(i1,...,in,a)  and the syntax
86
 
                 [x1,..,xm]=a(i1,...,in) has the following calling
87
 
                 sequence:  [x1,..,xm]=%<type_of_a>_e_(i1,...,in,a)
88
 
                 
89
 
                The overloading function associated to the insertion
90
 
                 syntax a(i1,...,in)=b  has the following calling sequence:
91
 
                  a=%<type_of_a>_i_<type_of_b>(i1,...,in,b,a). 
92
 
                 
93
 
 Functions : Some basic primitive function may also be overloaded for new data type. When
94
 
                  such a function is undefined for a particular data types the function
95
 
                 %<type_of_an_argument>_<function_name> is called. User may
96
 
                 add in this called function the definition associated with
97
 
                 the input data types.
98
 
                 
99
 
SEE ALSO
100
 
   tlist, disp, symbols
101
 
  
102
 
EXAMPLES
103
 
 //DISPLAY
104
 
 deff('[]=%tab_p(l)','disp([['' '';l(3)] [l(2);string(l(4))]])')
105
 
 tlist('tab',['a','b'],['x';'y'],rand(2,2))
106
 
 
107
 
 //OPERATOR
108
 
 deff('x=%c_a_s(a,b)','x=a+string(b)')
109
 
 's'+1
110
 
 
111
 
 //FUNCTION
112
 
 deff('x=%c_sin(a)','x=''sin(''+a+'')''')
113
 
 sin('2*x')
114
 
   
115