File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -3396,12 +3396,21 @@ alt x @{
3396
3396
cons(10, _) @{
3397
3397
process_ten();
3398
3398
@}
3399
+ nil. @{
3400
+ ret;
3401
+ @}
3399
3402
_ @{
3400
3403
fail;
3401
3404
@}
3402
3405
@}
3403
3406
@end example
3404
3407
3408
+ Note in the above example that @code {nil } is followed by a period. This is
3409
+ required syntax for pattern matching a nullary tag variant, to distingush the
3410
+ variant @code {nil } from a binding to variable @code {nil }. Without the period
3411
+ the value of @code {x } would be bound to variable @code {nil } and the compiler
3412
+ would issue an error about the final wildcard case being unreachable.
3413
+
3405
3414
Multiple alternative patterns may be joined with the @code {| } operator. A
3406
3415
range of values may be specified with @code {to }. For example:
3407
3416
You can’t perform that action at this time.
0 commit comments