forked from metaborg/pie
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make _ an anonymous value #277
Labels
Component: DSL
Something that concerns the design of PIE DSL
Priority: high
status: PR merged
Type: enhancement
New feature or request
Comments
MeAmAnUsername
added
Type: enhancement
New feature or request
Status: specified
Enhancement that is ready to implement
Component: DSL
Something that concerns the design of PIE DSL
Priority: low
Priority: medium
Priority: high
and removed
Priority: low
Priority: medium
labels
Mar 25, 2022
Increase priority because this is a breaking change, so it should be done before people actually use the PIE DSL. |
MeAmAnUsername
added a commit
that referenced
this issue
Mar 28, 2022
Notes for implementation:
|
Distinguish during parsing:
cons:
|
Turns out it should be VALID instead of TYPEID |
MeAmAnUsername
added
Status: in progress
and removed
Status: specified
Enhancement that is ready to implement
labels
Apr 16, 2022
MeAmAnUsername
added
Status: PR open
status: PR merged
and removed
Status: implemented
Status: PR open
labels
Jun 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Component: DSL
Something that concerns the design of PIE DSL
Priority: high
status: PR merged
Type: enhancement
New feature or request
Summary
Make
_
an anonymous valueTodo
_
as parameter nameReason
Useful when destructuring a tuple and you don't need every value:
val (_, result) = analyze(parse(file))
Description
Make it so
_
is always a fresh variable, i.e. it cannot be referred to, but multiple variables named_
can be used.If
_
is used in a reference, it should give an error: "Cannot refer to anonymous value_
. Use a named value instead."If
_
is used as parameter name in a foreign function (including methods and foreign tasks) for a qualified type (e.g._: mb:common:result:Result
), it is simply allowed. This is required because that is the only way to refer to a qualified value.If
_
is used as parameter name in a foreign function (including methods and foreign tasks) for an unqualified type (e.g._: int
or_: Result
), it should emit a warning: "Anonymous parameter name can be omitted. Alternatively, the parameter can have a proper name."If
_
is used as parameter name for a PIE function, it should give a note for now, at least until #16 is implemented.Note: "Anonymous parameter
_
cannot be referred to but will be included in the generated task signature. If this is not required, this parameter can be removed. If this is intended, it is recommended to add a comment explaining why this is necessary. To refer to this parameter, use a different name."Implementation
Exp.ValDec
to have a special case for anonymous values (no longer justTYPEID
but eitherTYPEID
or another valueTYPEID = "_" {reject}
Ref.AnonRef = [_]
which gives an error.Code generation: just generate a fresh variable for every declaration of an anonymous value. Use
unused
oranonymous
for base name. Even better: do not assign to variable at all if not required (only case where it is required is for paramaters I guess)Search terms
Underscore
Related issues
None
The text was updated successfully, but these errors were encountered: