comprehension syntax should respect the local variables defined in if clause
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 49.1k
- Forks
- 6k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 209
Description
It will be nice if comprehension syntax respects the local variables defined in if clause.
For example, filter_map of Ruby 2.7 or Rust will be implemented as follows
filter_map(f, a) = (y for x in a if (y=f(x)) !== nothing)
Python 3.8 will introduce the assignment expressions which makes this possible.
https://docs.python.org/3.8/whatsnew/3.8.html
https://www.python.org/dev/peps/pep-0572/#simplifying-list-comprehensions
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the comprehension example in the issue and compare its intended behavior with Julia's current local-variable scoping rules. No source file or test is named, so first locate the comprehension parser and relevant scope tests. Done means the shown filter_map pattern can bind y in the if clause and use it as the comprehension result without changing unrelated scoping behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100