Useless warning....

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

Useless warning....

rew

Hi,

My current(*)  design generates the following warning:

   DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

This doesn't help me find where this happens. (no line number)

(Ceterum autem censeo Carthaginem esse delendam)

I also want to say that I don't agree with this: Often the 0...0 case
means: one copy and 0...-1 means zero copies. Simple.

Say I want to make n fenceposts:

for (i=[0:n-1])
   translate ([pitch*i,0,0]) onepost ();

That works, even for one fencepost.

But now the first fencepost needs to be a bit different:

onepost (first=true);
for (i=[1:n-1])
   translate ([pitch*i,0,0]) onepost (first=false);

Now the one-fence-post case will trigger the warning. To prevent the
warning I need to special case the "regular posts" to the condition
that there ARE regular posts.

        Roger.

(*) I created the design a while ago, I'm mostly a "user" of the
design now. Last time I built some object-A this time I'm building
object-b and somewhere in there there this warning is triggered.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

nophead
Add a step size to get rid of the warming. E.g.  for (i=[1 : 1 : n-1])

On Sat, 8 Aug 2020 at 07:24, Rogier Wolff <[hidden email]> wrote:

Hi,

My current(*)  design generates the following warning:

   DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

This doesn't help me find where this happens. (no line number)

(Ceterum autem censeo Carthaginem esse delendam)

I also want to say that I don't agree with this: Often the 0...0 case
means: one copy and 0...-1 means zero copies. Simple.

Say I want to make n fenceposts:

for (i=[0:n-1])
   translate ([pitch*i,0,0]) onepost ();

That works, even for one fencepost.

But now the first fencepost needs to be a bit different:

onepost (first=true);
for (i=[1:n-1])
   translate ([pitch*i,0,0]) onepost (first=false);

Now the one-fence-post case will trigger the warning. To prevent the
warning I need to special case the "regular posts" to the condition
that there ARE regular posts.

        Roger.

(*) I created the design a while ago, I'm mostly a "user" of the
design now. Last time I built some object-A this time I'm building
object-b and somewhere in there there this warning is triggered.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
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
rew
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

rew
On Sat, Aug 08, 2020 at 09:13:46AM +0100, nop head wrote:
> Add a step size to get rid of the warming. E.g.  for (i=[1 : 1 : n-1])

OK! Thanks for the tip. Where in the code?

Actually, its relatively easy: The code is only 282 lines long.
And there are only three for loops:

240:  for (i=[0:nx-1]) {
241:    for (j=[0:ny-1]) {
257:  for (i=[0:180:180])

nx and ny are both "2" today.

        Roger.

P.S. I just tried adding the implicit :1 and it makes the whole thing
stop working. Without the :1 I get the 4 modules, with the added :1 I
get nothing.

Here is my code:

module m4 (nx=2, ny=2, model=0)
{
  p=75;

  for (i=[0:nx-1]) {   // this is line 240.
    for (j=[0:ny-1]) {
      translate ([i*p,j*p,0]) mymodule (model);
    }
  }
}
...

m4 (nx=2, ny=2, 0);

Note: The m4 module started out doing 2x2 or 4 modules as I'm
rendering/printing today, but since then I added the parameters but
have not changed the name.




> On Sat, 8 Aug 2020 at 07:24, Rogier Wolff <[hidden email]> wrote:
>
> >
> > Hi,
> >
> > My current(*)  design generates the following warning:
> >
> >    DEPRECATED: Using ranges of the form [begin:end] with begin value
> > greater than the end value is deprecated.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

rew
On Sat, Aug 08, 2020 at 10:36:55AM +0200, Rogier Wolff wrote:
> nx and ny are both "2" today.
>
> Roger.
>
> P.S. I just tried adding the implicit :1 and it makes the whole thing
> stop working. Without the :1 I get the 4 modules, with the added :1 I
> get nothing.

I just implemented a "full program" that shows this problem.
Below is the code, no warning, not working, remove the :1 and
it does what I expect of it.


module mymodule (model)
{
  cylinder (d=65,h=10);
}

module m4 (nx=2, ny=2, model=0)
{
  p=75;

  for (i=[0:1:nx-1]) {   // this is line 240.
    for (j=[0:ny-1]) {
      translate ([i*p,j*p,0]) mymodule (model);
    }
  }
}

m4 (nx=2, ny=2, 0);



--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

nophead
Sorry, in your case nx is zero so it is looping from 0 to -1, so a negative step would get rid of the warning.

I think you meant to set model to 0 but it is actually setting nx to zeo.



On Sat, 8 Aug 2020 at 09:43, Rogier Wolff <[hidden email]> wrote:
On Sat, Aug 08, 2020 at 10:36:55AM +0200, Rogier Wolff wrote:
> nx and ny are both "2" today.
>
>       Roger.
>
> P.S. I just tried adding the implicit :1 and it makes the whole thing
> stop working. Without the :1 I get the 4 modules, with the added :1 I
> get nothing.

I just implemented a "full program" that shows this problem.
Below is the code, no warning, not working, remove the :1 and
it does what I expect of it.


module mymodule (model)
{
  cylinder (d=65,h=10);
}

module m4 (nx=2, ny=2, model=0)
{
  p=75;

  for (i=[0:1:nx-1]) {   // this is line 240.
    for (j=[0:ny-1]) {
      translate ([i*p,j*p,0]) mymodule (model);
    }
  }
}

m4 (nx=2, ny=2, 0);



--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
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
rew
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

rew
On Sat, Aug 08, 2020 at 09:59:01AM +0100, nop head wrote:
> Sorry, in your case nx is zero so it is looping from 0 to -1, so a negative
> step would get rid of the warning.
>
> I think you meant to set model to 0 but it is actually setting nx to zeo.

So me redundantly specifying the name of the first and second
parameter causes the third parameter (of the call) to overwrite the
just explicitly specified-by-name first parameter (of the called
module)?????? You're shitting me, right?

Now that's something what might warrant a warning if not a rewrite to
change that behaviour....

        Roger.

> > module m4 (nx=2, ny=2, model=0)
...
> > m4 (nx=2, ny=2, 0);

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

nophead
Yes the first unnamed parameter is assigned to position 1 and so on. In Python you get "SyntaxError: positional argument follows keyword argument"

On Sat, 8 Aug 2020 at 12:25, Rogier Wolff <[hidden email]> wrote:
On Sat, Aug 08, 2020 at 09:59:01AM +0100, nop head wrote:
> Sorry, in your case nx is zero so it is looping from 0 to -1, so a negative
> step would get rid of the warning.
>
> I think you meant to set model to 0 but it is actually setting nx to zeo.

So me redundantly specifying the name of the first and second
parameter causes the third parameter (of the call) to overwrite the
just explicitly specified-by-name first parameter (of the called
module)?????? You're shitting me, right?

Now that's something what might warrant a warning if not a rewrite to
change that behaviour....

        Roger.

> > module m4 (nx=2, ny=2, model=0)
...
> > m4 (nx=2, ny=2, 0);

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
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: Useless warning....

JordanBrown
In reply to this post by rew
On 8/7/2020 11:23 PM, Rogier Wolff wrote:
   DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

This doesn't help me find where this happens. (no line number)

(Ceterum autem censeo Carthaginem esse delendam)

I also want to say that I don't agree with this: Often the 0...0 case
means: one copy and 0...-1 means zero copies. Simple.

That would be good.  But the historical behavior is that it just reverses the two endpoints.  Pretty much everybody agrees that's not desirable, hence the warning.

for (i=[3:1]) echo(i);

DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

ECHO: 1

ECHO: 2

ECHO: 3



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

Re: Useless warning....

MichaelAtOz
Administrator

(test - pls ignore)

 


From: Discuss [mailto:[hidden email]] On Behalf Of Jordan Brown
Sent: Sun, 9 Aug 2020 13:20
To: OpenSCAD general discussion; Rogier Wolff
Subject: Re: [OpenSCAD] Useless warning....

 

On 8/7/2020 11:23 PM, Rogier Wolff wrote:

   DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.
 
This doesn't help me find where this happens. (no line number)
 
(Ceterum autem censeo Carthaginem esse delendam)
 
I also want to say that I don't agree with this: Often the 0...0 case
means: one copy and 0...-1 means zero copies. Simple.


That would be good.  But the historical behavior is that it just reverses the two endpoints.  Pretty much everybody agrees that's not desirable, hence the warning.

for (i=[3:1]) echo(i);
 
DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

ECHO: 1

ECHO: 2

ECHO: 3

 


Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

nophead
Yes, the new behaviour makes more sense as I can't remember a writing a loop where I wanted to go in both directions. And now we don't need an if to test for the empty case.

I.e.
if(n) for(i = [0 : n - 1]) ...

becomes

for(i = [0 : 1 : n - 1]) ...

and in Rogier's case the warning found another bug, because the loop was actually running 0, -1 instead of 0, 1

On Sun, 9 Aug 2020 at 07:40, OzAtMichael <[hidden email]> wrote:

(test - pls ignore)

 


From: Discuss [mailto:[hidden email]] On Behalf Of Jordan Brown
Sent: Sun, 9 Aug 2020 13:20
To: OpenSCAD general discussion; Rogier Wolff
Subject: Re: [OpenSCAD] Useless warning....

 

On 8/7/2020 11:23 PM, Rogier Wolff wrote:

   DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.
 
This doesn't help me find where this happens. (no line number)
 
(Ceterum autem censeo Carthaginem esse delendam)
 
I also want to say that I don't agree with this: Often the 0...0 case
means: one copy and 0...-1 means zero copies. Simple.


That would be good.  But the historical behavior is that it just reverses the two endpoints.  Pretty much everybody agrees that's not desirable, hence the warning.

for (i=[3:1]) echo(i);
 
DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated.

ECHO: 1

ECHO: 2

ECHO: 3

 


Virus-free. www.avg.com
_______________________________________________
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
rew
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

rew
In reply to this post by nophead
On Sat, Aug 08, 2020 at 12:42:06PM +0100, nop head wrote:
> Yes the first unnamed parameter is assigned to position 1 and so on. In
> Python you get "SyntaxError: positional argument follows keyword argument"

Warning, error, yes, that would seem appropriate to me.

Or a change of "the rules".

The first unnamed parameter goes to the first parameter that is not
already specified.

Or: If there is a named parameter, but if unnamed, that would've
assigned to the same parameter, count it as unnamed. Or said in
another way: If the name is redundant, count as an unnamed parameter.

IMHO it is stiffling for the language if bad decisions from the past
need to be kept intact.

Maybe the compatibility guys should get their way with a
$scad_version=1; default but when set to 2, then some of these
historical bugs can be fixed....

        Roger.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

MichaelAtOz
Administrator
It is not a bug, it is how the language operates.
I don't mean offence, but just because you don't know the language, doesn't mean everyone and all
past programs must change.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Rogier Wolff
> Sent: Sun, 9 Aug 2020 19:49
> To: OpenSCAD general discussion
> Subject: Re: [OpenSCAD] Useless warning....
>
> On Sat, Aug 08, 2020 at 12:42:06PM +0100, nop head wrote:
> > Yes the first unnamed parameter is assigned to position 1 and so on. In
> > Python you get "SyntaxError: positional argument follows keyword argument"
>
> Warning, error, yes, that would seem appropriate to me.
>
> Or a change of "the rules".
>
> The first unnamed parameter goes to the first parameter that is not
> already specified.
>
> Or: If there is a named parameter, but if unnamed, that would've
> assigned to the same parameter, count it as unnamed. Or said in
> another way: If the name is redundant, count as an unnamed parameter.
>
> IMHO it is stiffling for the language if bad decisions from the past
> need to be kept intact.
>
> Maybe the compatibility guys should get their way with a
> $scad_version=1; default but when set to 2, then some of these
> historical bugs can be fixed....
>
> Roger.
>
> --
> ** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
> **    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
> The plan was simple, like my brother-in-law Phil. But unlike
> Phil, this plan just might work.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
This email has been checked for viruses by AVG.
https://www.avg.com


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

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.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

nophead
I expect the Python team has put a lot more thought into it and made it a syntax error because it is error prone and confusing to put named arguments before unnamed ones. OpenSCAD should probably add a warning or at least warn when an argument is assigned twice.

On Sun, 9 Aug 2020 at 11:32, OzAtMichael <[hidden email]> wrote:
It is not a bug, it is how the language operates.
I don't mean offence, but just because you don't know the language, doesn't mean everyone and all
past programs must change.

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of Rogier Wolff
> Sent: Sun, 9 Aug 2020 19:49
> To: OpenSCAD general discussion
> Subject: Re: [OpenSCAD] Useless warning....
>
> On Sat, Aug 08, 2020 at 12:42:06PM +0100, nop head wrote:
> > Yes the first unnamed parameter is assigned to position 1 and so on. In
> > Python you get "SyntaxError: positional argument follows keyword argument"
>
> Warning, error, yes, that would seem appropriate to me.
>
> Or a change of "the rules".
>
> The first unnamed parameter goes to the first parameter that is not
> already specified.
>
> Or: If there is a named parameter, but if unnamed, that would've
> assigned to the same parameter, count it as unnamed. Or said in
> another way: If the name is redundant, count as an unnamed parameter.
>
> IMHO it is stiffling for the language if bad decisions from the past
> need to be kept intact.
>
> Maybe the compatibility guys should get their way with a
> $scad_version=1; default but when set to 2, then some of these
> historical bugs can be fixed....
>
>       Roger.
>
> --
> ** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
> **    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
> The plan was simple, like my brother-in-law Phil. But unlike
> Phil, this plan just might work.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
This email has been checked for viruses by AVG.
https://www.avg.com


_______________________________________________
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
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Useless warning....

tp3
On 09.08.20 13:01, nop head wrote:
> OpenSCAD should probably add a warning or at least warn
> when an argument is assigned twice.

That sounds like a good idea.

I still want to point out the irony of that thread, starting
with title "Useless warning" where the warning actually did
point out a bug in the original code and resulting in the
request for yet more warnings to be added.

To also put some positive notes into this thread, thanks
Nophead for the helpful and detailed answers. I'm sure it's
not just me appreciating that.

Anyway, there's also some work going on in scope of this
years GSoC which will bring an additional view for warnings
and errors.
See https://github.com/openscad/openscad/issues/3388 for
a screenshot of the initial prototype. This is supposed to
not just bring a new view but also extend the infrastructure
to group warnings by some topic and even ultimately support
for them to be enabled/disabled.

ciao,
  Torsten.

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

Re: Useless warning....

JordanBrown
In reply to this post by nophead
On 8/9/2020 12:08 AM, nop head wrote:
Yes, the new behaviour makes more sense as I can't remember a writing a loop where I wanted to go in both directions. And now we don't need an if to test for the empty case.

In 2019.05, it warns but uses the old behavior.  Do the newer builds switch behavior?


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

Re: Useless warning....

rew
In reply to this post by MichaelAtOz
On Sun, Aug 09, 2020 at 08:31:05PM +1000, OzAtMichael wrote:
> It is not a bug, it is how the language operates.  I don't mean
> offence, but just because you don't know the language, doesn't mean
> everyone and all past programs must change.

Languages need to be used by people. People expect certain things. Maybe
because they know other languages, maybe because of a generic expectation
of how things should work.

Now with
  for (i=[5:2])
there is some real functionality: you can iterate from high to low, so
it is understandable that the language has a feature like this.

From generic "knowledge about languages" however I would expect
 for (variable = [start : end ]  )

to be a shorthand for:
 for (variable = [start : 1 : end ] )

i.e. the stepsize defaults to 1. However in openscad that is not true:
The compiler will decide when the end is lower than start that the
default for the stepsize can be -1 too! That is such unexpected
feature of the language that it generates a warning: if you really
want this specify a -1 step.

With the positional arguments overwriting named arguments specified
earlier: I can't see a normal use for that. Sure you can think up a
convoluted example where you can make use of the feature, but I don't
see any serious use for this.

I would say a warning is just as warranted as in the for loop
boundaries case.

Just to make sure that we're on the same page: I called that warning
"useless" because it didn't include teh line number of my program where
it found the problem. Should be an easy fix.

        Roger.

>
> > -----Original Message-----
> > From: Discuss [mailto:[hidden email]] On Behalf Of Rogier Wolff
> > Sent: Sun, 9 Aug 2020 19:49
> > To: OpenSCAD general discussion
> > Subject: Re: [OpenSCAD] Useless warning....
> >
> > On Sat, Aug 08, 2020 at 12:42:06PM +0100, nop head wrote:
> > > Yes the first unnamed parameter is assigned to position 1 and so on. In
> > > Python you get "SyntaxError: positional argument follows keyword argument"
> >
> > Warning, error, yes, that would seem appropriate to me.
> >
> > Or a change of "the rules".
> >
> > The first unnamed parameter goes to the first parameter that is not
> > already specified.
> >
> > Or: If there is a named parameter, but if unnamed, that would've
> > assigned to the same parameter, count it as unnamed. Or said in
> > another way: If the name is redundant, count as an unnamed parameter.
> >
> > IMHO it is stiffling for the language if bad decisions from the past
> > need to be kept intact.
> >
> > Maybe the compatibility guys should get their way with a
> > $scad_version=1; default but when set to 2, then some of these
> > historical bugs can be fixed....
> >
> > Roger.
> >
> > --
> > ** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
> > **    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
> > The plan was simple, like my brother-in-law Phil. But unlike
> > Phil, this plan just might work.
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Useless warning....

JordanBrown
On 8/9/2020 11:46 AM, Rogier Wolff wrote:
Now with
  for (i=[5:2]) 

there is some real functionality: you can iterate from high to low, so it is understandable that the language has a feature like this.

From generic "knowledge about languages" however I would expect

 for (variable = [start : end ]  )

to be a shorthand for:

 for (variable = [start : 1 : end ] ) 

i.e. the stepsize defaults to 1. However in openscad that is not true: The compiler will decide when the end is lower than start that the default for the stepsize can be -1 too! That is such unexpected feature of the language that it generates a warning: if you really want this specify a -1 step.


It doesn't set the default stepsize to -1.  It swaps the start and end.  This is from a development build from December:
for (i=[5:2]) echo(i);
DEPRECATED: Using ranges of the form [begin:end] with begin value greater than the end value is deprecated, in file loops.scad, line 1 

ECHO: 2

ECHO: 3

ECHO: 4

ECHO: 5

It almost doesn't matter.  Other than through "side effects" like echo() and errors, I don't immediately know how to tell what order OpenSCAD modules execute in, and thus what order its loops execute in.  As long as it hits all of the expected values, it could execute them in random order and the results would be the same.  How's that for "strange language behavior"?
Note:  I'm not saying that this is good, or bad... just interesting.  OpenSCAD is not a general-purpose language.  It's about producing 3D models, and based on that and some of its architectural decisions you get some unobvious effects.  Some of that is actively good:  because loop iterations are defined to be totally independent of one another, they could all be executed and rendered in parallel.  (OpenSCAD doesn't do that, but it could.)
Note that development builds have the file-and-line information that you're looking for.


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