foo = bar{2}
# expands into
foo = bar bar
foo = bar{2,4}
# expands into
foo = bar bar bar? bar?
# this one isn't part of POSIX, but it's a fairly obvious extension
foo = bar{,3}
# expands into
foo = bar? bar? bar?
Further, suffixing the upper bound with = prevents more instances of bar from existing:
This might be worth making the default? I'm not sure. It shouldn't be usable without the prefixed comma, since that sends conflicting messages about whether the number is a lower or upper bound.
Some-of operators
I have no idea what this syntax should look like. This is just what first came to mind.
There isn't much of a point to a lower bound of 0, as that would be equivalent to chaining ?, but it might as well be allowed anyway for simplicity. Note that reordering the parts isn't permitted here; it would be preferable to allow that, but the resulting implicit alternatives would be confusing:
foo = ~(bar baz bluh){2}
# could expand into
foo = (bar baz) / (bar bluh) / (baz bar) / (baz bluh) / (bluh bar) / (bluh baz)
# but what does that parse things as? we just don't know
# (it's still well-defined, of course, just weird)
If we introduce syntax to do this, then a lower bound of 0 does become meaningful. And, again, = is possible:
Range operators
StolenAdapted from POSIX regexes:Further, suffixing the upper bound with
=
prevents more instances ofbar
from existing:This might be worth making the default? I'm not sure. It shouldn't be usable without the prefixed comma, since that sends conflicting messages about whether the number is a lower or upper bound.
Some-of operators
I have no idea what this syntax should look like. This is just what first came to mind.
There isn't much of a point to a lower bound of 0, as that would be equivalent to chaining
?
, but it might as well be allowed anyway for simplicity. Note that reordering the parts isn't permitted here; it would be preferable to allow that, but the resulting implicit alternatives would be confusing:If we introduce syntax to do this, then a lower bound of 0 does become meaningful. And, again,
=
is possible: