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.

Add keyword for alternatives in a match construct

See original GitHub issue

edit @pokey:

As discussed in https://github.com/cursorless-dev/cursorless/issues/579#issuecomment-1161627378, we’d like to proceed as follows:

Original

There currently is no keyword for selecting alternatives in a match construct. Examples of match constructs are:

  • Python
    match x:
    case Alt1: exp1
    …
    case AltN: expN
    
  • Haskell
    f = case x of
      Alt1 -> exp1
      …
      AltN -> expN
    
    or
    f Alt1 = exp1
    …
    f AltN = expN
    

We probably want three keywords:

  • matched to select the value matched on, i.e., x;
  • <ordinal> pattern to select the i’th pattern, i.e., Alt1 to AltN above; and
  • <ordinal> case to select the i’th case, i.e., exp1 to expN above.

Unmodified pattern and case should probably to the scopes relative to the named mark or cursor, i.e., pattern refers to Alt1 if the mark or cursor is in either Alt1 or exp1, and similarly for case.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
purplePcommented, Jun 21, 2022

@pokey I like your proposal.

0reactions
pokeycommented, Jun 21, 2022

Ok I’ve edited my comment above with some new terms after a discussion with @AndreasArvidsson and @phillco. Tl;dr:

  • "case" became "branch"
  • "condition" became "subject" or not supported
  • "name" added synonyms "key" and "condition"

See the updated comment for discussion

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change keyword match types - Google Ads Editor Help
Select and edit specific keywords · Select Keywords. · Select the keywords to edit. · In the edit panel, select a new Match...
Read more >
Python Match-Case Statement: Example & Alternatives - Udacity
In this article, we'll explain what a switch statement is in programming. Next, we'll show you how to use the match-case statement with ......
Read more >
Keyword Match Types in Google Ads [Ultimate Guide] - Blog
Go to the Keyword section. In the Match type column, click on the arrow icon and set the match type.
Read more >
What Is Phrase Match in Google Ads? - WordStream
Phrase match is a keyword match type option offered by Google Ads, formerly known as Google AdWords. In this tutorial, you'll learn: How...
Read more >
PEP 622 – Structural Pattern Matching
This PEP proposes to add a pattern matching statement to Python, inspired by similar syntax found ... Pattern, a new syntactic construct, and...
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