TypeChecking

- Fixed overflow of code in example, formatting to not cross margins
This commit is contained in:
Tristan B. Velloza Kildaire 2023-07-09 14:39:00 +02:00
parent 0b3ed41e5c
commit 3403fd7381
2 changed files with 20 additions and 2 deletions

View File

@ -115,9 +115,15 @@ to bring it to the equal type.
The method by which this is done is:
``` d
typeEnforce(Type toType, Value v2, ref Instruction coercedInstruction, bool allowCoercion = false)
typeEnforce(Type toType,
Value v2,
ref Instruction coercedInstruction,
bool allowCoercion = false)
```
We will discuss exact equality and exact equality through coercion in
the next two sections.
#### Type equality
In order to check strict equality the type enforcer will initially check
@ -137,3 +143,12 @@ making the statement, $type_{i} = typeof(coerce(instr_{i}))$ (which is
the same as $type_{i} = typeof(coerceInstr_{i})$), valid.
TODO: Document this now
Coercion has a set of rules (TODO: docuemnt them) in terms of what can
be coerced. AT the end of the day if the coercion fails then a
`CoercionException` is thrown, if, however it succeeds then a
`CastedValueInstruction` will be placed into the memory location (the
variable) pointed to by the `ref` parameter of
`typeEnforce(..., ..., ref Instruction coercedInstruction, true)`.
TODO: Document the usage of this for variable assignments for example

View File

@ -216,7 +216,10 @@ Enforcement is the procedure of ensuring that a given `Value`-based instruction,
The method by which this is done is:
```d
typeEnforce(Type toType, Value v2, ref Instruction coercedInstruction, bool allowCoercion = false)
typeEnforce(Type toType,
Value v2,
ref Instruction coercedInstruction,
bool allowCoercion = false)
```
We will discuss exact equality and exact equality through coercion in the next two sections.