focus expression text field at startup -> version 1.2
[LeanCalc.git] / help / dereference
1 NAME
2     * - dereference or indirection operator
3
4 SYNOPSIS
5     * X
6
7 TYPES
8     X           address or lvalue
9
10     return      any
11
12 DESCRIPTION
13     When used as a binary operator, '*' performs multiplication.  When
14     used as a operator, '*' returns the value at a given address.
15
16     If X is an address, *X returns the value at that address.  This value
17     will be an octet, lvalue, string, or number, depending on the
18     type of address.  Thus, for any addressable A, *&A is the same as A.
19
20     If X is an lvalue, *X returns the current value at the address
21     considered to be specified by X.  This value may be an lvalue or
22     octet, in which cases, for most operations except when X is the
23     destination of an assignment, *X will contribute the same as X to
24     the result of the operation. For example, if A and B are lvalues
25     whose current values are numbers, A + B, *A + B, A + *B and *A + *B
26     will all return the same result.  However if C is an lvalue and A is
27     the result of the assignment A = &C, then A = B will assign the value
28     of B to A, *A = B will assign the value of B to C without affecting
29     the value of A.
30
31     If X is an lvalue whose current value is a structure (matrix, object,
32     list, or association), the value returned by *X is a copy of the
33     structure rather than the structure identified by X.  For example,
34     suppose B has been created by
35
36                         mat B[3] = {1,2,3}
37
38     then
39                         A = *B = {4,5,6}
40
41     will assign the values 4,5,6 to the elements of a copy of B, which
42     will then become the value of A, so that the values of A and B will
43     be different.  On the other hand,
44
45                         A = B = {4,5,6}
46
47     will result in A and B having the same value.
48
49     If X is an octet, *X returns the value of that octet as a number.
50
51     The * operator may be iterated with suitable sequences of pointer-valued
52     lvalues.  For example, after
53
54                         > global a, b, c;
55                         > b = &a;
56                         > c = &b;
57
58     **c returns the lvalue a;  ***c returns the value of a.
59
60 EXAMPLE
61     > mat A[3] = {1,2,3}
62     > p = &A[0]
63     > print *p, *(p + 1), *(p + 2)
64     1 2 3
65
66     > *(p + 1) = 4
67     > print A[1]
68     4
69
70     > A[0] = &a
71     > a = 7
72     > print **p
73     7
74
75 LIMITS
76     none
77
78 LINK LIBRARY
79     none
80
81 SEE ALSO
82     address, isptr
83