labs-lang / labs

LAbS: a Language with Attribute-based Stigmergies - Parser + Code generator
BSD 3-Clause "New" or "Revised" License
7 stars 0 forks source link

Multiple initializations for variables #19

Open lou1306 opened 5 years ago

lou1306 commented 5 years ago

The current syntax for initialization is unconvenient for complex cases.

Example

Suppose I want to initialize an attribute x to any value from -10 to 10. That's easy:

interface = x: -10..11  # Remember, ranges in LAbs are Python-style

Now suppose I want to exclude 0 from these values. Currently, the only way is to enumerate all values:

interface = x: [-10, -9, -8, ..., -1, 1, ..., 10]

Proposal

Improve the parser/codegen so that the user can provide multiple, comma-separated initializers (ranges or values). Our example would then become:

interface = x: [-10..0, 1..11]