Open chexxor opened 6 years ago
(Short comment as I'm on my phone:) I'm not sure 'wildcard' is an appropriate name. There's also (_ + 0)
.
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.
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.
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.
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:main :: _
)\_ ->
)case _ of
,if _ then
)_.x
,{x: _, y: _}
,rec { x = _ }
)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".