julia-script / julia-script/silk
syntax: Add range operators .. and ..=
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 0
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 213
Description
Context
Silk has no range value. A user who wants to walk a sequence of numbers writes a
while loop with an index variable. A range operator makes this shorter and gives a
value that a future for statement can use.
Current behavior
The lexer makes a DotDot token (packages/compiler/src/Lexer.ts:74). The parser
consumes that token in one place only: the rest pattern inside a nominal pattern
(packages/compiler/src/Parser.ts:830-831). There is no ..= token.
let mut index = 0
while index < limit {
index = index + 1
}
Requirements
- The lexer must make a token for
..=. - The parser must accept
a .. banda ..= bin expression position. a .. bmust exclude the valueb.a ..= bmust include the valueb.- Both operands must have the same integer type.
- The range must be an ordinary value that a user can pass to a function.
- The parser must keep the rest pattern behavior in pattern position.
Example
pub fn sum(limit: usize) -> usize {
let mut total = usize.add(0, 0)
// The range gives the values 0 to limit minus 1.
let span = 0 .. limit
return total
}
Out of scope
- A
forstatement. That is a separate decision. - Range patterns in a
matcharm. Add those after this ticket lands. - A range over a non-integer type.
Dependencies
None.
Acceptance criteria
- The lexer makes a
..=token. - The parser accepts a range in expression position.
- The parser still accepts
..as the rest pattern in a nominal pattern. - A test shows both forms in the same file.
-
openspec/specs/bootstrap-syntax/spec.md:746-750gets an amendment.
Implementation note
The conflict with the rest pattern is smaller than it looks. The parser consumes
DotDot in exactly one production, inside a nominal pattern field list, and only where
it expects a field. A range in expression position never reaches that production.
Disambiguate by grammatical position. Do not choose a different spelling.
Contributor guide
No contributing guide indexed for this repository
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
Start with the lexer token at packages/compiler/src/Lexer.ts:74 and the expression parser alongside the rest-pattern production at packages/compiler/src/Parser.ts:830-831. Add coverage for both range forms in one file, preserving the nominal-pattern rest behavior, and amend openspec/specs/bootstrap-syntax/spec.md:746-750; done means the stated lexer, parser, integer-type, inclusivity, and ordinary-value requirements are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100