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

nop head nop.head at gmail.com
Wed May 22 13:34:40 EDT 2019


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20190522/ee6eaebe/attachment.html>


More information about the Discuss mailing list