[OpenSCAD] if statement ignores non boolean values

Giles Bathgate giles.bathgate at gmail.com
Sat Sep 17 19:12:36 CEST 2011


I agree it should either be a warning or cast 1 to true not just treat it as
false along with 0

Regards

Giles
On Sep 17, 2011 5:07 PM, "nop head" <nop.head at gmail.com> wrote:
> If it only handles boolean values it should complain if it gets
> something that is not one or it should convert it to a boolean like
> any other language.
>
> On 17 September 2011 16:49, William Adams <william_a_adams at msn.com> wrote:
>> Why would it complain?  I thought OpenScad has 'true' and 'false', actual
>> boolean values.  In this context, 1 != true.
>>
>> so
>> if (1)
>>   echo(true);
>> else
>>   echo(false);
>>
>> will echo: false
>>
>> That seems like 'correct' behavior, if a bit annoying to classical 'C'
>> programmers.
>>
>> -- William
>>
>> ===============================
>> - Shaping clay is easier than digging it out of the ground.
>>
>>
>> http://internationalwilliam.spaces.msn.com/
>>
>>
>>> Date: Sat, 17 Sep 2011 16:06:35 +0100
>>> From: nop.head at gmail.com
>>> To: openscad at rocklinux.org
>>> Subject: [OpenSCAD] if statement ignores non boolean values
>>>
>>> if(1) { ... } is not treated as true but does not complain either. A
>>> bit confusing as I can't think of another language that would not do
>>> one of the other.
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> OpenSCAD at rocklinux.org
>>> http://rocklinux.net/mailman/listinfo/openscad
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> OpenSCAD at rocklinux.org
>> http://rocklinux.net/mailman/listinfo/openscad
>>
>>
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rocklinux.net/pipermail/openscad/attachments/20110917/ead6191d/attachment.html


More information about the OpenSCAD mailing list