Function defs should allow patterns in arguments

Bug #439164 reported by Matt Giuca
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mars
Triaged
Low
Matt Giuca

Bug Description

A function definition should allow an argument to be named "_" (currently a syntax error), which indicates that the argument is unused (it is not bound to any variable name). Multiple arguments should be allowed to be called "_". This is consistent with switch notation in Mars, as well as other languages like Haskell and Prolog.

Tags: feature
Matt Giuca (mgiuca)
Changed in mars:
milestone: none → 0.3
Revision history for this message
Matt Giuca (mgiuca) wrote :

Solve this by implementing full pattern bindings in arguments, as for assignments (see bug #513633). Don't go so far as having multiple clauses.

Revision history for this message
Matt Giuca (mgiuca) wrote :

I committed a fix to bug #513633 (assignment statements can have patterns) but didn't go as far as to allow it in function definitions as well. Therefore, de-duplicating this bug, renaming, and milestoning. Now just apply the assignment patterns feature to function arguments.

One tricky thing is that for the purpose of representing the functions in our IR, we do need a canonical name for each argument. We shall have to generate one for any parameter that uses a non-variable pattern.

summary: - Function defs should allow "_" for an unused argument
+ Function defs should allow patterns in arguments
Changed in mars:
milestone: 0.3 → 0.4
Matt Giuca (mgiuca)
Changed in mars:
milestone: 1.0 → 1.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.