question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Named parameter pattern matching

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
snoblecommented, May 13, 2019

Maybe you could poll some Galiano retreaters

0reactions
johnynekcommented, Aug 9, 2020

see https://www.python.org/dev/peps/pep-0622/ for how python is thinking about pattern matching.

I think python would do this as:

match x:
  case Foo(bar = b):
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found