cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Add `"subject"` scope type

Open pokey opened this issue 2 years ago • 8 comments

  • [ ] We'll begin by introducing the scope type extension side
  • [ ] Then when we support amalgamating more granular scope types, we'll figure out how we want to roll this one up

For original discussion, see https://github.com/cursorless-dev/cursorless/issues/579#issuecomment-1161627378 for more

image

pokey avatar Dec 14 '22 14:12 pokey

As I mention in #2177, "subject" is a generalisation of "condition".

wenkokke avatar Jan 17 '24 12:01 wenkokke

huh that's kind of interesting. had never seen your if-else / switch equivalence before. repeated here for convenience

def ifThenElse(cond, ifTrue, ifFalse):
  match cond:
#       ^^^^  <-- "condition"
    case True:
#        ^^^^  <-- "pattern"
      return ifTrue()
    case False:
#        ^^^^^  <-- "pattern"
      return ifFalse()

I think I could be convinced that condition should be what's inside the parens. It visually feels like condition as well because of where it appears in the statement (at the top inside parens), which practically speaking is what matters the most 😄🦎🧠. cc/ @AndreasArvidsson

pokey avatar Jan 18 '24 15:01 pokey

Inside the parens? Are you talking about the arguments to the function? Could you elaborate?

AndreasArvidsson avatar Jan 18 '24 16:01 AndreasArvidsson

It should be the argument to match, right? The name in the parens is the function argument.

wenkokke avatar Jan 18 '24 17:01 wenkokke

Letting "condition" refer to today's "subject". But not totally convinced

pokey avatar Jan 18 '24 21:01 pokey

I was never a fan of subject and would be fine with just using condition there as well.

AndreasArvidsson avatar Jan 18 '24 23:01 AndreasArvidsson

Wait, was subject actually implemented?

wenkokke avatar Jan 19 '24 13:01 wenkokke

Yes but as a private scope

subject, private.switchStatementSubject

https://github.com/cursorless-dev/cursorless/pull/1148

AndreasArvidsson avatar Jan 19 '24 13:01 AndreasArvidsson