Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (for_expression) to locals.scm #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rwjblue
Copy link

@rwjblue rwjblue commented Sep 7, 2023

This change does two main things:

  1. Indicate that (for_expression)'s introduce a @local.scope (this is the scope for the enumerators to be used within the loop).
  2. Indicate that the (identifiers) within the (enumerators) are @local.definitions.

For the following example snippet:

val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}

The count and fruits identifiers are new definitions introduced by the for expressions scope.

This change does two main things:

1. Indicate that `(for_expression)`'s introduce a `@local.scope` (this
   is the scope for the enumerators to be used within the loop).
2. Indicate that the `(identifiers)` within the `(enumerators)` are
   `@local.definition`s.

---

For the following example snippet:

```scala
val fruits = List("apple", "banana", "avocado", "papaya")

val countsToFruits = fruits.groupBy(fruit => fruit.count(_ == 'a'))

for ((count, fruits) <- countsToFruits) {
  println(s"with (fruits) 'a' × $count = $fruits")
}
```

The `count` and `fruits` identifiers are new definitions introduced by
the `for` expressions scope.
Copy link
Collaborator

@ckipp01 ckipp01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rwjblue, same comment as the other PR. Would you be willing to add in some tests in the highlight queries showing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants