Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a1b2ddb

Browse files
committed
[[ Bug 14993 ]] Updated LCB language reference.
1 parent 84af473 commit a1b2ddb

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

docs/specs/livecode_builder_language_reference.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ By following this convention, there will not be any ambiguity between identifier
6060
6161
# Typing
6262

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).
6464

6565
The range of core types is relatively small, comprising the following:
6666

67-
- **undefined**: the single value *undefined*
67+
- **nothing**: the single value *nothing*
6868
- **Boolean**: one of *true* or *false*
6969
- **Integer**: any integral numeric value (size limitations apply)
7070
- **Real**: any numeric value (size and accuracy limitations apply)
@@ -75,7 +75,7 @@ The range of core types is relatively small, comprising the following:
7575
- **Array**: a mapping from strings to values
7676
- **any**: a value of any type
7777

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.
7979

8080
> **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.
8181
@@ -164,36 +164,36 @@ A type definition defines an alias, it names the given type with the given Name,
164164
: <Name: Identifier>
165165
| 'optional' <Target: Type>
166166
| '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'
177177

178178
A type clause describes the kind of value which can be used in a variable or parameter.
179179

180180
If a type is an identifier, then this is taken to be a named type defined in a type definition clause.
181181

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.
183183

184184
The remaining types are as follows:
185185

186186
- **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).
197197

198198
> **Note:** *integer* and *real* are currently the same as *number*.
199199
@@ -208,18 +208,18 @@ The remaining types are as follows:
208208

209209
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).
210210

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.
212212

213213
## Handlers
214214

215215
HandlerDefinition
216-
: 'handler' <Name: Identifier> '(' [ ParameterList ] ')' [ 'returns' ( <ReturnType: Type> | 'nothing' ) ] SEPARATOR
216+
: 'handler' <Name: Identifier> '(' [ ParameterList ] ')' [ 'returns' <ReturnType: Type> ] SEPARATOR
217217
{ Statement }
218218
'end' 'handler'
219219

220220
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.
221221

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*.
223223

224224
ParameterList
225225
: { Parameter , ',' }
@@ -231,7 +231,7 @@ The parameter list describes the parameters which can be passed to the handler.
231231

232232
An in parameter means that the value from the caller is copied to the parameter variable in the callee handler.
233233

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.
235235

236236
> **Note:** It is a checked runtime error to return from a handler without ensuring all non-optional 'out' parameters have been assigned a value.
237237
@@ -244,15 +244,15 @@ The type of parameter is optional, if no type is specified it is taken to be *op
244244
## Foreign Handlers
245245

246246
ForeignHandlerDefinition
247-
: 'foreign' 'handler' <Name: Identifier> '(' [ ParameterList ] ')' [ 'returns' ( <ReturnType: Type> | 'nothing' ) ] 'binds' 'to' <Binding: String>
247+
: 'foreign' 'handler' <Name: Identifier> '(' [ ParameterList ] ')' [ 'returns' <ReturnType: Type> ) ] 'binds' 'to' <Binding: String>
248248

249249
ForeignType
250250
: Type
251-
| 'bool'
252-
| 'int'
253-
| 'uint'
254-
| 'float'
255-
| 'double'
251+
| 'CBool'
252+
| 'CInt'
253+
| 'CUInt'
254+
| 'CFloat'
255+
| 'CDouble'
256256

257257
A foreign handler definition binds an identifier to a handler defined in foreign code.
258258

@@ -269,21 +269,21 @@ This mapping means that a foreign handler with a bool parameter say, will accept
269269
At present, only C binding is allowed and follow these rules:
270270

271271
- 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
287287

288288
Modes map as follows:
289289

@@ -371,11 +371,11 @@ A variable statement defines a handler-scope variable. Such variables can be use
371371

372372
> **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.
373373
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.
375375

376376
> **Note:** It is a checked runtime error to attempt to use a non-optionally typed variable before it has a value.
377377
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.
379379

380380
## If Statements
381381

@@ -501,7 +501,7 @@ Any parameters of 'inout' type are evaluated on entry, and assigned on exit.
501501
502502
The return value of a handler is subsequently available by using **the result** expression.
503503

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**.
505505
506506
# Expressions
507507

@@ -517,7 +517,7 @@ There are a number of expressions which are built-in and allow constant values,
517517
## Constant Value Expressions
518518

519519
ConstantValueExpression
520-
: 'undefined'
520+
: 'nothing'
521521
| 'true'
522522
| 'false'
523523
| INTEGER
@@ -526,7 +526,7 @@ There are a number of expressions which are built-in and allow constant values,
526526

527527
Constant value expressions evaluate to the specified constant value.
528528

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.
530530

531531
The **true** and **false** expressions evaluate to boolean values.
532532

@@ -574,4 +574,4 @@ A call expression executes a handler.
574574

575575
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**.
576576

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

Comments
 (0)