[OpenSCAD] DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

Doug Moen doug at moens.org
Wed May 22 14:10:08 EDT 2019


Many other languages support closed ranges.
In Haskell and Perl, the closed range [0 : -1] returns the empty range.
(Haskell and Perl use a different syntax for ranges than OpenSCAD, but that's not important to the point I'm making.)

On Wed, May 22, 2019, at 1:35 PM, nop head wrote:
> The problem with OpenSCAD ranges is they include the last value, so you can never have a loop that doesn't do any iterations, you have to check for that first. When iterating over the indices of a list you need [0 : len(list) -1] but then if the list is empty you get [0 : -1] which I think warns and then iterates backwards. All other languages I know use half open ranges, so can have zero elements and don't need the -1.
> 
> Using the new C style loops is a work around for that.
> 
> On Wed, 22 May 2019 at 17:41, A. Craig West <acraigwest at gmail.com> wrote:
>> It occurs to me that I haven't checked this since I switched to more recent builds. It was certainly the behavior in the 2015 version, but that is much less relevant now 😊.
>> I shall give this a try. Hopefully thingiverse will start using the new version for their customiser, as that has been the only thing keeping me back on that one... 
>> 
>> On Wed, 22 May 2019, 12:32 Torsten Paul, <Torsten.Paul at gmx.de> wrote:
>>> On 22.05.19 15:15, A. Craig West wrote:
>>>  > len(v) == 0 ? [] :
>>>  > [ for (o = v)...] 
>>> 
>>>  This has nothing to do with ranges as far as I can see. Can
>>>  you elaborate on why that is needed? If there's a bug then
>>>  it can only be fixed if it's reported.
>>> 
>>>  v = [];
>>>  echo([for (a = v) a]);
>>> 
>>>  Works fine and reports an empty list which is what I would
>>>  expect. So in which case is that len() needed?
>>> 
>>>  ciao,
>>>  Torsten.
>>> 
>>>  _______________________________________________
>>>  OpenSCAD mailing list
>>> Discuss at lists.openscad.org
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>> _______________________________________________
>>  OpenSCAD mailing list
>> Discuss at lists.openscad.org
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> _______________________________________________
> OpenSCAD mailing list
> Discuss at lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190522/2c2e8ea6/attachment.html>


More information about the Discuss mailing list