Named parameter pattern matching
See original GitHub issueI think you’ve mentioned this before but I couldn’t find an issue. I think there’s enough pattern matching that this would eliminate the need for accessors. And it’s pretty easy to translate these into position based pattern matches
Syntax could be:
struct File(name: String, modified_time: Int, size: Int, hash: HashResult)
File(hsh@hash) = file
def time_plus_size(File(mt@modified_time, sze@size)):
mt + sze
Alternatives to @ could be = or <- or ~
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Pattern matching with named fields - Scala Contributors
When matching is done on a case class with a few field it works fine. One can use underscore to express 'match all'...
Read more >haskell - pattern matching and named argument in one
In haskell I can receive argument using pattern matching, which give me easy access to basic elements, but is more complicated to join...
Read more >Allow named and default arguments in pattern matching #6524
Cutting boiler plate in pattern match cases and make them more readable. A problem I can see is where arguments are omitted but...
Read more >Named parameters - Rosetta Code
Create a function which takes in a number of arguments which are specified by name rather than (necessarily) position, and show how to...
Read more >Pattern matching in parameters - SideFX
You can use string patterns anywhere an expression function needs a name (such as a parameter or node name) to match multiple things...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe you could poll some Galiano retreaters
see https://www.python.org/dev/peps/pep-0622/ for how python is thinking about pattern matching.
I think python would do this as: