On 02.11.19 18:13, Jordan Brown wrote:
Why not only closed intervals? For integer indices, it
seems like the only difference between closed and open
is adding a +1 to the start or -1 to the end. Or are you
concerned that if end is zero and they want open on the
right, they'd end up with -1 and trigger the "measure
from the end" case?
Both actually.
Specifically for the (deprecated) range behavior which
swaps values if the second one is less than the first
value.
v = [];
for (i = [0:len(v) - 1]) {
echo(i = i);
}
// DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.
// ECHO: i = -1
// ECHO: i = 0
You already can get around that using [0:1:len(v) - 1]
though. But [0:<len(v)] does not seem too bad either.
Otherwise it's pretty much simple syntactic sugar, so
it's not super critical to have it. After playing a bit
with this way to specify the range end, I start to like
it. It does give a nice way of reading ranges/slices.
[2:<5] start at index 2 and stop at index less than 5
Maybe always closed on the left and always open on
the right, so if you want different you'd +1 on one
end or the other?
I don't think there's a way to do that without breaking
existing code.
Adding new syntax is ugly...
Why? We should probably try to not add too ugly stuff,
but I don't think it's wrong to add things at all. I'd
like OpenSCAD to stay very simple to get started, just
as it is now. But it needs quite some more features to
really grow up. I suspect not everyone will need those
features but we want to give it into the hands of people
who can build libraries.
ciao,
Torsten.