What is wrong here?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

What is wrong here?

Ronaldo
This silly code:

ssl = [[1],[1,2]];
cycls = ssl;

function ev(a) = a;
function bh(a) = a;

a=[for(si=ssl)[for(sij=si, bh=[bh(sij)]) each sij, cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)] ] ] ;

generates the following console messages with version 2018.01.16:

Compiling design (CSG Tree generation)...

WARNING: Ignoring unknown variable 'sij'.

WARNING: Ignoring unknown variable 'bh'.

WARNING: Ignoring unknown variable 'sij'.

WARNING: Ignoring unknown variable 'bh'.

WARNING: Ignoring unknown variable 'sij'.

WARNING: Ignoring unknown variable 'bh'.

WARNING: Ignoring unknown variable 'sij'.

WARNING: Ignoring unknown variable 'bh'.

Compiling design (CSG Products generation)...

Geometries in cache: 0

Geometry cache size in bytes: 0

CGAL Polyhedrons in cache: 0


The last snapshot version 2019.01.10.ci1115 makes the same warnings adding the line number of the last line.


I can't see what is wrong!




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

woferry
Seems to be a chicken & egg problem, in the code below you assigned things to "a" before defining it.  But if you move the definition of "a" above the functions, then "a" is calling "ev" and "bh" before they are defined.  So I think it's busted either way.  Now as to why it only complained about "sij" and "bh" and not "a" or "ev" (I get the same warnings regardless of where "a" is defined) I can't say.

- Will


> On Jan 28, 2019, at 9:46 AM, Ronaldo Persiano <[hidden email]> wrote:
>
> This silly code:
>
> ssl = [[1],[1,2]];
> cycls = ssl;
>
> function ev(a) = a;
> function bh(a) = a;
>
> a=[for(si=ssl)[for(sij=si, bh=[bh(sij)]) each sij, cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)] ] ] ;
>
> generates the following console messages with version 2018.01.16:
>
> Compiling design (CSG Tree generation)...
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> Compiling design (CSG Products generation)...
> Geometries in cache: 0
> Geometry cache size in bytes: 0
> CGAL Polyhedrons in cache: 0
>
> The last snapshot version  2019.01.10.ci1115 makes the same warnings adding the line number of the last line.
>
> I can't see what is wrong!
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

thehans
I think the issue is your comma separated expressions "each sij, cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)]" in the list comprehension don't make sense.  They need to be wrapped in square brackets.

On Mon, Jan 28, 2019 at 12:02 PM William Ferry <[hidden email]> wrote:
Seems to be a chicken & egg problem, in the code below you assigned things to "a" before defining it.  But if you move the definition of "a" above the functions, then "a" is calling "ev" and "bh" before they are defined.  So I think it's busted either way.  Now as to why it only complained about "sij" and "bh" and not "a" or "ev" (I get the same warnings regardless of where "a" is defined) I can't say.

- Will


> On Jan 28, 2019, at 9:46 AM, Ronaldo Persiano <[hidden email]> wrote:
>
> This silly code:
>
> ssl = [[1],[1,2]];
> cycls = ssl;
>
> function ev(a) = a;
> function bh(a) = a;
>
> a=[for(si=ssl)[for(sij=si, bh=[bh(sij)]) each sij, cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)] ] ] ;
>
> generates the following console messages with version 2018.01.16:
>
> Compiling design (CSG Tree generation)...
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> WARNING: Ignoring unknown variable 'sij'.
> WARNING: Ignoring unknown variable 'bh'.
> Compiling design (CSG Products generation)...
> Geometries in cache: 0
> Geometry cache size in bytes: 0
> CGAL Polyhedrons in cache: 0
>
> The last snapshot version  2019.01.10.ci1115 makes the same warnings adding the line number of the last line.
>
> I can't see what is wrong!
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

Ronaldo
In reply to this post by woferry
William Ferry <[hidden email]> wrote:
Seems to be a chicken & egg problem, in the code below you assigned things to "a" before defining it.  But if you move the definition of "a" above the functions, then "a" is calling "ev" and "bh" before they are defined.  So I think it's busted either way.  Now as to why it only complained about "sij" and "bh" and not "a" or "ev" (I get the same warnings regardless of where "a" is defined) I can't say.

The place of the definitions of ev() and bh() are irrelevant to OpenSCAD. I usually write my main codes before the definitions of functions and modules in a top down order.

I got what I wanted with the code:

a=[for(si=ssl)[for(sij=si, bh=[bh(sij)]) append(cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)], sij)] ] ;

function append(e,l) = [each l, e];

what is very different from what the previous code was trying to express.

But why the previous code generates the warning is a mystery.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

Ronaldo
In reply to this post by thehans


Hans L <[hidden email]> wrote:
I think the issue is your comma separated expressions "each sij, cycls[bh][ev(sij)+1] - cycls[bh][ev(sij)]" in the list comprehension don't make sense.  They need to be wrapped in square brackets.

I guess you are write but then the message should be a syntax error message and not a warning about something else.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

Parkinbot
Ronaldo

echo(a);
a=[for(i=[0:3]) each i, 1];

will output [0, 1, 2, 3, 1]

while

echo(a);
a=[for(i=[0:3]) each i, i];

will give you a warning because the second reference to i is out of scope as
the inner for loop ends at the comma.  




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

Ronaldo
Right, Parkinbot. Crystal clear. That was my mistake.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: What is wrong here?

kdtop
Can MeshMixer fix the problem?  Or are you just not wanting there to be problem in the first place?

KT

On Mon, Jan 28, 2019 at 10:11 PM Ronaldo Persiano <[hidden email]> wrote:
Right, Parkinbot. Crystal clear. That was my mistake.
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org