purescript / documentation

Documentation for the PureScript language, compiler, and tools.
Other
1.03k stars 301 forks source link

Distinguish "anonymous argument" from "wildcards"? #145

Open chexxor opened 6 years ago

chexxor commented 6 years ago

The PS compiler produces an error message named "InvalidAnonymousArgument" when incorrectly using operator section syntax. When reviewing the PR to add docs for this error message, https://github.com/purescript/documentation/pull/144, I had to ask around to learn the difference between "anonymous argument" and "operator sections".

An underscore, _, is used in several different syntax definitions, which can add confusion:

My only question is whether record-related syntax should be called "anonymous argument", or if that is sufficiently different to have its own name, like "record wildcards". I wonder because PS has lots of sugar, like perhaps record syntax is desugared to simple lambdas, which have arguments, so could be called "anonymous argument".

LiamGoodacre commented 6 years ago

(Short comment as I'm on my phone:) I'm not sure 'wildcard' is an appropriate name. There's also (_ + 0).

hdgarrood commented 6 years ago

I think we should use "anonymous argument" to refer to all of case _ of, if _ then _ else _, _.x, {x: _, y: _}, etc: basically anything where a underscore is desugared to a lambda.

hdgarrood commented 6 years ago

Using that definition, it's easy to say what the difference between operator sections and anonymous arguments is, since operator sections are just a specific type of anonymous argument.

chexxor commented 6 years ago

Sounds good. I'll change the scope of this issue to have us add a single place to document anonymous arguments, then. We can link to that doc-section from all syntaxes which support it.