operator new with "value type"

  • Thread starter Thread starter carnold
  • Start date Start date
Ben said:
do-while and switch require the braces

---8<---
class App
{
static void Main()
{
do System.Console.WriteLine(); while(false);
}
}
--->8---

C# switch does require braces, although consider C/C++:

---8<---
int main(void)
{
switch (0);
return 0;
}
--->8---

(I in no way condone use of the above forms; though I'm ambivalent about
requiring {} on if-statement sub-blocks.)

-- Barry
 
Arne said:
Fortran 90/95 ?

Not possible in 66 and 77.


(I know that C++ had such a problem before ANSI standardization)

I don't remember which version of FORTRAN scoped loop variables to the loop
for you, but it was in 1980. The reason was optimization - the loop variable
could be enregistered. The register would be colored by a different variable
immediately after loop exit.
 
Lew said:
I don't remember which version of FORTRAN scoped loop variables to the
loop for you, but it was in 1980. The reason was optimization - the
loop variable could be enregistered. The register would be colored by a
different variable immediately after loop exit.

Are you sure you remember correct ?

Declarations in Fortran (at least the old versions) are always
before executable statements and therefor with subroutine/function
wide scope. I would assume that implicit declared variable would be
the same.

And AFAIK the Fortran standard explicitly define that the loop
variable to be last value + step after the do loop.

Arne
 
Barry Kelly said:
---8<---
class App
{
static void Main()
{
do System.Console.WriteLine(); while(false);
}
}
--->8---

Ok, you win. I have *never* before seen a do-while without braces in either
C#, C++, or plain C.
 
Ok, you win. I have *never* before seen a do-while without braces in either
C#, C++, or plain C.

Neither have I.

But considering that in Pascal you can even do multiple
statements in a repeat until loop without begin end blocks,
then it should not be that surprising.

Arne
 
Arne said:
Neither have I.

But considering that in Pascal you can even do multiple
statements in a repeat until loop without begin end blocks,
then it should not be that surprising.

It isn't like Pascal - in C/etc., the logic is that a *single* statement
is expected between the 'do' and the 'while', so the parser code looks
very roughly like this (in LL recursive descent):

case DO:
Skip(DO);
body = ParseStatement();
Expect(WHILE);
// etc...

It could have been rewritten to something like:

case DO:
Skip(DO);
body = ParseBlockStatement();
Expect(WHILE);
// etc...

.... but it never has, for reasons unknown.

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top