NH
nop head
Sat, Jul 19, 2025 5:55 PM
Yes, that also works for me. Not sure that it makes any difference though
as it is still under the each.
On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
I was thinking of this, which appears to produce the same result (though
it's hard to be certain since you didn't provide a runable example)
[for(i = [0 : len(transforms) - 1])
each assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
profile4 * transforms[i],
];
which seems to obviously run the assert only once. You could also insert
the assert inside the let with a dummy assignment, or inside the profile4
assignment, though both are a little ugly.
On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
It isn't clear to me if moving it after the each make the assert executed
more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If I had to guess I would say that the problem is what does assert do?
It passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is
basically invisible.
But when you insert an each you are now exploding the x from being one
item into a bunch of items. It seems like assert cannot accept an
exploded list as one child item. I would say that there are very few
contexts where each is permitted. You can't write a = each list. So it
doesn't seem shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the
each but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Yes, that also works for me. Not sure that it makes any difference though
as it is still under the each.
On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
> I was thinking of this, which appears to produce the same result (though
> it's hard to be certain since you didn't provide a runable example)
>
> [for(i = [0 : len(transforms) - 1])
> each assert(len(profiles[i]) == len(profiles[0]))
> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
> profile4 * transforms[i],
> ];
>
> which seems to obviously run the assert only once. You could also insert
> the assert inside the let with a dummy assignment, or inside the profile4
> assignment, though both are a little ugly.
>
> On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> It isn't clear to me if moving it after the each make the assert executed
>> more times or not.
>>
>> On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> If I had to guess I would say that the problem is what does assert do?
>>> It passes the "child" object up as a return value. So
>>>
>>> assert( ...) x
>>>
>>> is the same as
>>>
>>> x
>>>
>>> from the perspective of the calling code, to which the assert is
>>> basically invisible.
>>>
>>> But when you insert an each you are now exploding the x from being one
>>> item into a bunch of items. It seems like assert cannot accept an
>>> exploded list as one child item. I would say that there are very few
>>> contexts where each is permitted. You can't write a = each list. So it
>>> doesn't seem shocking that the each needs to be outside the assert.
>>>
>>> Perhaps Torsten will have a more formal explanation.
>>>
>>> On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> Yes, that works, thanks. Not sure why each not allowed after an
>>>> assert though?
>>>>
>>>> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> Problem appears to be the "each". Looks like putting each before the
>>>>> assert() may work.
>>>>>
>>>>>
>>>>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>>>>> discuss@lists.openscad.org> wrote:
>>>>>
>>>>>> The error square in the editor is actually on the space after the
>>>>>> each but if I remove the assert that line is fine.
>>>>>>
>>>>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>>>>
>>>>>>> [for(i = [0 : len(transforms) - 1])
>>>>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>>>>> each profile4 * transforms[i],
>>>>>>> ];
>>>>>>>
>>>>>>>
>>>>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>>
>>>>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>>>>> > It seems that assert can't be used in a list comprehension? Is
>>>>>>>> this
>>>>>>>> > correct, if so, why not?
>>>>>>>>
>>>>>>>> That could be a parser conflict for a specific case as this works
>>>>>>>>
>>>>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>>>>> echo(a);
>>>>>>>>
>>>>>>>> So what's the code that fails?
>>>>>>>>
>>>>>>>> ciao,
>>>>>>>> Torsten.
>>>>>>>> _______________________________________________
>>>>>>>> OpenSCAD mailing list
>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>> OpenSCAD mailing list
>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>
>>>>> _______________________________________________
>>>>> OpenSCAD mailing list
>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
AM
Adrian Mariano
Sat, Jul 19, 2025 6:00 PM
If you do the other thing then the assert is inside the second loop, so it
seems pretty obvious it will run many times. This way, it is inside the
each but outside the inner loop. Why would you expect it to run more than
once? The assert runs once, and then passes its list argument to each,
which gets exploded and processed by the list comprehension above. I don't
see any reason why the assert could run more than once (well, more than
once each time inside the top level loop).
On Sat, Jul 19, 2025 at 1:56 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that also works for me. Not sure that it makes any difference though
as it is still under the each.
On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
I was thinking of this, which appears to produce the same result (though
it's hard to be certain since you didn't provide a runable example)
[for(i = [0 : len(transforms) - 1])
each assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
profile4 * transforms[i],
];
which seems to obviously run the assert only once. You could also insert
the assert inside the let with a dummy assignment, or inside the profile4
assignment, though both are a little ugly.
On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
It isn't clear to me if moving it after the each make the assert
executed more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If I had to guess I would say that the problem is what does assert do?
It passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is
basically invisible.
But when you insert an each you are now exploding the x from being one
item into a bunch of items. It seems like assert cannot accept an
exploded list as one child item. I would say that there are very few
contexts where each is permitted. You can't write a = each list. So it
doesn't seem shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before the
assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the
each but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
If you do the other thing then the assert is inside the second loop, so it
seems pretty obvious it will run many times. This way, it is inside the
each but outside the inner loop. Why would you expect it to run more than
once? The assert runs once, and then passes its list argument to each,
which gets exploded and processed by the list comprehension above. I don't
see any reason why the assert could run more than once (well, more than
once each time inside the top level loop).
On Sat, Jul 19, 2025 at 1:56 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
> Yes, that also works for me. Not sure that it makes any difference though
> as it is still under the each.
>
> On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> I was thinking of this, which appears to produce the same result (though
>> it's hard to be certain since you didn't provide a runable example)
>>
>> [for(i = [0 : len(transforms) - 1])
>> each assert(len(profiles[i]) == len(profiles[0]))
>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>> profile4 * transforms[i],
>> ];
>>
>> which seems to obviously run the assert only once. You could also insert
>> the assert inside the let with a dummy assignment, or inside the profile4
>> assignment, though both are a little ugly.
>>
>> On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> It isn't clear to me if moving it after the each make the assert
>>> executed more times or not.
>>>
>>> On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> If I had to guess I would say that the problem is what does assert do?
>>>> It passes the "child" object up as a return value. So
>>>>
>>>> assert( ...) x
>>>>
>>>> is the same as
>>>>
>>>> x
>>>>
>>>> from the perspective of the calling code, to which the assert is
>>>> basically invisible.
>>>>
>>>> But when you insert an each you are now exploding the x from being one
>>>> item into a bunch of items. It seems like assert cannot accept an
>>>> exploded list as one child item. I would say that there are very few
>>>> contexts where each is permitted. You can't write a = each list. So it
>>>> doesn't seem shocking that the each needs to be outside the assert.
>>>>
>>>> Perhaps Torsten will have a more formal explanation.
>>>>
>>>> On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> Yes, that works, thanks. Not sure why each not allowed after an
>>>>> assert though?
>>>>>
>>>>> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
>>>>> discuss@lists.openscad.org> wrote:
>>>>>
>>>>>> Problem appears to be the "each". Looks like putting each before the
>>>>>> assert() may work.
>>>>>>
>>>>>>
>>>>>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>
>>>>>>> The error square in the editor is actually on the space after the
>>>>>>> each but if I remove the assert that line is fine.
>>>>>>>
>>>>>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>>>>>
>>>>>>>> [for(i = [0 : len(transforms) - 1])
>>>>>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>>>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>>>>>> each profile4 * transforms[i],
>>>>>>>> ];
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>>>
>>>>>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>>>>>> > It seems that assert can't be used in a list comprehension? Is
>>>>>>>>> this
>>>>>>>>> > correct, if so, why not?
>>>>>>>>>
>>>>>>>>> That could be a parser conflict for a specific case as this works
>>>>>>>>>
>>>>>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>>>>>> echo(a);
>>>>>>>>>
>>>>>>>>> So what's the code that fails?
>>>>>>>>>
>>>>>>>>> ciao,
>>>>>>>>> Torsten.
>>>>>>>>> _______________________________________________
>>>>>>>>> OpenSCAD mailing list
>>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>> OpenSCAD mailing list
>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>
>>>>>> _______________________________________________
>>>>>> OpenSCAD mailing list
>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>
>>>>> _______________________________________________
>>>>> OpenSCAD mailing list
>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
NH
nop head
Sat, Jul 19, 2025 6:14 PM
The inner loop is self-contained though, as it makes a list and assigns it
to a variable, then the list is multiplied by a matrix.
On Sat, 19 Jul 2025 at 19:01, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If you do the other thing then the assert is inside the second loop, so it
seems pretty obvious it will run many times. This way, it is inside the
each but outside the inner loop. Why would you expect it to run more than
once? The assert runs once, and then passes its list argument to each,
which gets exploded and processed by the list comprehension above. I don't
see any reason why the assert could run more than once (well, more than
once each time inside the top level loop).
On Sat, Jul 19, 2025 at 1:56 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that also works for me. Not sure that it makes any difference though
as it is still under the each.
On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
I was thinking of this, which appears to produce the same result (though
it's hard to be certain since you didn't provide a runable example)
[for(i = [0 : len(transforms) - 1])
each assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
profile4 * transforms[i],
];
which seems to obviously run the assert only once. You could also
insert the assert inside the let with a dummy assignment, or inside the
profile4 assignment, though both are a little ugly.
On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
It isn't clear to me if moving it after the each make the assert
executed more times or not.
On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
If I had to guess I would say that the problem is what does assert
do? It passes the "child" object up as a return value. So
assert( ...) x
is the same as
x
from the perspective of the calling code, to which the assert is
basically invisible.
But when you insert an each you are now exploding the x from being one
item into a bunch of items. It seems like assert cannot accept an
exploded list as one child item. I would say that there are very few
contexts where each is permitted. You can't write a = each list. So it
doesn't seem shocking that the each needs to be outside the assert.
Perhaps Torsten will have a more formal explanation.
On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
Yes, that works, thanks. Not sure why each not allowed after an
assert though?
On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
Problem appears to be the "each". Looks like putting each before
the assert() may work.
On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
discuss@lists.openscad.org> wrote:
The error square in the editor is actually on the space after the
each but if I remove the assert that line is fine.
On Sat, 19 Jul 2025 at 16:56, nop head nop.head@gmail.com wrote:
[for(i = [0 : len(transforms) - 1])
assert(len(profiles[i]) == len(profiles[0]))
let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
each profile4 * transforms[i],
];
On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
discuss@lists.openscad.org> wrote:
On 19.07.25 17:23, nop head via Discuss wrote:
It seems that assert can't be used in a list comprehension? Is
That could be a parser conflict for a specific case as this works
a = [ for (x = [0:10]) assert(x < 10) x ];
echo(a);
So what's the code that fails?
ciao,
Torsten.
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
The inner loop is self-contained though, as it makes a list and assigns it
to a variable, then the list is multiplied by a matrix.
On Sat, 19 Jul 2025 at 19:01, Adrian Mariano via Discuss <
discuss@lists.openscad.org> wrote:
> If you do the other thing then the assert is inside the second loop, so it
> seems pretty obvious it will run many times. This way, it is inside the
> each but outside the inner loop. Why would you expect it to run more than
> once? The assert runs once, and then passes its list argument to each,
> which gets exploded and processed by the list comprehension above. I don't
> see any reason why the assert could run more than once (well, more than
> once each time inside the top level loop).
>
>
> On Sat, Jul 19, 2025 at 1:56 PM nop head via Discuss <
> discuss@lists.openscad.org> wrote:
>
>> Yes, that also works for me. Not sure that it makes any difference though
>> as it is still under the each.
>>
>> On Sat, 19 Jul 2025 at 17:54, Adrian Mariano via Discuss <
>> discuss@lists.openscad.org> wrote:
>>
>>> I was thinking of this, which appears to produce the same result (though
>>> it's hard to be certain since you didn't provide a runable example)
>>>
>>> [for(i = [0 : len(transforms) - 1])
>>> each assert(len(profiles[i]) == len(profiles[0]))
>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>> profile4 * transforms[i],
>>> ];
>>>
>>> which seems to obviously run the assert only once. You could also
>>> insert the assert inside the let with a dummy assignment, or inside the
>>> profile4 assignment, though both are a little ugly.
>>>
>>> On Sat, Jul 19, 2025 at 12:44 PM nop head via Discuss <
>>> discuss@lists.openscad.org> wrote:
>>>
>>>> It isn't clear to me if moving it after the each make the assert
>>>> executed more times or not.
>>>>
>>>> On Sat, 19 Jul 2025 at 17:37, Adrian Mariano via Discuss <
>>>> discuss@lists.openscad.org> wrote:
>>>>
>>>>> If I had to guess I would say that the problem is what does assert
>>>>> do? It passes the "child" object up as a return value. So
>>>>>
>>>>> assert( ...) x
>>>>>
>>>>> is the same as
>>>>>
>>>>> x
>>>>>
>>>>> from the perspective of the calling code, to which the assert is
>>>>> basically invisible.
>>>>>
>>>>> But when you insert an each you are now exploding the x from being one
>>>>> item into a bunch of items. It seems like assert cannot accept an
>>>>> exploded list as one child item. I would say that there are very few
>>>>> contexts where each is permitted. You can't write a = each list. So it
>>>>> doesn't seem shocking that the each needs to be outside the assert.
>>>>>
>>>>> Perhaps Torsten will have a more formal explanation.
>>>>>
>>>>> On Sat, Jul 19, 2025 at 12:25 PM nop head via Discuss <
>>>>> discuss@lists.openscad.org> wrote:
>>>>>
>>>>>> Yes, that works, thanks. Not sure why each not allowed after an
>>>>>> assert though?
>>>>>>
>>>>>> On Sat, 19 Jul 2025 at 17:09, Adrian Mariano via Discuss <
>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>
>>>>>>> Problem appears to be the "each". Looks like putting each before
>>>>>>> the assert() may work.
>>>>>>>
>>>>>>>
>>>>>>> On Sat, Jul 19, 2025 at 12:01 PM nop head via Discuss <
>>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>>
>>>>>>>> The error square in the editor is actually on the space after the
>>>>>>>> each but if I remove the assert that line is fine.
>>>>>>>>
>>>>>>>> On Sat, 19 Jul 2025 at 16:56, nop head <nop.head@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> [for(i = [0 : len(transforms) - 1])
>>>>>>>>> assert(len(profiles[i]) == len(profiles[0]))
>>>>>>>>> let(profile4 = [for(p = profiles[i]) [p.x, p.y, p.z, 1]])
>>>>>>>>> each profile4 * transforms[i],
>>>>>>>>> ];
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sat, 19 Jul 2025 at 16:29, Torsten Paul via Discuss <
>>>>>>>>> discuss@lists.openscad.org> wrote:
>>>>>>>>>
>>>>>>>>>> On 19.07.25 17:23, nop head via Discuss wrote:
>>>>>>>>>> > It seems that assert can't be used in a list comprehension? Is
>>>>>>>>>> this
>>>>>>>>>> > correct, if so, why not?
>>>>>>>>>>
>>>>>>>>>> That could be a parser conflict for a specific case as this works
>>>>>>>>>>
>>>>>>>>>> a = [ for (x = [0:10]) assert(x < 10) x ];
>>>>>>>>>> echo(a);
>>>>>>>>>>
>>>>>>>>>> So what's the code that fails?
>>>>>>>>>>
>>>>>>>>>> ciao,
>>>>>>>>>> Torsten.
>>>>>>>>>> _______________________________________________
>>>>>>>>>> OpenSCAD mailing list
>>>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>> OpenSCAD mailing list
>>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> OpenSCAD mailing list
>>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>>
>>>>>> _______________________________________________
>>>>>> OpenSCAD mailing list
>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>>
>>>>> _______________________________________________
>>>>> OpenSCAD mailing list
>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>>
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>>
>> _______________________________________________
>> OpenSCAD mailing list
>> To unsubscribe send an email to discuss-leave@lists.openscad.org
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to discuss-leave@lists.openscad.org
>
JB
Jordan Brown
Sat, Jul 19, 2025 6:25 PM
The reason why assert() doesn't work in list comprehension contexts is
that the syntax doesn't have it as one of the list comprehension
elements. (There are actually three different kinds of let():
statement, expression, and list comprehension. It's the winner; there
are only two kinds each of assert, echo, for, and if.)
But why not?
I took a quick stab at adding it. Once I stopped making stupid yacc
mistakes, it was fine.
So I think the answer is, very simply, that whoever did list
comprehensions didn't think to add it.
Same for echo().
Quite possibly they thought that the expression variant would be enough,
but that would be missing the case where you want to do the assert() or
echo() and then do a list comprehension element.
Here's a simple case where the expression variant isn't enough:
x = [ assert(true) for(i=[1:5]) i ];
In that simple case you could put the assertion outside the vector, but
in a more complex case you might not be able to.
There's already an issue filed:
Assert causes syntax error at for in function with assert/let/for
#5475 <https://github.com/openscad/openscad/issues/5475>
The reason why assert() doesn't work in list comprehension contexts is
that the syntax doesn't have it as one of the list comprehension
elements. (There are actually three different kinds of let():
statement, expression, and list comprehension. It's the winner; there
are only two kinds each of assert, echo, for, and if.)
But why not?
I took a quick stab at adding it. Once I stopped making stupid yacc
mistakes, it was fine.
So I think the answer is, very simply, that whoever did list
comprehensions didn't think to add it.
Same for echo().
Quite possibly they thought that the expression variant would be enough,
but that would be missing the case where you want to do the assert() or
echo() and then do a list comprehension element.
Here's a simple case where the expression variant isn't enough:
x = [ assert(true) for(i=[1:5]) i ];
In that simple case you could put the assertion outside the vector, but
in a more complex case you might not be able to.
There's already an issue filed:
Assert causes syntax error at for in function with assert/let/for
#5475 <https://github.com/openscad/openscad/issues/5475>