You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: docs/specs/livecode_builder_language_reference.md
+55-55Lines changed: 55 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,11 +60,11 @@ By following this convention, there will not be any ambiguity between identifier
60
60
61
61
# Typing
62
62
63
-
Modular LiveCode is a typed language, although typing is completely optional in most places (the only exception being in foreign handler declarations). If a type annotation is not specified it is simply taken to be the most general type *optional any* (meaning any value, including undefined).
63
+
Modular LiveCode is a typed language, although typing is completely optional in most places (the only exception being in foreign handler declarations). If a type annotation is not specified it is simply taken to be the most general type *optional any* (meaning any value, including nothing).
64
64
65
65
The range of core types is relatively small, comprising the following:
66
66
67
-
-**undefined**: the single value *undefined*
67
+
-**nothing**: the single value *nothing*
68
68
-**Boolean**: one of *true* or *false*
69
69
-**Integer**: any integral numeric value (size limitations apply)
70
70
-**Real**: any numeric value (size and accuracy limitations apply)
@@ -75,7 +75,7 @@ The range of core types is relatively small, comprising the following:
75
75
-**Array**: a mapping from strings to values
76
76
-**any**: a value of any type
77
77
78
-
Additionally, all types can be annotated with **optional**. An optional annotation means the value may be the original type or the undefined value.
78
+
Additionally, all types can be annotated with **optional**. An optional annotation means the value may be the original type or nothing.
79
79
80
80
> **Note:** The current compiler does not do type-checking; all type-checking happens at runtime. However, this is being worked on so there will soon be a compiler which will give you type errors at compile-time.
81
81
@@ -164,36 +164,36 @@ A type definition defines an alias, it names the given type with the given Name,
164
164
: <Name: Identifier>
165
165
| 'optional' <Target: Type>
166
166
| 'any'
167
-
| 'boolean'
168
-
| 'integer'
169
-
| 'real'
170
-
| 'number'
171
-
| 'string'
172
-
| 'data'
173
-
| 'array'
174
-
| 'list'
175
-
| 'undefined'
176
-
| 'pointer'
167
+
| 'nothing'
168
+
| 'Boolean'
169
+
| 'Integer'
170
+
| 'Real'
171
+
| 'Number'
172
+
| 'String'
173
+
| 'Data'
174
+
| 'Array'
175
+
| 'List'
176
+
| 'Pointer'
177
177
178
178
A type clause describes the kind of value which can be used in a variable or parameter.
179
179
180
180
If a type is an identifier, then this is taken to be a named type defined in a type definition clause.
181
181
182
-
An optional type means the value can be either the specified type or undefined.
182
+
An optional type means the value can be either the specified type or nothing. Variables which are of optional type are automatically initial zed to nothing.
183
183
184
184
The remaining types are as follows:
185
185
186
186
-**any**: any value
187
-
-**boolean**: a boolean value, either the value *true* or *false*.
188
-
-**integer**: any integer number value
189
-
-**real**: any real number value
190
-
-**number**: any number value
191
-
-**string**: a sequence of UTF-16 code units
192
-
-**data**: a sequence of bytes
193
-
-**array**: a map from string to any value (i.e. an associative array, just like in LiveCode Script)
194
-
-**list**: a sequence of any value
195
-
-**undefined**: a single value *undefined* (this is used to describe handlers with no return value - i.e. void)
196
-
-**pointer**: a low-level pointer (this is used with foreign code interconnect and shouldn't be generally used).
187
+
-**Boolean**: a boolean value, either the value *true* or *false*.
188
+
-**Integer**: any integer number value
189
+
-**Real**: any real number value
190
+
-**Number**: any number value
191
+
-**String**: a sequence of UTF-16 code units
192
+
-**Data**: a sequence of bytes
193
+
-**Array**: a map from string to any value (i.e. an associative array, just like in LiveCode Script)
194
+
-**List**: a sequence of any value
195
+
-**nothing**: a single value *nothing* (this is used to describe handlers with no return value - i.e. void)
196
+
-**Pointer**: a low-level pointer (this is used with foreign code interconnect and shouldn't be generally used).
197
197
198
198
> **Note:***integer* and *real* are currently the same as *number*.
199
199
@@ -208,18 +208,18 @@ The remaining types are as follows:
208
208
209
209
A variable definition defines a module-scope variable. In a widget module, such variables are per-widget (i.e. instance variables). In a library module, there is only a single instance (i.e. a private global variable).
210
210
211
-
The type specification for the variable is optional, if it is not specified the type of the variable is *optional any* meaning that it can hold any value, including being undefined.
211
+
The type specification for the variable is optional, if it is not specified the type of the variable is *optional any* meaning that it can hold any value, including being nothing.
Handler definitions are used to define functions which can be called from LiveCode Builder code, invoked as a result of events triggering in a widget module, or called from LiveCode Script if public and inside a library module.
221
221
222
-
There is no distinction between handlers which return a value and ones which do not, apart from the return type. Handlers can be called either in expression context, or in statement context. If a handler which returns no value (it is specified as *returns nothing*) is called in expression context then its value is *undefined*.
222
+
There is no distinction between handlers which return a value and ones which do not, apart from the return type. Handlers can be called either in expression context, or in statement context. If a handler which returns no value (it is specified as *returns nothing*) is called in expression context then its value is *nothing*.
223
223
224
224
ParameterList
225
225
: { Parameter , ',' }
@@ -231,7 +231,7 @@ The parameter list describes the parameters which can be passed to the handler.
231
231
232
232
An in parameter means that the value from the caller is copied to the parameter variable in the callee handler.
233
233
234
-
An out parameter means that no value is copied from the caller (the parameter variable in the callee handler starts as *undefined*), and the value on exit of the callee handler is copied back to the caller on return.
234
+
An out parameter means that no value is copied from the caller, and the value on exit of the callee handler is copied back to the caller on return.
235
235
236
236
> **Note:** It is a checked runtime error to return from a handler without ensuring all non-optional 'out' parameters have been assigned a value.
237
237
@@ -244,15 +244,15 @@ The type of parameter is optional, if no type is specified it is taken to be *op
A foreign handler definition binds an identifier to a handler defined in foreign code.
258
258
@@ -269,21 +269,21 @@ This mapping means that a foreign handler with a bool parameter say, will accept
269
269
At present, only C binding is allowed and follow these rules:
270
270
271
271
- any type passes an MCValueRef
272
-
-boolean type passes an MCBooleanRef
273
-
-integer type passes an MCNumberRef
274
-
-real type passes an MCNumberRef
275
-
-number type passes an MCNumberRef
276
-
-string type passes an MCStringRef
277
-
-data type passes an MCDataRef
278
-
-array type passes an MCArrayRef
279
-
-list type passes an MCProperListRef
280
-
-undefined type passes an MCNullRef
281
-
-pointer type passes a void *
282
-
-bool type passes a bool (i.e. an int - pre-C99).
283
-
-int type passes an int
284
-
-uint type passes an unsigned int
285
-
-float type passes a float
286
-
-double type passes a double
272
+
-nothing type passes as the null pointer
273
+
-Boolean type passes an MCBooleanRef
274
+
-Integer type passes an MCNumberRef
275
+
-Real type passes an MCNumberRef
276
+
-Number type passes an MCNumberRef
277
+
-String type passes an MCStringRef
278
+
-Data type passes an MCDataRef
279
+
-Array type passes an MCArrayRef
280
+
-List type passes an MCProperListRef
281
+
-Pointer type passes a void *
282
+
-CBool type passes a bool (i.e. an int - pre-C99).
283
+
-CInt type passes an int
284
+
-CUInt type passes an unsigned int
285
+
-CFloat type passes a float
286
+
-CDouble type passes a double
287
287
288
288
Modes map as follows:
289
289
@@ -371,11 +371,11 @@ A variable statement defines a handler-scope variable. Such variables can be use
371
371
372
372
> **Note:** Variables are currently not block-scoped, they are defined from the point of declaration to the end of the handler - this might change in a subsequent revision.
373
373
374
-
Variables are initially undefined, and if of non-optional type, must be assigned a value before they can be used.
374
+
Variables are initially undefined and thus cannot be fetched without a runtime error occurring until a value is placed into them. If a variable has been annotated with an optional type, its initial value will be nothing.
375
375
376
376
> **Note:** It is a checked runtime error to attempt to use a non-optionally typed variable before it has a value.
377
377
378
-
The type specification for the variable is optional, if it is not specified the type of the variable is *optional any* meaning that it can hold any value, including being undefined.
378
+
The type specification for the variable is optional, if it is not specified the type of the variable is *optional any* meaning that it can hold any value, including being nothing.
379
379
380
380
## If Statements
381
381
@@ -501,7 +501,7 @@ Any parameters of 'inout' type are evaluated on entry, and assigned on exit.
501
501
502
502
The return value of a handler is subsequently available by using **the result** expression.
503
503
504
-
> **Note:** All handlers return a value, even if it is undefined. This means that calling a handler will always change **the result**.
504
+
> **Note:** All handlers return a value, even if it is nothing. This means that calling a handler will always change **the result**.
505
505
506
506
# Expressions
507
507
@@ -517,7 +517,7 @@ There are a number of expressions which are built-in and allow constant values,
517
517
## Constant Value Expressions
518
518
519
519
ConstantValueExpression
520
-
: 'undefined'
520
+
: 'nothing'
521
521
| 'true'
522
522
| 'false'
523
523
| INTEGER
@@ -526,7 +526,7 @@ There are a number of expressions which are built-in and allow constant values,
526
526
527
527
Constant value expressions evaluate to the specified constant value.
528
528
529
-
The **undefined** expression evaluates to the undefined value and can be assigned to any optional typed variable.
529
+
The **nothing** expression evaluates to the nothing value and can be assigned to any optional typed variable.
530
530
531
531
The **true** and **false** expressions evaluate to boolean values.
532
532
@@ -574,4 +574,4 @@ A call expression executes a handler.
574
574
575
575
Its use is identical to a call statement, except that the return value of the handler is the value of the expression, rather than being available as **the result**.
576
576
577
-
> **Note:** Handlers which return no value (i.e. have undefined as their result type) can still be used in call expressions. In this case the value of the call is **undefined**.
577
+
> **Note:** Handlers which return no value (i.e. have nothing as their result type) can still be used in call expressions. In this case the value of the call is **nothing**.
0 commit comments