discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

treatment of syntax errors in OpenSCAD

PF
Peter Falke
Mon, Mar 16, 2015 9:44 PM

I'm very much worried by the way OpenSCAD  treats what I call syntax errors:

square([2,3,]); //works like square([2,3]);

translate(1)circle();// translate() fails silently

square([10,10,10]); // fails silently

To remedy this I would like to initiate a discussion of what should be the
expected behavior, what should lead to an error, and what should lead to a
warning.

To facilitate this discussion, I wrote a small program that, as a test
case, lists all  possible values a variable could take on.

It than calls the module print_boolean() for all values which echos their
value and its Boolean value.

This program could then be used as a template for testing other calls (e.g.
sphere(value);).

Please have a look at it: Are there any other values that would be
important to include as test cases?


// -----------------------------------------------------------------------

//

// syntax_boolean_v0

//

// List all possible values of vaiables to later

// use them as a template to define and test the syntax

// of (internal) module calls.

// This is shown here for the boolean value, as an example.

//

// GPLv2

// (c) 2015 TakeItAndRun

//

// -----------------------------------------------------------------------

// variables

var_true=true;

var_false=false;

var_zero=0;

var_number=3;

var_negnumber=-3;

var_small=0.494066e-323;

var_large=1.7976931348623158080999999e+308*1;

var_undef=true*true;

var_inf=1/0;

var_char="a";

var_string="TEXT";

var_emptystring="";

// 2 dim-vectors

vec2_true=vec2(var_true);

vec2_false=vec2(var_false);

vec2_zero=vec2(var_zero);

vec2_number=vec2(var_number);

vec2_negnumber=vec2(var_negnumber);

vec2_small=vec2(var_small);

vec2_large=vec2(var_large);

vec2_undef=vec2(var_undef);

vec2_inf=vec2(var_inf);

vec2_char=vec2(var_char);

vec2_string=vec2(var_string);

vec2_emptystring=vec2(var_emptystring);

// 3 dim-vectors

vec3_true=vec3(var_true);

vec3_false=vec3(var_false);

vec3_zero=vec3(var_zero);

vec3_number=vec3(var_number);

vec3_negnumber=vec3(var_negnumber);

vec3_small=vec3(var_small);

vec3_large=vec3(var_large);

vec3_undef=vec3(var_undef);

vec3_inf=vec3(var_inf);

vec3_char=vec3(var_char);

vec3_string=vec3(var_string);

vec3_emptystring=vec3(var_emptystring);

// generate vectors from variables

function vec2(var)=[var,var];

function vec3(var)=[var,var,var];

// print the value and the boolean value of it

module print_boolean(var){

echo(var,var?true:false);

}

// var

print_boolean(var_true);

print_boolean(var_false);

print_boolean(var_zero);

print_boolean(var_number);

print_boolean(var_negnumber);

print_boolean(var_small);

print_boolean(var_large);

print_boolean(var_undef);

print_boolean(var_inf);

print_boolean(var_char);

print_boolean(var_string);

print_boolean(var_emptystring);

// echo -->> The boolean value of false, zero, undef, and empty string
gives false, everything else gives true

// 2-dim vector

print_boolean(vec2_true);

print_boolean(vec2_false);

print_boolean(vec2_zero);

print_boolean(vec2_number);

print_boolean(vec2_negnumber);

print_boolean(vec2_small);

print_boolean(vec2_large);

print_boolean(vec2_undef);

print_boolean(vec2_inf);

print_boolean(vec2_char);

print_boolean(vec2_string);

print_boolean(vec2_emptystring);

// echo -->> The boolean value of any (!) 2-dim vector is always true
regardeless of its value

// 3-dim vector

print_boolean(vec3_true);

print_boolean(vec3_false);

print_boolean(vec3_zero);

print_boolean(vec3_number);

print_boolean(vec3_negnumber);

print_boolean(vec3_small);

print_boolean(vec3_large);

print_boolean(vec3_undef);

print_boolean(vec3_inf);

print_boolean(vec3_char);

print_boolean(vec3_string);

print_boolean(vec3_emptystring);

// echo -->> The boolean value of any (!) 3-dim vector is always true
regardeless of its value


Output:


ECHO: true, true

ECHO: false, false

ECHO: 0, false

ECHO: 3, true

ECHO: -3, true

ECHO: 4.94066e-324, true

ECHO: 1.79769e+308, true

ECHO: undef, false

ECHO: inf, true

ECHO: "a", true

ECHO: "TEXT", true

ECHO: "", false

ECHO: [true, true], true

ECHO: [false, false], true

ECHO: [0, 0], true

ECHO: [3, 3], true

ECHO: [-3, -3], true

ECHO: [4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef], true

ECHO: [inf, inf], true

ECHO: ["a", "a"], true

ECHO: ["TEXT", "TEXT"], true

ECHO: ["", ""], true

ECHO: [true, true, true], true

ECHO: [false, false, false], true

ECHO: [0, 0, 0], true

ECHO: [3, 3, 3], true

ECHO: [-3, -3, -3], true

ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef, undef], true

ECHO: [inf, inf, inf], true

ECHO: ["a", "a", "a"], true

ECHO: ["TEXT", "TEXT", "TEXT"], true

ECHO: ["", "", ""], true

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

I'm very much worried by the way OpenSCAD treats what I call syntax errors: square([2,3,]); //works like square([2,3]); translate(1)circle();// translate() fails silently square([10,10,10]); // fails silently To remedy this I would like to initiate a discussion of what should be the expected behavior, what should lead to an error, and what should lead to a warning. To facilitate this discussion, I wrote a small program that, as a test case, lists all possible values a variable could take on. It than calls the module print_boolean() for all values which echos their value and its Boolean value. This program could then be used as a template for testing other calls (e.g. sphere(value);). Please have a look at it: Are there any other values that would be important to include as test cases? _____________________________________ // ----------------------------------------------------------------------- // // syntax_boolean_v0 // // List all possible values of vaiables to later // use them as a template to define and test the syntax // of (internal) module calls. // This is shown here for the boolean value, as an example. // // GPLv2 // (c) 2015 TakeItAndRun // // ----------------------------------------------------------------------- // variables var_true=true; var_false=false; var_zero=0; var_number=3; var_negnumber=-3; var_small=0.494066e-323; var_large=1.7976931348623158080999999e+308*1; var_undef=true*true; var_inf=1/0; var_char="a"; var_string="TEXT"; var_emptystring=""; // 2 dim-vectors vec2_true=vec2(var_true); vec2_false=vec2(var_false); vec2_zero=vec2(var_zero); vec2_number=vec2(var_number); vec2_negnumber=vec2(var_negnumber); vec2_small=vec2(var_small); vec2_large=vec2(var_large); vec2_undef=vec2(var_undef); vec2_inf=vec2(var_inf); vec2_char=vec2(var_char); vec2_string=vec2(var_string); vec2_emptystring=vec2(var_emptystring); // 3 dim-vectors vec3_true=vec3(var_true); vec3_false=vec3(var_false); vec3_zero=vec3(var_zero); vec3_number=vec3(var_number); vec3_negnumber=vec3(var_negnumber); vec3_small=vec3(var_small); vec3_large=vec3(var_large); vec3_undef=vec3(var_undef); vec3_inf=vec3(var_inf); vec3_char=vec3(var_char); vec3_string=vec3(var_string); vec3_emptystring=vec3(var_emptystring); // generate vectors from variables function vec2(var)=[var,var]; function vec3(var)=[var,var,var]; // print the value and the boolean value of it module print_boolean(var){ echo(var,var?true:false); } // var print_boolean(var_true); print_boolean(var_false); print_boolean(var_zero); print_boolean(var_number); print_boolean(var_negnumber); print_boolean(var_small); print_boolean(var_large); print_boolean(var_undef); print_boolean(var_inf); print_boolean(var_char); print_boolean(var_string); print_boolean(var_emptystring); // echo -->> The boolean value of false, zero, undef, and empty string gives false, everything else gives true // 2-dim vector print_boolean(vec2_true); print_boolean(vec2_false); print_boolean(vec2_zero); print_boolean(vec2_number); print_boolean(vec2_negnumber); print_boolean(vec2_small); print_boolean(vec2_large); print_boolean(vec2_undef); print_boolean(vec2_inf); print_boolean(vec2_char); print_boolean(vec2_string); print_boolean(vec2_emptystring); // echo -->> The boolean value of any (!) 2-dim vector is always true regardeless of its value // 3-dim vector print_boolean(vec3_true); print_boolean(vec3_false); print_boolean(vec3_zero); print_boolean(vec3_number); print_boolean(vec3_negnumber); print_boolean(vec3_small); print_boolean(vec3_large); print_boolean(vec3_undef); print_boolean(vec3_inf); print_boolean(vec3_char); print_boolean(vec3_string); print_boolean(vec3_emptystring); // echo -->> The boolean value of any (!) 3-dim vector is always true regardeless of its value _____________________________________ Output: _____________________________________ ECHO: true, true ECHO: false, false ECHO: 0, false ECHO: 3, true ECHO: -3, true ECHO: 4.94066e-324, true ECHO: 1.79769e+308, true ECHO: undef, false ECHO: inf, true ECHO: "a", true ECHO: "TEXT", true ECHO: "", false ECHO: [true, true], true ECHO: [false, false], true ECHO: [0, 0], true ECHO: [3, 3], true ECHO: [-3, -3], true ECHO: [4.94066e-324, 4.94066e-324], true ECHO: [1.79769e+308, 1.79769e+308], true ECHO: [undef, undef], true ECHO: [inf, inf], true ECHO: ["a", "a"], true ECHO: ["TEXT", "TEXT"], true ECHO: ["", ""], true ECHO: [true, true, true], true ECHO: [false, false, false], true ECHO: [0, 0, 0], true ECHO: [3, 3, 3], true ECHO: [-3, -3, -3], true ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true ECHO: [undef, undef, undef], true ECHO: [inf, inf, inf], true ECHO: ["a", "a", "a"], true ECHO: ["TEXT", "TEXT", "TEXT"], true ECHO: ["", "", ""], true -- stempeldergeschichte@googlemail.com <karsten@rohrbach.de> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben. Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. P.S. In case my e-mail is shorter than you enjoy: I am currently trying short replies instead of no replies at all. Please let me know, if you like to read more. Enjoy!
MK
Marius Kintel
Mon, Mar 16, 2015 9:55 PM

On Mar 16, 2015, at 17:44 PM, Peter Falke stempeldergeschichte@googlemail.com wrote:

I'm very much worried by the way OpenSCAD  treats what I call syntax errors:

This has been discussed quite a bit. I agree that this needs a cleanup.
We could start with providing warnings for all such cases, with an option of treating warnings as errors, to give people some sort of bug compatibility.
Then there are corner cases..

-Marius

On Mar 16, 2015, at 17:44 PM, Peter Falke <stempeldergeschichte@googlemail.com> wrote: > I'm very much worried by the way OpenSCAD treats what I call syntax errors: > This has been discussed quite a bit. I agree that this needs a cleanup. We could start with providing warnings for all such cases, with an option of treating warnings as errors, to give people some sort of bug compatibility. Then there are corner cases.. -Marius
NH
nop head
Mon, Mar 16, 2015 9:57 PM

Only the first one could be called a syntax error. Other languages allow
trailing comma for lists sometimes as it makes extending the list easier.

The rest are valid syntax but wrong argument type.

On 16 March 2015 at 21:44, Peter Falke stempeldergeschichte@googlemail.com
wrote:

I'm very much worried by the way OpenSCAD  treats what I call syntax
errors:

square([2,3,]); //works like square([2,3]);

translate(1)circle();// translate() fails silently

square([10,10,10]); // fails silently

To remedy this I would like to initiate a discussion of what should be the
expected behavior, what should lead to an error, and what should lead to a
warning.

To facilitate this discussion, I wrote a small program that, as a test
case, lists all  possible values a variable could take on.

It than calls the module print_boolean() for all values which echos their
value and its Boolean value.

This program could then be used as a template for testing other calls
(e.g. sphere(value);).

Please have a look at it: Are there any other values that would be
important to include as test cases?


// -----------------------------------------------------------------------

//

// syntax_boolean_v0

//

// List all possible values of vaiables to later

// use them as a template to define and test the syntax

// of (internal) module calls.

// This is shown here for the boolean value, as an example.

//

// GPLv2

// (c) 2015 TakeItAndRun

//

// -----------------------------------------------------------------------

// variables

var_true=true;

var_false=false;

var_zero=0;

var_number=3;

var_negnumber=-3;

var_small=0.494066e-323;

var_large=1.7976931348623158080999999e+308*1;

var_undef=true*true;

var_inf=1/0;

var_char="a";

var_string="TEXT";

var_emptystring="";

// 2 dim-vectors

vec2_true=vec2(var_true);

vec2_false=vec2(var_false);

vec2_zero=vec2(var_zero);

vec2_number=vec2(var_number);

vec2_negnumber=vec2(var_negnumber);

vec2_small=vec2(var_small);

vec2_large=vec2(var_large);

vec2_undef=vec2(var_undef);

vec2_inf=vec2(var_inf);

vec2_char=vec2(var_char);

vec2_string=vec2(var_string);

vec2_emptystring=vec2(var_emptystring);

// 3 dim-vectors

vec3_true=vec3(var_true);

vec3_false=vec3(var_false);

vec3_zero=vec3(var_zero);

vec3_number=vec3(var_number);

vec3_negnumber=vec3(var_negnumber);

vec3_small=vec3(var_small);

vec3_large=vec3(var_large);

vec3_undef=vec3(var_undef);

vec3_inf=vec3(var_inf);

vec3_char=vec3(var_char);

vec3_string=vec3(var_string);

vec3_emptystring=vec3(var_emptystring);

// generate vectors from variables

function vec2(var)=[var,var];

function vec3(var)=[var,var,var];

// print the value and the boolean value of it

module print_boolean(var){

echo(var,var?true:false);

}

// var

print_boolean(var_true);

print_boolean(var_false);

print_boolean(var_zero);

print_boolean(var_number);

print_boolean(var_negnumber);

print_boolean(var_small);

print_boolean(var_large);

print_boolean(var_undef);

print_boolean(var_inf);

print_boolean(var_char);

print_boolean(var_string);

print_boolean(var_emptystring);

// echo -->> The boolean value of false, zero, undef, and empty string
gives false, everything else gives true

// 2-dim vector

print_boolean(vec2_true);

print_boolean(vec2_false);

print_boolean(vec2_zero);

print_boolean(vec2_number);

print_boolean(vec2_negnumber);

print_boolean(vec2_small);

print_boolean(vec2_large);

print_boolean(vec2_undef);

print_boolean(vec2_inf);

print_boolean(vec2_char);

print_boolean(vec2_string);

print_boolean(vec2_emptystring);

// echo -->> The boolean value of any (!) 2-dim vector is always true
regardeless of its value

// 3-dim vector

print_boolean(vec3_true);

print_boolean(vec3_false);

print_boolean(vec3_zero);

print_boolean(vec3_number);

print_boolean(vec3_negnumber);

print_boolean(vec3_small);

print_boolean(vec3_large);

print_boolean(vec3_undef);

print_boolean(vec3_inf);

print_boolean(vec3_char);

print_boolean(vec3_string);

print_boolean(vec3_emptystring);

// echo -->> The boolean value of any (!) 3-dim vector is always true
regardeless of its value


Output:


ECHO: true, true

ECHO: false, false

ECHO: 0, false

ECHO: 3, true

ECHO: -3, true

ECHO: 4.94066e-324, true

ECHO: 1.79769e+308, true

ECHO: undef, false

ECHO: inf, true

ECHO: "a", true

ECHO: "TEXT", true

ECHO: "", false

ECHO: [true, true], true

ECHO: [false, false], true

ECHO: [0, 0], true

ECHO: [3, 3], true

ECHO: [-3, -3], true

ECHO: [4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef], true

ECHO: [inf, inf], true

ECHO: ["a", "a"], true

ECHO: ["TEXT", "TEXT"], true

ECHO: ["", ""], true

ECHO: [true, true, true], true

ECHO: [false, false, false], true

ECHO: [0, 0, 0], true

ECHO: [3, 3, 3], true

ECHO: [-3, -3, -3], true

ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef, undef], true

ECHO: [inf, inf, inf], true

ECHO: ["a", "a", "a"], true

ECHO: ["TEXT", "TEXT", "TEXT"], true

ECHO: ["", "", ""], true

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Only the first one could be called a syntax error. Other languages allow trailing comma for lists sometimes as it makes extending the list easier. The rest are valid syntax but wrong argument type. On 16 March 2015 at 21:44, Peter Falke <stempeldergeschichte@googlemail.com> wrote: > I'm very much worried by the way OpenSCAD treats what I call syntax > errors: > > > square([2,3,]); //works like square([2,3]); > > > translate(1)circle();// translate() fails silently > > > square([10,10,10]); // fails silently > > > > To remedy this I would like to initiate a discussion of what should be the > expected behavior, what should lead to an error, and what should lead to a > warning. > > > To facilitate this discussion, I wrote a small program that, as a test > case, lists all possible values a variable could take on. > > It than calls the module print_boolean() for all values which echos their > value and its Boolean value. > > This program could then be used as a template for testing other calls > (e.g. sphere(value);). > > > Please have a look at it: Are there any other values that would be > important to include as test cases? > > > _____________________________________ > > // ----------------------------------------------------------------------- > > // > > // syntax_boolean_v0 > > // > > // List all possible values of vaiables to later > > // use them as a template to define and test the syntax > > // of (internal) module calls. > > // This is shown here for the boolean value, as an example. > > // > > // GPLv2 > > // (c) 2015 TakeItAndRun > > // > > // ----------------------------------------------------------------------- > > > // variables > > > var_true=true; > > var_false=false; > > var_zero=0; > > var_number=3; > > var_negnumber=-3; > > var_small=0.494066e-323; > > var_large=1.7976931348623158080999999e+308*1; > > var_undef=true*true; > > var_inf=1/0; > > var_char="a"; > > var_string="TEXT"; > > var_emptystring=""; > > > // 2 dim-vectors > > > vec2_true=vec2(var_true); > > vec2_false=vec2(var_false); > > vec2_zero=vec2(var_zero); > > vec2_number=vec2(var_number); > > vec2_negnumber=vec2(var_negnumber); > > vec2_small=vec2(var_small); > > vec2_large=vec2(var_large); > > vec2_undef=vec2(var_undef); > > vec2_inf=vec2(var_inf); > > vec2_char=vec2(var_char); > > vec2_string=vec2(var_string); > > vec2_emptystring=vec2(var_emptystring); > > > // 3 dim-vectors > > > vec3_true=vec3(var_true); > > vec3_false=vec3(var_false); > > vec3_zero=vec3(var_zero); > > vec3_number=vec3(var_number); > > vec3_negnumber=vec3(var_negnumber); > > vec3_small=vec3(var_small); > > vec3_large=vec3(var_large); > > vec3_undef=vec3(var_undef); > > vec3_inf=vec3(var_inf); > > vec3_char=vec3(var_char); > > vec3_string=vec3(var_string); > > vec3_emptystring=vec3(var_emptystring); > > > // generate vectors from variables > > > function vec2(var)=[var,var]; > > function vec3(var)=[var,var,var]; > > > // print the value and the boolean value of it > > > module print_boolean(var){ > > echo(var,var?true:false); > > } > > > // var > > > print_boolean(var_true); > > print_boolean(var_false); > > print_boolean(var_zero); > > print_boolean(var_number); > > print_boolean(var_negnumber); > > print_boolean(var_small); > > print_boolean(var_large); > > print_boolean(var_undef); > > print_boolean(var_inf); > > print_boolean(var_char); > > print_boolean(var_string); > > print_boolean(var_emptystring); > > > // echo -->> The boolean value of false, zero, undef, and empty string > gives false, everything else gives true > > > // 2-dim vector > > > print_boolean(vec2_true); > > print_boolean(vec2_false); > > print_boolean(vec2_zero); > > print_boolean(vec2_number); > > print_boolean(vec2_negnumber); > > print_boolean(vec2_small); > > print_boolean(vec2_large); > > print_boolean(vec2_undef); > > print_boolean(vec2_inf); > > print_boolean(vec2_char); > > print_boolean(vec2_string); > > print_boolean(vec2_emptystring); > > > // echo -->> The boolean value of any (!) 2-dim vector is always true > regardeless of its value > > > // 3-dim vector > > > print_boolean(vec3_true); > > print_boolean(vec3_false); > > print_boolean(vec3_zero); > > print_boolean(vec3_number); > > print_boolean(vec3_negnumber); > > print_boolean(vec3_small); > > print_boolean(vec3_large); > > print_boolean(vec3_undef); > > print_boolean(vec3_inf); > > print_boolean(vec3_char); > > print_boolean(vec3_string); > > print_boolean(vec3_emptystring); > > > // echo -->> The boolean value of any (!) 3-dim vector is always true > regardeless of its value > > > > _____________________________________ > > > Output: > > _____________________________________ > > > ECHO: true, true > > ECHO: false, false > > ECHO: 0, false > > ECHO: 3, true > > ECHO: -3, true > > ECHO: 4.94066e-324, true > > ECHO: 1.79769e+308, true > > ECHO: undef, false > > ECHO: inf, true > > ECHO: "a", true > > ECHO: "TEXT", true > > ECHO: "", false > > ECHO: [true, true], true > > ECHO: [false, false], true > > ECHO: [0, 0], true > > ECHO: [3, 3], true > > ECHO: [-3, -3], true > > ECHO: [4.94066e-324, 4.94066e-324], true > > ECHO: [1.79769e+308, 1.79769e+308], true > > ECHO: [undef, undef], true > > ECHO: [inf, inf], true > > ECHO: ["a", "a"], true > > ECHO: ["TEXT", "TEXT"], true > > ECHO: ["", ""], true > > ECHO: [true, true, true], true > > ECHO: [false, false, false], true > > ECHO: [0, 0, 0], true > > ECHO: [3, 3, 3], true > > ECHO: [-3, -3, -3], true > > ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true > > ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true > > ECHO: [undef, undef, undef], true > > ECHO: [inf, inf, inf], true > > ECHO: ["a", "a", "a"], true > > ECHO: ["TEXT", "TEXT", "TEXT"], true > > ECHO: ["", "", ""], true > > > -- > stempeldergeschichte@googlemail.com <karsten@rohrbach.de> > > P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: > Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu > schreiben. > Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. > > P.S. In case my e-mail is shorter than you enjoy: > I am currently trying short replies instead of no replies at all. > Please let me know, if you like to read more. > > Enjoy! > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
J
jon
Mon, Mar 16, 2015 10:00 PM

In my opinion, having ANYTHING fail silently is a real problem. This is
one reason why people have trouble "getting into" OpenSCAD: no hints as
to what they have done wrong.

On 3/16/2015 5:57 PM, nop head wrote:

Only the first one could be called a syntax error. Other languages
allow trailing comma for lists sometimes as it makes extending the
list easier.

The rest are valid syntax but wrong argument type.

On 16 March 2015 at 21:44, Peter Falke
<stempeldergeschichte@googlemail.com
mailto:stempeldergeschichte@googlemail.com> wrote:

 I'm very much worried by the way OpenSCAD treats what I call
 syntax errors:
 /
 /
 square([2,3,]); //works like square([2,3]);


 translate(1)circle();// translate() fails silently


 square([10,10,10]); // fails silently



 To remedy this I would like to initiate a discussion of what
 should be the expected behavior, what should lead to an error, and
 what should lead to a warning.


 To facilitate this discussion, I wrote a small program that, as a
 test case, lists all  possible values a variable could take on.

 It than calls the module print_boolean() for all values which
 echos their value and its Boolean value.

 This program could then be used as a template for testing other
 calls (e.g. sphere(value);).


 Please have a look at it: Are there any other values that would be
 important to include as test cases?


 _____________________________________

 //
 -----------------------------------------------------------------------

 //

 // syntax_boolean_v0

 //

 // List all possible values of vaiables to later

 // use them as a template to define and test the syntax

 // of (internal) module calls.

 // This is shown here for the boolean value, as an example.

 //

 // GPLv2

 // (c) 2015 TakeItAndRun

 //

 //
 -----------------------------------------------------------------------


 // variables


 var_true=true;

 var_false=false;

 var_zero=0;

 var_number=3;

 var_negnumber=-3;

 var_small=0.494066e-323;

 var_large=1.7976931348623158080999999e+308*1;

 var_undef=true*true;

 var_inf=1/0;

 var_char="a";

 var_string="TEXT";

 var_emptystring="";


 // 2 dim-vectors


 vec2_true=vec2(var_true);

 vec2_false=vec2(var_false);

 vec2_zero=vec2(var_zero);

 vec2_number=vec2(var_number);

 vec2_negnumber=vec2(var_negnumber);

 vec2_small=vec2(var_small);

 vec2_large=vec2(var_large);

 vec2_undef=vec2(var_undef);

 vec2_inf=vec2(var_inf);

 vec2_char=vec2(var_char);

 vec2_string=vec2(var_string);

 vec2_emptystring=vec2(var_emptystring);


 // 3 dim-vectors


 vec3_true=vec3(var_true);

 vec3_false=vec3(var_false);

 vec3_zero=vec3(var_zero);

 vec3_number=vec3(var_number);

 vec3_negnumber=vec3(var_negnumber);

 vec3_small=vec3(var_small);

 vec3_large=vec3(var_large);

 vec3_undef=vec3(var_undef);

 vec3_inf=vec3(var_inf);

 vec3_char=vec3(var_char);

 vec3_string=vec3(var_string);

 vec3_emptystring=vec3(var_emptystring);


 // generate vectors from variables


 function vec2(var)=[var,var];

 function vec3(var)=[var,var,var];


 // print the value and the boolean value of it


 module print_boolean(var){

 echo(var,var?true:false);

 }


 // var


 print_boolean(var_true);

 print_boolean(var_false);

 print_boolean(var_zero);

 print_boolean(var_number);

 print_boolean(var_negnumber);

 print_boolean(var_small);

 print_boolean(var_large);

 print_boolean(var_undef);

 print_boolean(var_inf);

 print_boolean(var_char);

 print_boolean(var_string);

 print_boolean(var_emptystring);


 // echo -->> The boolean value of false, zero, undef, and empty
 string gives false, everything else gives true


 // 2-dim vector


 print_boolean(vec2_true);

 print_boolean(vec2_false);

 print_boolean(vec2_zero);

 print_boolean(vec2_number);

 print_boolean(vec2_negnumber);

 print_boolean(vec2_small);

 print_boolean(vec2_large);

 print_boolean(vec2_undef);

 print_boolean(vec2_inf);

 print_boolean(vec2_char);

 print_boolean(vec2_string);

 print_boolean(vec2_emptystring);


 // echo -->> The boolean value of any (!) 2-dim vector is always
 true regardeless of its value


 // 3-dim vector


 print_boolean(vec3_true);

 print_boolean(vec3_false);

 print_boolean(vec3_zero);

 print_boolean(vec3_number);

 print_boolean(vec3_negnumber);

 print_boolean(vec3_small);

 print_boolean(vec3_large);

 print_boolean(vec3_undef);

 print_boolean(vec3_inf);

 print_boolean(vec3_char);

 print_boolean(vec3_string);

 print_boolean(vec3_emptystring);


 // echo -->> The boolean value of any (!) 3-dim vector is always
 true regardeless of its value



 _____________________________________


 Output:

 _____________________________________


 ECHO: true, true

 ECHO: false, false

 ECHO: 0, false

 ECHO: 3, true

 ECHO: -3, true

 ECHO: 4.94066e-324, true

 ECHO: 1.79769e+308, true

 ECHO: undef, false

 ECHO: inf, true

 ECHO: "a", true

 ECHO: "TEXT", true

 ECHO: "", false

 ECHO: [true, true], true

 ECHO: [false, false], true

 ECHO: [0, 0], true

 ECHO: [3, 3], true

 ECHO: [-3, -3], true

 ECHO: [4.94066e-324, 4.94066e-324], true

 ECHO: [1.79769e+308, 1.79769e+308], true

 ECHO: [undef, undef], true

 ECHO: [inf, inf], true

 ECHO: ["a", "a"], true

 ECHO: ["TEXT", "TEXT"], true

 ECHO: ["", ""], true

 ECHO: [true, true, true], true

 ECHO: [false, false, false], true

 ECHO: [0, 0, 0], true

 ECHO: [3, 3, 3], true

 ECHO: [-3, -3, -3], true

 ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true

 ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true

 ECHO: [undef, undef, undef], true

 ECHO: [inf, inf, inf], true

 ECHO: ["a", "a", "a"], true

 ECHO: ["TEXT", "TEXT", "TEXT"], true

 ECHO: ["", "", ""], true



 -- 
 stempeldergeschichte@googlemail.com <mailto:karsten@rohrbach.de>

 P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
 Ich probiere gerade aus kurze Antworten statt gar keine Antworten
 zu schreiben.
 Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

 P.S. In case my e-mail is shorter than you enjoy:
 I am currently trying short replies instead of no replies at all.
 Please let me know, if you like to read more.

 Enjoy!

 _______________________________________________
 OpenSCAD mailing list
 Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org>
 http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2015.0.5751 / Virus Database: 4306/9317 - Release Date: 03/16/15

In my opinion, having ANYTHING fail silently is a real problem. This is one reason why people have trouble "getting into" OpenSCAD: no hints as to what they have done wrong. On 3/16/2015 5:57 PM, nop head wrote: > Only the first one could be called a syntax error. Other languages > allow trailing comma for lists sometimes as it makes extending the > list easier. > > The rest are valid syntax but wrong argument type. > > On 16 March 2015 at 21:44, Peter Falke > <stempeldergeschichte@googlemail.com > <mailto:stempeldergeschichte@googlemail.com>> wrote: > > I'm very much worried by the way OpenSCAD treats what I call > syntax errors: > / > / > square([2,3,]); //works like square([2,3]); > > > translate(1)circle();// translate() fails silently > > > square([10,10,10]); // fails silently > > > > To remedy this I would like to initiate a discussion of what > should be the expected behavior, what should lead to an error, and > what should lead to a warning. > > > To facilitate this discussion, I wrote a small program that, as a > test case, lists all possible values a variable could take on. > > It than calls the module print_boolean() for all values which > echos their value and its Boolean value. > > This program could then be used as a template for testing other > calls (e.g. sphere(value);). > > > Please have a look at it: Are there any other values that would be > important to include as test cases? > > > _____________________________________ > > // > ----------------------------------------------------------------------- > > // > > // syntax_boolean_v0 > > // > > // List all possible values of vaiables to later > > // use them as a template to define and test the syntax > > // of (internal) module calls. > > // This is shown here for the boolean value, as an example. > > // > > // GPLv2 > > // (c) 2015 TakeItAndRun > > // > > // > ----------------------------------------------------------------------- > > > // variables > > > var_true=true; > > var_false=false; > > var_zero=0; > > var_number=3; > > var_negnumber=-3; > > var_small=0.494066e-323; > > var_large=1.7976931348623158080999999e+308*1; > > var_undef=true*true; > > var_inf=1/0; > > var_char="a"; > > var_string="TEXT"; > > var_emptystring=""; > > > // 2 dim-vectors > > > vec2_true=vec2(var_true); > > vec2_false=vec2(var_false); > > vec2_zero=vec2(var_zero); > > vec2_number=vec2(var_number); > > vec2_negnumber=vec2(var_negnumber); > > vec2_small=vec2(var_small); > > vec2_large=vec2(var_large); > > vec2_undef=vec2(var_undef); > > vec2_inf=vec2(var_inf); > > vec2_char=vec2(var_char); > > vec2_string=vec2(var_string); > > vec2_emptystring=vec2(var_emptystring); > > > // 3 dim-vectors > > > vec3_true=vec3(var_true); > > vec3_false=vec3(var_false); > > vec3_zero=vec3(var_zero); > > vec3_number=vec3(var_number); > > vec3_negnumber=vec3(var_negnumber); > > vec3_small=vec3(var_small); > > vec3_large=vec3(var_large); > > vec3_undef=vec3(var_undef); > > vec3_inf=vec3(var_inf); > > vec3_char=vec3(var_char); > > vec3_string=vec3(var_string); > > vec3_emptystring=vec3(var_emptystring); > > > // generate vectors from variables > > > function vec2(var)=[var,var]; > > function vec3(var)=[var,var,var]; > > > // print the value and the boolean value of it > > > module print_boolean(var){ > > echo(var,var?true:false); > > } > > > // var > > > print_boolean(var_true); > > print_boolean(var_false); > > print_boolean(var_zero); > > print_boolean(var_number); > > print_boolean(var_negnumber); > > print_boolean(var_small); > > print_boolean(var_large); > > print_boolean(var_undef); > > print_boolean(var_inf); > > print_boolean(var_char); > > print_boolean(var_string); > > print_boolean(var_emptystring); > > > // echo -->> The boolean value of false, zero, undef, and empty > string gives false, everything else gives true > > > // 2-dim vector > > > print_boolean(vec2_true); > > print_boolean(vec2_false); > > print_boolean(vec2_zero); > > print_boolean(vec2_number); > > print_boolean(vec2_negnumber); > > print_boolean(vec2_small); > > print_boolean(vec2_large); > > print_boolean(vec2_undef); > > print_boolean(vec2_inf); > > print_boolean(vec2_char); > > print_boolean(vec2_string); > > print_boolean(vec2_emptystring); > > > // echo -->> The boolean value of any (!) 2-dim vector is always > true regardeless of its value > > > // 3-dim vector > > > print_boolean(vec3_true); > > print_boolean(vec3_false); > > print_boolean(vec3_zero); > > print_boolean(vec3_number); > > print_boolean(vec3_negnumber); > > print_boolean(vec3_small); > > print_boolean(vec3_large); > > print_boolean(vec3_undef); > > print_boolean(vec3_inf); > > print_boolean(vec3_char); > > print_boolean(vec3_string); > > print_boolean(vec3_emptystring); > > > // echo -->> The boolean value of any (!) 3-dim vector is always > true regardeless of its value > > > > _____________________________________ > > > Output: > > _____________________________________ > > > ECHO: true, true > > ECHO: false, false > > ECHO: 0, false > > ECHO: 3, true > > ECHO: -3, true > > ECHO: 4.94066e-324, true > > ECHO: 1.79769e+308, true > > ECHO: undef, false > > ECHO: inf, true > > ECHO: "a", true > > ECHO: "TEXT", true > > ECHO: "", false > > ECHO: [true, true], true > > ECHO: [false, false], true > > ECHO: [0, 0], true > > ECHO: [3, 3], true > > ECHO: [-3, -3], true > > ECHO: [4.94066e-324, 4.94066e-324], true > > ECHO: [1.79769e+308, 1.79769e+308], true > > ECHO: [undef, undef], true > > ECHO: [inf, inf], true > > ECHO: ["a", "a"], true > > ECHO: ["TEXT", "TEXT"], true > > ECHO: ["", ""], true > > ECHO: [true, true, true], true > > ECHO: [false, false, false], true > > ECHO: [0, 0, 0], true > > ECHO: [3, 3, 3], true > > ECHO: [-3, -3, -3], true > > ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true > > ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true > > ECHO: [undef, undef, undef], true > > ECHO: [inf, inf, inf], true > > ECHO: ["a", "a", "a"], true > > ECHO: ["TEXT", "TEXT", "TEXT"], true > > ECHO: ["", "", ""], true > > > > -- > stempeldergeschichte@googlemail.com <mailto:karsten@rohrbach.de> > > P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: > Ich probiere gerade aus kurze Antworten statt gar keine Antworten > zu schreiben. > Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. > > P.S. In case my e-mail is shorter than you enjoy: > I am currently trying short replies instead of no replies at all. > Please let me know, if you like to read more. > > Enjoy! > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > > No virus found in this message. > Checked by AVG - www.avg.com <http://www.avg.com> > Version: 2015.0.5751 / Virus Database: 4306/9317 - Release Date: 03/16/15 >
PF
Peter Falke
Mon, Mar 16, 2015 10:05 PM

So in the case of Boolean value:

Is there any use case for the Boolean of a vector?
Could the attempt of getting the Boolean of a vector lead to a WARNING:
wrong argument type ?

2015-03-16 22:57 GMT+01:00 nop head nop.head@gmail.com:

Only the first one could be called a syntax error. Other languages allow
trailing comma for lists sometimes as it makes extending the list easier.

The rest are valid syntax but wrong argument type.

On 16 March 2015 at 21:44, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:

I'm very much worried by the way OpenSCAD  treats what I call syntax
errors:

square([2,3,]); //works like square([2,3]);

translate(1)circle();// translate() fails silently

square([10,10,10]); // fails silently

To remedy this I would like to initiate a discussion of what should be
the expected behavior, what should lead to an error, and what should lead
to a warning.

To facilitate this discussion, I wrote a small program that, as a test
case, lists all  possible values a variable could take on.

It than calls the module print_boolean() for all values which echos their
value and its Boolean value.

This program could then be used as a template for testing other calls
(e.g. sphere(value);).

Please have a look at it: Are there any other values that would be
important to include as test cases?


// -----------------------------------------------------------------------

//

// syntax_boolean_v0

//

// List all possible values of vaiables to later

// use them as a template to define and test the syntax

// of (internal) module calls.

// This is shown here for the boolean value, as an example.

//

// GPLv2

// (c) 2015 TakeItAndRun

//

// -----------------------------------------------------------------------

// variables

var_true=true;

var_false=false;

var_zero=0;

var_number=3;

var_negnumber=-3;

var_small=0.494066e-323;

var_large=1.7976931348623158080999999e+308*1;

var_undef=true*true;

var_inf=1/0;

var_char="a";

var_string="TEXT";

var_emptystring="";

// 2 dim-vectors

vec2_true=vec2(var_true);

vec2_false=vec2(var_false);

vec2_zero=vec2(var_zero);

vec2_number=vec2(var_number);

vec2_negnumber=vec2(var_negnumber);

vec2_small=vec2(var_small);

vec2_large=vec2(var_large);

vec2_undef=vec2(var_undef);

vec2_inf=vec2(var_inf);

vec2_char=vec2(var_char);

vec2_string=vec2(var_string);

vec2_emptystring=vec2(var_emptystring);

// 3 dim-vectors

vec3_true=vec3(var_true);

vec3_false=vec3(var_false);

vec3_zero=vec3(var_zero);

vec3_number=vec3(var_number);

vec3_negnumber=vec3(var_negnumber);

vec3_small=vec3(var_small);

vec3_large=vec3(var_large);

vec3_undef=vec3(var_undef);

vec3_inf=vec3(var_inf);

vec3_char=vec3(var_char);

vec3_string=vec3(var_string);

vec3_emptystring=vec3(var_emptystring);

// generate vectors from variables

function vec2(var)=[var,var];

function vec3(var)=[var,var,var];

// print the value and the boolean value of it

module print_boolean(var){

echo(var,var?true:false);

}

// var

print_boolean(var_true);

print_boolean(var_false);

print_boolean(var_zero);

print_boolean(var_number);

print_boolean(var_negnumber);

print_boolean(var_small);

print_boolean(var_large);

print_boolean(var_undef);

print_boolean(var_inf);

print_boolean(var_char);

print_boolean(var_string);

print_boolean(var_emptystring);

// echo -->> The boolean value of false, zero, undef, and empty string
gives false, everything else gives true

// 2-dim vector

print_boolean(vec2_true);

print_boolean(vec2_false);

print_boolean(vec2_zero);

print_boolean(vec2_number);

print_boolean(vec2_negnumber);

print_boolean(vec2_small);

print_boolean(vec2_large);

print_boolean(vec2_undef);

print_boolean(vec2_inf);

print_boolean(vec2_char);

print_boolean(vec2_string);

print_boolean(vec2_emptystring);

// echo -->> The boolean value of any (!) 2-dim vector is always true
regardeless of its value

// 3-dim vector

print_boolean(vec3_true);

print_boolean(vec3_false);

print_boolean(vec3_zero);

print_boolean(vec3_number);

print_boolean(vec3_negnumber);

print_boolean(vec3_small);

print_boolean(vec3_large);

print_boolean(vec3_undef);

print_boolean(vec3_inf);

print_boolean(vec3_char);

print_boolean(vec3_string);

print_boolean(vec3_emptystring);

// echo -->> The boolean value of any (!) 3-dim vector is always true
regardeless of its value


Output:


ECHO: true, true

ECHO: false, false

ECHO: 0, false

ECHO: 3, true

ECHO: -3, true

ECHO: 4.94066e-324, true

ECHO: 1.79769e+308, true

ECHO: undef, false

ECHO: inf, true

ECHO: "a", true

ECHO: "TEXT", true

ECHO: "", false

ECHO: [true, true], true

ECHO: [false, false], true

ECHO: [0, 0], true

ECHO: [3, 3], true

ECHO: [-3, -3], true

ECHO: [4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef], true

ECHO: [inf, inf], true

ECHO: ["a", "a"], true

ECHO: ["TEXT", "TEXT"], true

ECHO: ["", ""], true

ECHO: [true, true, true], true

ECHO: [false, false, false], true

ECHO: [0, 0, 0], true

ECHO: [3, 3, 3], true

ECHO: [-3, -3, -3], true

ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true

ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true

ECHO: [undef, undef, undef], true

ECHO: [inf, inf, inf], true

ECHO: ["a", "a", "a"], true

ECHO: ["TEXT", "TEXT", "TEXT"], true

ECHO: ["", "", ""], true

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
stempeldergeschichte@googlemail.com karsten@rohrbach.de

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

So in the case of Boolean value: Is there any use case for the Boolean of a vector? Could the attempt of getting the Boolean of a vector lead to a WARNING: wrong argument type ? 2015-03-16 22:57 GMT+01:00 nop head <nop.head@gmail.com>: > Only the first one could be called a syntax error. Other languages allow > trailing comma for lists sometimes as it makes extending the list easier. > > The rest are valid syntax but wrong argument type. > > On 16 March 2015 at 21:44, Peter Falke < > stempeldergeschichte@googlemail.com> wrote: > >> I'm very much worried by the way OpenSCAD treats what I call syntax >> errors: >> >> >> square([2,3,]); //works like square([2,3]); >> >> >> translate(1)circle();// translate() fails silently >> >> >> square([10,10,10]); // fails silently >> >> >> >> To remedy this I would like to initiate a discussion of what should be >> the expected behavior, what should lead to an error, and what should lead >> to a warning. >> >> >> To facilitate this discussion, I wrote a small program that, as a test >> case, lists all possible values a variable could take on. >> >> It than calls the module print_boolean() for all values which echos their >> value and its Boolean value. >> >> This program could then be used as a template for testing other calls >> (e.g. sphere(value);). >> >> >> Please have a look at it: Are there any other values that would be >> important to include as test cases? >> >> >> _____________________________________ >> >> // ----------------------------------------------------------------------- >> >> // >> >> // syntax_boolean_v0 >> >> // >> >> // List all possible values of vaiables to later >> >> // use them as a template to define and test the syntax >> >> // of (internal) module calls. >> >> // This is shown here for the boolean value, as an example. >> >> // >> >> // GPLv2 >> >> // (c) 2015 TakeItAndRun >> >> // >> >> // ----------------------------------------------------------------------- >> >> >> // variables >> >> >> var_true=true; >> >> var_false=false; >> >> var_zero=0; >> >> var_number=3; >> >> var_negnumber=-3; >> >> var_small=0.494066e-323; >> >> var_large=1.7976931348623158080999999e+308*1; >> >> var_undef=true*true; >> >> var_inf=1/0; >> >> var_char="a"; >> >> var_string="TEXT"; >> >> var_emptystring=""; >> >> >> // 2 dim-vectors >> >> >> vec2_true=vec2(var_true); >> >> vec2_false=vec2(var_false); >> >> vec2_zero=vec2(var_zero); >> >> vec2_number=vec2(var_number); >> >> vec2_negnumber=vec2(var_negnumber); >> >> vec2_small=vec2(var_small); >> >> vec2_large=vec2(var_large); >> >> vec2_undef=vec2(var_undef); >> >> vec2_inf=vec2(var_inf); >> >> vec2_char=vec2(var_char); >> >> vec2_string=vec2(var_string); >> >> vec2_emptystring=vec2(var_emptystring); >> >> >> // 3 dim-vectors >> >> >> vec3_true=vec3(var_true); >> >> vec3_false=vec3(var_false); >> >> vec3_zero=vec3(var_zero); >> >> vec3_number=vec3(var_number); >> >> vec3_negnumber=vec3(var_negnumber); >> >> vec3_small=vec3(var_small); >> >> vec3_large=vec3(var_large); >> >> vec3_undef=vec3(var_undef); >> >> vec3_inf=vec3(var_inf); >> >> vec3_char=vec3(var_char); >> >> vec3_string=vec3(var_string); >> >> vec3_emptystring=vec3(var_emptystring); >> >> >> // generate vectors from variables >> >> >> function vec2(var)=[var,var]; >> >> function vec3(var)=[var,var,var]; >> >> >> // print the value and the boolean value of it >> >> >> module print_boolean(var){ >> >> echo(var,var?true:false); >> >> } >> >> >> // var >> >> >> print_boolean(var_true); >> >> print_boolean(var_false); >> >> print_boolean(var_zero); >> >> print_boolean(var_number); >> >> print_boolean(var_negnumber); >> >> print_boolean(var_small); >> >> print_boolean(var_large); >> >> print_boolean(var_undef); >> >> print_boolean(var_inf); >> >> print_boolean(var_char); >> >> print_boolean(var_string); >> >> print_boolean(var_emptystring); >> >> >> // echo -->> The boolean value of false, zero, undef, and empty string >> gives false, everything else gives true >> >> >> // 2-dim vector >> >> >> print_boolean(vec2_true); >> >> print_boolean(vec2_false); >> >> print_boolean(vec2_zero); >> >> print_boolean(vec2_number); >> >> print_boolean(vec2_negnumber); >> >> print_boolean(vec2_small); >> >> print_boolean(vec2_large); >> >> print_boolean(vec2_undef); >> >> print_boolean(vec2_inf); >> >> print_boolean(vec2_char); >> >> print_boolean(vec2_string); >> >> print_boolean(vec2_emptystring); >> >> >> // echo -->> The boolean value of any (!) 2-dim vector is always true >> regardeless of its value >> >> >> // 3-dim vector >> >> >> print_boolean(vec3_true); >> >> print_boolean(vec3_false); >> >> print_boolean(vec3_zero); >> >> print_boolean(vec3_number); >> >> print_boolean(vec3_negnumber); >> >> print_boolean(vec3_small); >> >> print_boolean(vec3_large); >> >> print_boolean(vec3_undef); >> >> print_boolean(vec3_inf); >> >> print_boolean(vec3_char); >> >> print_boolean(vec3_string); >> >> print_boolean(vec3_emptystring); >> >> >> // echo -->> The boolean value of any (!) 3-dim vector is always true >> regardeless of its value >> >> >> >> _____________________________________ >> >> >> Output: >> >> _____________________________________ >> >> >> ECHO: true, true >> >> ECHO: false, false >> >> ECHO: 0, false >> >> ECHO: 3, true >> >> ECHO: -3, true >> >> ECHO: 4.94066e-324, true >> >> ECHO: 1.79769e+308, true >> >> ECHO: undef, false >> >> ECHO: inf, true >> >> ECHO: "a", true >> >> ECHO: "TEXT", true >> >> ECHO: "", false >> >> ECHO: [true, true], true >> >> ECHO: [false, false], true >> >> ECHO: [0, 0], true >> >> ECHO: [3, 3], true >> >> ECHO: [-3, -3], true >> >> ECHO: [4.94066e-324, 4.94066e-324], true >> >> ECHO: [1.79769e+308, 1.79769e+308], true >> >> ECHO: [undef, undef], true >> >> ECHO: [inf, inf], true >> >> ECHO: ["a", "a"], true >> >> ECHO: ["TEXT", "TEXT"], true >> >> ECHO: ["", ""], true >> >> ECHO: [true, true, true], true >> >> ECHO: [false, false, false], true >> >> ECHO: [0, 0, 0], true >> >> ECHO: [3, 3, 3], true >> >> ECHO: [-3, -3, -3], true >> >> ECHO: [4.94066e-324, 4.94066e-324, 4.94066e-324], true >> >> ECHO: [1.79769e+308, 1.79769e+308, 1.79769e+308], true >> >> ECHO: [undef, undef, undef], true >> >> ECHO: [inf, inf, inf], true >> >> ECHO: ["a", "a", "a"], true >> >> ECHO: ["TEXT", "TEXT", "TEXT"], true >> >> ECHO: ["", "", ""], true >> >> >> -- >> stempeldergeschichte@googlemail.com <karsten@rohrbach.de> >> >> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: >> Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu >> schreiben. >> Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. >> >> P.S. In case my e-mail is shorter than you enjoy: >> I am currently trying short replies instead of no replies at all. >> Please let me know, if you like to read more. >> >> Enjoy! >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > -- stempeldergeschichte@googlemail.com <karsten@rohrbach.de> P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist: Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben. Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen. P.S. In case my e-mail is shorter than you enjoy: I am currently trying short replies instead of no replies at all. Please let me know, if you like to read more. Enjoy!
M
MichaelAtOz
Tue, Mar 17, 2015 12:15 AM

jon_bondy wrote

In my opinion, having ANYTHING fail silently is a real problem. This is
one reason why people have trouble "getting into" OpenSCAD: no hints as
to what they have done wrong.

+1 from my earlier learning experience, this was one of the most frustrating
bits.
However it should be a Warning (or an option) not a fail.
With the new alert at the view window it will stand out.


Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/

View this message in context: http://forum.openscad.org/treatment-of-syntax-errors-in-OpenSCAD-tp12060p12067.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

jon_bondy wrote > In my opinion, having ANYTHING fail silently is a real problem. This is > one reason why people have trouble "getting into" OpenSCAD: no hints as > to what they have done wrong. +1 from my earlier learning experience, this was one of the most frustrating bits. However it should be a Warning (or an option) not a fail. With the new alert at the view window it will stand out. ----- Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ -- View this message in context: http://forum.openscad.org/treatment-of-syntax-errors-in-OpenSCAD-tp12060p12067.html Sent from the OpenSCAD mailing list archive at Nabble.com.
PF
Peter Falke
Tue, Mar 17, 2015 5:00 PM

I cleaned up my code a bit: organized the corner cases in a vector, so that
you can easily loop over them.

Presently the Boolean value of a vector is always (!) true.
Is taking the Boolean of a vector a wrong argument error (or warning) or is
there a use case anyone could think about?
Would it make sense to logical or all elements of the vector and use this
at its Boolean value?
What could one do with this?

I cleaned up my code a bit: organized the corner cases in a vector, so that you can easily loop over them. Presently the Boolean value of a vector is always (!) true. Is taking the Boolean of a vector a wrong argument error (or warning) or is there a use case anyone could think about? Would it make sense to logical or all elements of the vector and use this at its Boolean value? What could one do with this?
C
clothbot
Tue, Mar 17, 2015 7:22 PM

Try this:

vec_empty=[];
print_boolean(vec_empty);

I get 'false'.

If a vector is not-empty it's not-false=true.

Andrew.

--
View this message in context: http://forum.openscad.org/treatment-of-syntax-errors-in-OpenSCAD-tp12060p12071.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Try this: vec_empty=[]; print_boolean(vec_empty); I get 'false'. If a vector is not-empty it's not-false=true. Andrew. -- View this message in context: http://forum.openscad.org/treatment-of-syntax-errors-in-OpenSCAD-tp12060p12071.html Sent from the OpenSCAD mailing list archive at Nabble.com.