Thread overview
[Issue 11488] Disallow chaining of - operator
[Issue 11488] FORTRAN "FORI=" Error
Jan 30, 2015
Stewart Gordon
Feb 01, 2015
Manfred Nowak
Feb 01, 2015
Stewart Gordon
Feb 01, 2015
Manfred Nowak
Feb 01, 2015
Stewart Gordon
Feb 01, 2015
Iain Buclaw
Feb 01, 2015
Stewart Gordon
Dec 27, 2019
berni44
Dec 17, 2022
Iain Buclaw
January 30, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com

--- Comment #1 from Stewart Gordon <smjg@iname.com> ---
This would undesirably prevent - from being being chained with any unary operator, not just another -.

I can't see such an error as being likely to occur.  If you mean the -- operator, how would a space between the two minuses creep in by accident?

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

--- Comment #2 from Manfred Nowak <svv1999@hotmail.com> ---
(In reply to Stewart Gordon from comment #1)

If chaining of "-", "--". "+" and "++" is used heavily, then disallowing to shoot oneself is okay. Hint: "- -- -- -- - --- -- - -- ---- - -- - --x" is currently a legal expression and I doubt that one can _see_ in general the positions at which a significant space is wrongly placed or deleted. Disallowing chaining requires to use paired paranthesis in such cases, which doubles the number of wrongly placed characters needed to make an error slip through.

BTW: allowing such chaining makes D similar to an esoteric language.

If chaining of those operators will never be used heavily, then there is no ratio for allowing the chaining.

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|FORTRAN "FORI=" Error       |Disallow chaining of -
                   |                            |operator

--- Comment #3 from Stewart Gordon <smjg@iname.com> ---
(In reply to Manfred Nowak from comment #2)
> If chaining of "-", "--". "+" and "++" is used heavily, then disallowing to shoot oneself is okay. Hint: "- -- -- -- - --- -- - -- ---- - -- - --x" is currently a legal expression and I doubt that one can _see_ in general the positions at which a significant space is wrongly placed or deleted.

But how would such an expression find its way into real-world code in the first place?

> If chaining of those operators will never be used heavily, then there is no ratio for allowing the chaining.

In my mind, this is all the more reason that it isn't worth disallowing it and
thereby (a) adding extra complexity to the parser (b) precluding legitimate,
non-error-prone use cases.

Also, what does `FORTRAN "FORI=" Error` mean?  I used Fortran for a few years, and never came across the term.  Probably a lot of people here have never used Fortran, and have even less idea what it means.  As such, I'm changing the summary line to make sense to D programmers.

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

--- Comment #4 from Manfred Nowak <svv1999@hotmail.com> ---
(In reply to Stewart Gordon from comment #3)

> But how would such an expression find its way into real-world code in the first place?
I did show by example, that chaining "-" and "--" is not tolerable. An analog example holds for "+" and "++". Its the burdon of the language designer to give the ratio for allowing such constructs.

> In my mind,
I agree, that our thinking differs.

> Also, what does `FORTRAN "FORI=" Error` mean?
Maybe its an urban legend that made it into a university. According to that university talk in a fortran-program the space between the `for' and the index-variable `i' was lost. Thereby declaring and assigning the variable `fori' instead of introducing a loop---with fatal consequences for a space-ship.

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

--- Comment #5 from Stewart Gordon <smjg@iname.com> ---
(In reply to Manfred Nowak from comment #4)
> I did show by example, that chaining "-" and "--" is not tolerable. An analog example holds for "+" and "++". Its the burdon of the language designer to give the ratio for allowing such constructs.

What do you mean by "the ratio for allowing such constructs"?

>> Also, what does `FORTRAN "FORI=" Error` mean?
> Maybe its an urban legend that made it into a university. According to that university talk in a fortran-program the space between the `for' and the index-variable `i' was lost. Thereby declaring and assigning the variable `fori' instead of introducing a loop---with fatal consequences for a space-ship.

I see.  But does Fortran have the FOR keyword?  I've just had a look and been reminded that Fortran uses DO for for-loops - none of the online sources I've found mention FOR as alternative syntax.  But it seems to me that the cause of this was a failure to test the software properly - something that is needed regardless of what language it is written in.

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #6 from Iain Buclaw <ibuclaw@gdcproject.org> ---
It looks like the grammar does allow this, but fails semantic because in the following expression, -x is not an lvalue (probably an implementation detail though).

-- -x;


More complex examples expose artificial variables in errors, so that is definitely a bug.

--
February 01, 2015
https://issues.dlang.org/show_bug.cgi?id=11488

--- Comment #7 from Stewart Gordon <smjg@iname.com> ---
(In reply to Iain Buclaw from comment #6)
> It looks like the grammar does allow this, but fails semantic because in the following expression, -x is not an lvalue (probably an implementation detail though).
> 
> -- -x;

For primitive types, this should never pass.  However, it's potentially possible for it to work on struct/class objects that have this overloaded.  But even then, such a long-winded example as Manfred posted is highly unlikely to find its way into real-world code.

--
December 27, 2019
https://issues.dlang.org/show_bug.cgi?id=11488

berni44 <bugzilla@d-ecke.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@d-ecke.de
          Component|dlang.org                   |dmd

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=11488

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4

--