[OpenSCAD] if statement ignores non boolean values

Brad Pitcher bradpitcher at gmail.com
Tue Sep 27 20:22:35 CEST 2011


I agree, all non-empty strings should evaluate to true.


On Tue, Sep 27, 2011 at 11:13 AM, Christian Siefkes
<christian at siefkes.net>wrote:

> On 09/27/2011 07:59 PM, Marius Kintel wrote:
> > This was implemented in commit 6659ad47b0b07b66b62ca79f3929d361733cc67a
> in the visitor branch.
> >>From the release notes:
> >
> > "if() and else() can now take any value type as parameter. false, 0,
> empty string and empty vector or illegal value type will evaluate as false,
> everything else as true."
> >
> > My implementation corresponds to that of Brad, except mine considers any
> string with length > 0 as true.
> >
> > I'm uncertain about whether the string "0" should be considered false or
> not. If we make it false, what about the string "false", or the array [0]
> (thinking about strings as arrays of characters)?
>
> Or what about the string "0.0", or " 0 ", or "00"? I think it makes more
> sense to consider ALL non-empty strings as true (and only the empty string
> as false), everything else opens a can of worms...
>
> Best regards
>        Christian
>
> --
> |------- Dr. Christian Siefkes ------- christian at siefkes.net -------
> | Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/
> |    Peer Production Everywhere:       http://peerconomy.org/wiki/
> |---------------------------------- OpenPGP Key ID: 0x346452D8 --
> Sent from my toaster.
>
>
> _______________________________________________
> 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/20110927/c3974727/attachment-0001.html


More information about the OpenSCAD mailing list