Updated Common Criticisms (markdown)
This commit is contained in:
parent
57d86f1045
commit
c223307877
|
@ -26,9 +26,9 @@ while in Nim they are written like
|
||||||
type
|
type
|
||||||
NodeKind = enum opValue, opAdd, opSub, opMul, opCall
|
NodeKind = enum opValue, opAdd, opSub, opMul, opCall
|
||||||
Node = ref object
|
Node = ref object
|
||||||
case k: NodeKind
|
case kind: NodeKind
|
||||||
of opValue: value: int
|
of opValue: value: int
|
||||||
of opAdd, opSub, opMul, opCall: kids: seq[Node]
|
of opAdd, opSub, opMul, opCall: kids: seq[Node]
|
||||||
```
|
```
|
||||||
|
|
||||||
While the OCaml way looks better, the Nim version allows for multiple types to have the same values, without repetition. It also has the advantage that multiple variants can concisely be matched upon using sets like `{opSub, opMul}`
|
While the OCaml way looks better, the Nim version allows for multiple types to have the same values without repetition. It also has the advantage that multiple variants can concisely be matched upon using sets, eg `node.kind in {opSub, opMul}`.
|
||||||
|
|
Loading…
Reference in New Issue