Jump to page: 1 211  
Page
Thread overview
why ; ?
May 05, 2008
Tomasz Sowinski
May 05, 2008
Robert Fraser
May 05, 2008
Tomasz Sowinski
May 05, 2008
BCS
May 05, 2008
Tom
May 06, 2008
Michael Neumann
May 06, 2008
Daniel Giddings
May 07, 2008
Janice Caron
May 07, 2008
sambeau
May 07, 2008
Leandro Lucarella
May 07, 2008
bearophile
May 07, 2008
bearophile
May 07, 2008
Janice Caron
May 07, 2008
Leandro Lucarella
May 08, 2008
Janice Caron
May 08, 2008
Nick Sabalausky
May 08, 2008
Janice Caron
May 08, 2008
Gilles G.
May 08, 2008
Janice Caron
May 09, 2008
Bruce Adams
May 08, 2008
Michael Neumann
May 08, 2008
Nick Sabalausky
May 08, 2008
terranium
May 08, 2008
Janice Caron
May 08, 2008
Nick Sabalausky
May 08, 2008
Edward Diener
May 09, 2008
Bruce Adams
May 14, 2008
user
May 08, 2008
Janice Caron
May 08, 2008
Michael Neumann
May 08, 2008
Nick Sabalausky
May 09, 2008
Bruce Adams
May 10, 2008
Michael Neumann
May 10, 2008
Bruce Adams
May 08, 2008
terranium
May 08, 2008
Michael Neumann
May 08, 2008
Nick Sabalausky
May 08, 2008
Michael Neumann
May 08, 2008
Nick Sabalausky
Instance variables with @ (was: Re: why ; ?)
May 09, 2008
Michael Neumann
May 09, 2008
Nick Sabalausky
May 09, 2008
Bruce Adams
May 09, 2008
Bruce Adams
May 09, 2008
Bruce Adams
May 08, 2008
terranium
May 09, 2008
terranium
May 09, 2008
Michael Neumann
May 09, 2008
terranium
May 09, 2008
Bruce Adams
May 10, 2008
Michael Neumann
May 09, 2008
bearophile
May 09, 2008
Bruce Adams
May 08, 2008
Leandro Lucarella
May 08, 2008
Janice Caron
May 08, 2008
Jesse Phillips
May 08, 2008
Leandro Lucarella
May 09, 2008
Janice Caron
May 12, 2008
Leandro Lucarella
May 12, 2008
Janice Caron
May 08, 2008
Nick Sabalausky
May 06, 2008
Nick Sabalausky
May 07, 2008
terranium
May 05, 2008
downs
May 05, 2008
naryl
May 05, 2008
BCS
May 05, 2008
Sascha Katzner
May 05, 2008
Tomasz Sowinski
May 05, 2008
BCS
May 05, 2008
Tomasz Sowinski
May 05, 2008
Jesse Phillips
May 05, 2008
Robert Fraser
May 06, 2008
Walter Bright
May 05, 2008
BCS
May 05, 2008
Bruce Adams
May 05, 2008
Tomasz Sowinski
May 06, 2008
Walter Bright
May 05, 2008
Walter Bright
May 05, 2008
bearophile
May 05, 2008
Tomasz Sowinski
May 05, 2008
bearophile
May 06, 2008
Nick Sabalausky
May 06, 2008
Bill Baxter
May 06, 2008
Walter Bright
May 08, 2008
Don
May 08, 2008
Michael Neumann
May 08, 2008
Nick Sabalausky
May 09, 2008
Don
May 09, 2008
Michael Neumann
May 09, 2008
Don
May 09, 2008
bearophile
May 09, 2008
Nick Sabalausky
May 09, 2008
bearophile
May 09, 2008
Nick Sabalausky
May 09, 2008
bearophile
May 09, 2008
Michael Neumann
May 05, 2008
J Duncan
May 05, 2008
Koroskin Denis
May 05, 2008
Walter Bright
May 06, 2008
Tower Ty
May 06, 2008
Tower Ty
May 06, 2008
janderson
May 05, 2008
Just another feature thought. Never gonna happen, but still...

What's the reason of having lines end with a semicolon? Anything else than a legacy issue with C/C++?

The only thing I can think of is having multiple statements in one line, but that only makes code unreadable. Wouldn't getting rid of ; improve readability?


Tomek
May 05, 2008
Tomasz Sowinski wrote:
> Just another feature thought. Never gonna happen, but still...
> 
> What's the reason of having lines end with a semicolon? Anything else than a legacy issue with C/C++?
> 
> The only thing I can think of is having multiple statements in one line, but that only makes code unreadable. Wouldn't getting rid of ; improve readability?
> 
> 
> Tomek

So the end of a statement would be marked by a newline character a la Python?

I usually like to keep my lines under 80 characters long for readability, and occasionally have long statements (especially if there's a ternary operator in there somewhere), so my vote is "nay". There are various other arguments against it, too (especially in that it makes parsing easier).
May 05, 2008
Robert Fraser Wrote:

> So the end of a statement would be marked by a newline character a la Python?

yes

> I usually like to keep my lines under 80 characters long for readability, and occasionally have long statements (especially if there's a ternary operator in there somewhere), so my vote is "nay".

Maybe a breakline symbol like in Ruby or VB for long statements?

> There are various other arguments against it, too (especially in that it makes parsing easier).

There is a meaningful newline character anyway to know where the // comment ends, so would removing ; make a big difference in parsing?

I'm not arguing. As I said, I know it's never going to happen, I was just curious about those "other various arguments".
May 05, 2008
Robert Fraser wrote:
> Tomasz Sowinski wrote:
>> Just another feature thought. Never gonna happen, but still...
>>
>> What's the reason of having lines end with a semicolon? Anything else than a legacy issue with C/C++?
>>
>> The only thing I can think of is having multiple statements in one line, but that only makes code unreadable. Wouldn't getting rid of ; improve readability?
>>
>>
>> Tomek
> 
> So the end of a statement would be marked by a newline character a la Python?

Why mark the end of statements at all?

Couldn't it be possible to have the compiler deduce the end of a statement automatically, by parsing as much as it can and then stopping?

void main() { writefln("Hello World") int a float b = 4 writefln(a, " - ", b) return 0 }
> 
> I usually like to keep my lines under 80 characters long for readability, and occasionally have long statements (especially if there's a ternary operator in there somewhere), so my vote is "nay". There are various other arguments against it, too (especially in that it makes parsing easier).

I vote in favor, as long as I can do multiple statements per line. It's useful sometimes. Maybe support "; "  as a fallback?

 --downs
May 05, 2008
Tomasz Sowinski wrote:
> What's the reason of having lines end with a semicolon? Anything else
> than a legacy issue with C/C++?
> 
> The only thing I can think of is having multiple statements in one
> line, but that only makes code unreadable. Wouldn't getting rid of ;
> improve readability?

No, you would never know if a statement is just a continuation from the previous line or actually a new one.

An example:

	int i
	for (i=0; i<10; i++)
	writefln(i)

Should this print all numbers from 1 to 9 or simply increment i ten times and print "10"?

The only exception to this are IMO inline assembly statements, the semicolons there are unnecessary and ugly. And since I'm accustomed to write assembly without semicolons at the end I continuously forget them. ;)

[X] Vote to kick semicolons in asm statements!

LLAP,
Sascha
May 05, 2008
On Mon, 05 May 2008 09:13:48 +0100, Tomasz Sowinski <tomeksowi@gmail.com> wrote:

>
> Just another feature thought. Never gonna happen, but still...
>
> What's the reason of having lines end with a semicolon? Anything else than a legacy issue with C/C++?
>
> The only thing I can think of is having multiple statements in one line, but that only makes code unreadable. Wouldn't getting rid of ; improve readability?
>
>
> Tomek

There is always going to be a trade off between having to mark the end of a statement using ";"
or having to escape newlines. Otherwise a language becomes horrendously difficult to parse.
The rules for when you really need to end a statement would look even stranger if you only needed
to do it for particular statements in particular contexts. Perhaps you could have the best of both
worlds with a statementiser that knew more about typography and layout. Then your heading back along
the python path. Either way the keep is simple rule applies. If its easier for a compiler to grok
it might well be easier for a human to grok too and visa versa.
May 05, 2008
On Mon, 05 May 2008 13:25:17 +0400, downs <default_357-line@yahoo.de> wrote:

> I vote in favor, as long as I can do multiple statements per line. It's useful sometimes. Maybe support "; "  as a fallback?
>
>  --downs

<g> You are reinventing the Scala language here.
May 05, 2008
Sascha Katzner Wrote:

> An example:
> 
> 	int i
> 	for (i=0; i<10; i++)
> 	writefln(i)
> 
> Should this print all numbers from 1 to 9 or simply increment i ten times and print "10"?

The former. For the latter the it should be
    for (i=0; i<10; i++) {}
    writefln(i)

btw, can you make a loop without any statement in D? I think no...
Anyway, I don't see the benefit of putting or not putting a semicolon there.
May 05, 2008
Bruce Adams Wrote:

> There is always going to be a trade off between having to mark the end of
> a statement using ";"
> or having to escape newlines. Otherwise a language becomes horrendously
> difficult to parse.

Can you give some examples of the difficulties?
I'm not into parsing issues really, so maybe I'll learn a thing or two.
May 05, 2008
"Tomasz Sowinski" <tomeksowi@gmail.com> wrote in message news:fvmfjs$q4n$1@digitalmars.com...
>
> Just another feature thought. Never gonna happen, but still...
>
> What's the reason of having lines end with a semicolon? Anything else than a legacy issue with C/C++?
>
> The only thing I can think of is having multiple statements in one line, but that only makes code unreadable. Wouldn't getting rid of ; improve readability?

I don't like semicolons.  To that end, I have changed statement terminators in my scripting language to accept semicolons or newlines.  Having a C-style syntax, it's been a sort of interesting experiment to see what ambiguities arise in the C syntax without them.

The language has not dropped semicolons entirely, it's just made it possible to skip them at the end of lines.  If you want multiple statements on one line, you still have to separate them with semicolons.

There are really only two places in the grammar where there are possible parsing ambiguities:

1) Return statements.  Does:

return
f()

parse as "return f();", or does it parse as a "return;" followed by a function call?  I have it parse as the latter, as that makes the most sense to me.

2) Function calls vs. parenthesized expressions.  Does:

x = f
(g + h).i()

parse as "x = f(g + h).i();" or as "x = f; (g + h).i();" ?  I have this give a parsing error since one way or the other doesn't really make sense.  In order to resolve the ambiguity, you either have to put a semicolon after the first statement to make it 2 statements, or move the open paren up to the first line to make it one.

Other than these two cases, I haven't run into any other tricky parsing spots.  Granted, the language is simpler than D and doesn't have nearly as many statements, but it doesn't seem like there would be any other difficulties in parsing.

The one major downside to this change in the grammar, however, is that it makes lexical analysis dependent upon syntactic analysis, since the significance of newlines depends upon the current construct being parsed.  D prides itself on having no such interdependencies, and you'd be hard-pressed to convince Walter to do otherwise.


« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11