riff-lang / riff

The Riff programming language
https://riff.cx
BSD Zero Clause License
23 stars 1 forks source link

List comprehensions #66

Open darrylabbate opened 1 year ago

darrylabbate commented 1 year ago

There are any number of ways to design a list comprehension syntax, so not really concerned with those details at the moment. Though I'd want it to be delimited by braces ([]) like many other languages.

The only tricky constraint is to be able to support list comprehensions as well as vanilla "list" literals in the form [0,1,2,...]. Python, as an example, doesn't allow the two syntaxes to coincide in the same literal. That's a reasonable restriction, though it doesn't really help wrt the compiler disambiguating a list comprehension from a vanilla literal. The biggest thing would be a syntax where the "output expression" is the first element (most common style). If the syntax had some other unique token first, it'd be a non-issue.

Ref: