Skip to content
Discussion options

You must be logged in to vote

Both spellings already exist. _ is the wildcard, else is the no-match fallback, and otherwise is a synonym of else. So if you dislike the underscore, write else or otherwise and you get exactly what default would give you. Adding default would be a third spelling of something that is already there twice.

There is a reason _ is not just cosmetic sugar for else. _ is a pattern, not a clause, and it goes where a clause cannot:

match p of
  (0, _): writeln('on Y axis');
  (_, 0): writeln('on X axis');
  'w', 'a', _: writeln('w, a, or anything else');
end;

Inside a tuple pattern _ means "ignore this field", and it can also close a comma-separated pattern list. default has no meaning in either …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@stvowi
Comment options

@stvowi
Comment options

Answer selected by stvowi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants