Delete page 'Initialization'
parent
f76de30db1
commit
ed3be9beb1
@ -1,56 +0,0 @@
|
|||||||
`set` phrases, data sections, and type and function return default values all
|
|
||||||
support value initialization. There are two types of initialization in ARF:
|
|
||||||
simple and complex.
|
|
||||||
|
|
||||||
Simple initialization is just a single argument that is sufficient for setting
|
|
||||||
the value of a simple thing such as an Int. However, objects and arrays require
|
|
||||||
more than that. This is where complex initialization comes in.
|
|
||||||
|
|
||||||
An indented block under a...
|
|
||||||
|
|
||||||
- Data section
|
|
||||||
- Type section
|
|
||||||
- Enum section member
|
|
||||||
- Objt section member
|
|
||||||
- Set phrase
|
|
||||||
- Function ouput declaration
|
|
||||||
|
|
||||||
... is to be treated as a complex initialization. There are two types of complex
|
|
||||||
initialization: object and array. Array initialization is simple, it is just a
|
|
||||||
list of values of the same type. The following array initializations are
|
|
||||||
syntactically and semantically valid:
|
|
||||||
|
|
||||||
```
|
|
||||||
set x:{Int 4}
|
|
||||||
3849 92348 93 -21
|
|
||||||
|
|
||||||
set y:{Int 5}
|
|
||||||
23 2
|
|
||||||
39 695 1
|
|
||||||
|
|
||||||
set z:{Int 5}
|
|
||||||
23
|
|
||||||
2
|
|
||||||
39
|
|
||||||
695
|
|
||||||
1
|
|
||||||
```
|
|
||||||
|
|
||||||
Object initializations allow setting the values for an entire object, including
|
|
||||||
its constituent parts:
|
|
||||||
|
|
||||||
```
|
|
||||||
set x:SomeObject
|
|
||||||
.someMember 5
|
|
||||||
.memberWithMembers
|
|
||||||
.bird0
|
|
||||||
.bird1
|
|
||||||
.arrayMember
|
|
||||||
9853 943850 2093 399
|
|
||||||
394 93
|
|
||||||
```
|
|
||||||
|
|
||||||
The parser is able to differentiate between the two because in an object
|
|
||||||
initialization block, every member is preceded by a dot. Object initialization
|
|
||||||
members may nest - they may have array initializations in them, or even other
|
|
||||||
object initializations.
|
|
Reference in New Issue
Block a user