www.digitalmars.com         C & C++   DMDScript  

D - suggestion

reply imr1984 <imr1984_member pathlink.com> writes:
the other day i was studying assembly programming, and it struck me - why does D
need semicolons after statements at all? they seem like a waste of time.

I think statements should be seperated by new lines OR semicolons, so that
existing D code will still work.

Ive been programming C style languages for years now and i still often forget a
semicolon - so i think this would be a big time saver, as well as making the
code more readable
Mar 10 2004
next sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
imr1984 wrote:

I think statements should be seperated by new lines OR semicolons, so that
existing D code will still work.
  
I agree, although I'd still like to use semicolons now-and-then, having them optional would be great. -- -Anderson: http://badmama.com.au/~anderson/
Mar 10 2004
next sibling parent imr1984 <imr1984_member pathlink.com> writes:
cool - someone agrees with me :) Walter what do you think?

In article <c2n4nj$m6p$1 digitaldaemon.com>, J Anderson says...
imr1984 wrote:

I think statements should be seperated by new lines OR semicolons, so that
existing D code will still work.
  
I agree, although I'd still like to use semicolons now-and-then, having them optional would be great. -- -Anderson: http://badmama.com.au/~anderson/
Mar 10 2004
prev sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
J Anderson wrote:

 imr1984 wrote:

 I think statements should be seperated by new lines OR semicolons, so 
 that
 existing D code will still work.
  
I agree, although I'd still like to use semicolons now-and-then, having them optional would be great.
I would also: add that semicolons are just another small redundancy (most of the time) for the programmer. Removing redundancies makes code just a little bit easier for coders. -- -Anderson: http://badmama.com.au/~anderson/
Mar 10 2004
parent Charles Hixson <charleshixsn earthlink.net> writes:
J Anderson wrote:
 J Anderson wrote:
 
 imr1984 wrote:

 I think statements should be seperated by new lines OR semicolons, so 
 that
 existing D code will still work.
  
I agree, although I'd still like to use semicolons now-and-then, having them optional would be great.
I would also: add that semicolons are just another small redundancy (most of the time) for the programmer. Removing redundancies makes code just a little bit easier for coders.
Do note, however, that removing reduncancies also increases the probability that a random change won't be detected as an error. A part of the art of language design is deciding on the correct amount of reduncancy. In this case Walter decided on a choice that made things easy for the parser. Many of his choices were made on those grounds. D is intended to be parseable purely syntactically, without the need for any semantic knowledge, or any non-local knowledge, e.g.
Mar 10 2004
prev sibling next sibling parent Manfred Nowak <svv1999 hotmail.com> writes:
imr1984 wrote:

[...]
 I think statements should be seperated by new lines OR semicolons, so
 that existing D code will still work.
[...] Ouch! You forgot to introduce the line continuation character. I am used to see function calls formatted over several lines. More extensions in the c-- style? So long.
Mar 10 2004
prev sibling next sibling parent Ant <duitoolkit yahoo.ca> writes:
On Wed, 10 Mar 2004 13:16:35 +0000, imr1984 wrote:

 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
 
 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.
 
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, as well as making the
 code more readable
Once I designed and implemented a language (mix of C and Pascal see past posts) and it didn't had any statment separators. int f(int i) { f = i * 2 } int a int b a=1 b=2 a = a + b * f(b) + 47 there is no confusion there! the prove that the semicolon aren't needed is that the compiler can warn you when they are missing I just convinced dmd to produce the message: "semicolon expected, not 'public'" I see the semicolon as a control so that both the human and the compiler are sure they are talking about the same thing. a = b f() that would be valid and interpreted (on my language) as a = b; f(); but you might wanted to say a = b + f(); and now for a missing key stroke you have a bug... let's keep them. now the IDE might help you to put a semicolon at the end of the line (I'm NOT planing that for leds). eclipse JDT goes half way: when you press ";" anywhere on the line it will placed at the end of the line (this for sure would be good on leds). Ant
Mar 10 2004
prev sibling next sibling parent Andy Friesen <andy ikagames.com> writes:
imr1984 wrote:

 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
They make the parser easier to implement, basically.
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, as well as making the
 code more readable
Python does exactly this. When the parser encounters an open bracket/brace/parenth, it ignores newlines until it's closed. a = b + c // no good, need a \ at the end of the previous line a = (b + c) // ok blah(a, b, c) // also ok a = b + c // Legal, but probably not what the programmer means! While I think it's the Right Thing, this could really throw off C coders who are used to whitespace being completely ignored. -- andy
Mar 10 2004
prev sibling next sibling parent reply =?ISO-8859-1?Q?Sigbj=F8rn_Lund_Olsen?= <sigbjorn lundolsen.net> writes:
imr1984 wrote:
 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
 
 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.
 
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, as well as making the
 code more readable
I personally find the semi-colons rather useful when needing to split a really large statement over several lines. If you've ever programmed using the Windows API you will know what I mean. (Someone ought to be shot for that festering turd of an API.) The first programming language I used (and discarded) was Visual Basic, which used newlines for statement separation. There you needed to use an underscore (IIRC) to join several lines into one statement. I don't know, it's possibly a matter of taste, but I prefer the semicolons. Yes, I forget them from time to time, but the compiler will notify me when it hits something else when its expecting a semi-colon, so it's not a problem. Hmm. FYI, and because I'm waiting for my downloads to end (never happens). The most annoying syntax error I tend to make is when I forget to close a literal string somewhere. Mind, I only do this when I use PHP - never had this problem elsewhere, probably because I use less literal strings elsewhere. At any rate, while PHP tends to output fairly good error messages (certainly better than any other "compiler" I've ever used including dmd at the moment, but hopefully not forever(?)) in this case it just cannot figure out the whereabouts of the error, so I usually end up checking ever singly literal string I've written. (I should really run scripts/compile a lot more often, it's a bad habit of mine to write 200-400 lines and *then* sort out all the errors, just to finally find that the logic is broken, and then I can't find it.) Uh. That makes me look like a worse programmer than I (think I) am :-o Cheers, Sigbjørn Lund Olsen
Mar 10 2004
next sibling parent reply Ant <duitoolkit yahoo.ca> writes:
On Wed, 10 Mar 2004 16:11:01 +0100, Sigbjørn Lund Olsen wrote:

The most annoying syntax error I tend to make is when I forget 
 to close a literal string somewhere.
(Ah! another opportunity to talk about leds.) leds will highlight unclosed literals with a different color. (This is standard on Scintilla) Ant
Mar 10 2004
next sibling parent reply =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Ant wrote:
 On Wed, 10 Mar 2004 16:11:01 +0100, Sigbjørn Lund Olsen wrote:
 
 
The most annoying syntax error I tend to make is when I forget 
to close a literal string somewhere.
(Ah! another opportunity to talk about leds.) leds will highlight unclosed literals with a different color. (This is standard on Scintilla) Ant
What do you think about some basic features for leds: -Class navigator (like in Delphi or python IDE) -Antialias fonts (leds is scintilla based...) -Differents encodings (UTF8.... I can't write some spanish characters in leds) ... Now I'm using SciTE for editing D files in linux, because leds is at an earlier stage, but I hope leds will be a standard tool for D programming Julio
Mar 10 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Wed, 10 Mar 2004 17:08:21 +0100, Julio Jiménez wrote:

 Ant wrote:
 (Ah! another opportunity to talk about leds.)
What do you think about some basic features for leds: -Class navigator (like in Delphi or python IDE)
Like eclipse class hierarchy? or a complete hierarchy? I thing a simple parent hierarchy could be usefull and simple to implement. what do you mean? a full classes relation diagram? (that might not happed soon but should be fun to do I can imagine a full OpenGL navigation ;)
 -Antialias fonts (leds is scintilla based...)
from Scintilla docs: "On GTK+ 2.x, either GDK or Pango can be used to display text. Pango antialiases text and works well with Unicode but GDK is faster. Prepend a '!' character to the font name to use Pango." so when leds allows you to select the font that should be covered.
 -Differents encodings (UTF8.... I can't write some spanish characters in 
 leds)
from scintilla: SCI_SETCODEPAGE(int codePage) SCI_GETCODEPAGE but I no nothing about UTF how do you know the codePage number? I'm going to try to add that option right now.
 ...
 
 Now I'm using SciTE for editing D files in linux, because leds is at an 
 earlier stage, but I hope leds will be a standard tool for D programming
 
Since I remove the background (separate thread) compile and execute leds is uncrashable (yea, sure), except for the combo boxes. I need to reread the GTK threads docs. :( I need to fix the combo boxes. :( leds has only 3 combos I'll change that to entries (text fields), add the code page (help me here with the code numbers), (maybe not) allow to select the fonts and release it in a couple of days. try leds in a few days after the next release announcement. Ant
Mar 10 2004
parent reply =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Ant wrote:
 On Wed, 10 Mar 2004 17:08:21 +0100, Julio Jiménez wrote:
 
 
Ant wrote:

(Ah! another opportunity to talk about leds.)
What do you think about some basic features for leds: -Class navigator (like in Delphi or python IDE)
Like eclipse class hierarchy? or a complete hierarchy?
Really a complete code navigation in a Tree view you can put all the classes and functions of the active file (d file) you can expand the tree and see all the class members (grouped by visibility... public, private....) double clicking in the tree the current cursor position at the code will be moved member or function you selected. In this way, you can see al the members class easily and navigate throw the code. I don't know about eclipse but Borland Delphi and python IDE have something there. The code navigator is really usefull to remember all the functions in a file and all the members for one class
 I thing a simple parent hierarchy could be usefull
 and simple to implement.
 
 what do you mean? a full classes relation diagram?
 (that might not happed soon but should be fun to do
 I can imagine a full OpenGL navigation ;)
 
 
Really full code navigation and one option to open an imported file.... ;)
-Antialias fonts (leds is scintilla based...)
from Scintilla docs: "On GTK+ 2.x, either GDK or Pango can be used to display text. Pango antialiases text and works well with Unicode but GDK is faster. Prepend a '!' character to the font name to use Pango." so when leds allows you to select the font that should be covered.
Ok. really for text editing no need a great speed but the visual aspect is better for antialiases fonts
 
-Differents encodings (UTF8.... I can't write some spanish characters in 
leds)
from scintilla: SCI_SETCODEPAGE(int codePage) SCI_GETCODEPAGE but I no nothing about UTF how do you know the codePage number? I'm going to try to add that option right now.
You can select the encoding you want for the editor.... from SciTE you can select File->Encoding... and select 8 bits, UTF-8..... Gtk2 uses UTF8 so i use UTF8 for my file encodings (no translating strings) No need to know codepage.... is character encoding and you can select those you want
...

Now I'm using SciTE for editing D files in linux, because leds is at an 
earlier stage, but I hope leds will be a standard tool for D programming
Since I remove the background (separate thread) compile and execute leds is uncrashable (yea, sure), except for the combo boxes. I need to reread the GTK threads docs. :( I need to fix the combo boxes. :(
Not only combo..... From DUI TEditableCells.d file // columns ~= DUIType.INT; // columns ~= DUIType.STRING; // columns ~= DUIType.BOOLEAN; columns ~= DUIType.STRING; columns ~= DUIType.STRING; columns ~= DUIType.BOOLEAN; strange results DUIType.INT is broken.... I get strange results in the Treeviewcolumn...... visual representation for integers converted to strings is bad.... in the window but the stdout is correct i can red in the terminal screen: 3 bottles of coke true 5 packages of noodles true 2 packages of chocolate chip cookies true 1 can vanilla ice cream true 6 eggs true but in the Editable cell example window: 3456789 bottles of coke 56789 packages of noodles 23456789 packages of chocolate chip cookies 123456789 can vanilla ice cream 6789 eggs funny... :) when i add items clicking button all is ok..... in window and console there is something wrong in ListRow....
 leds has only 3 combos I'll change that to entries (text fields),
 add the code page (help me here with the code numbers),
 (maybe not) allow to select the fonts
 and release it in a couple of days.
 
 try leds in a few days after the next release announcement.
 
 Ant
 
All right... waiting now i'm working in my PostgreSQL >= 7.4 D interface ..... ;) can write programs in C stlye.... ... /* Make a connection to the database */ conn = PQconnectdb(conninfo); if (PQstatus(conn) != ConnStatusType.CONNECTION_OK) { printf("Connection to database '%s' failed.\n", PQdb(conn)); printf("%s", PQerrorMessage(conn)); exit_nicely(conn); } /* Start a transaction block */ res = PQexec(conn, "BEGIN"); if (PQresultStatus(res) != ExecStatusType.PGRES_COMMAND_OK) { printf("BEGIN command failed: %s", PQerrorMessage(conn)); PQclear(res); exit_nicely(conn); } ... and using D classes..... import dlibpq.connection; import dlibpq.transaction; import dlibpq.result; int main(char[][] args) { Connection C = new Connection("dbname = julio"); // can use Connection C = new Connection() for defaults if (!C.connected()) { printf("No pude conectar a la base de datos julio...\n"); return 1; } Transaction T = new Transaction(C, "tra1"); Result R = T.exec("create table ciudades (nombre varchar(80), poblacion int)"); if (!R.commandOk) { printf("error creando tabla: %.*s\n", R.errorMessage()); T.rollBack(); } else T.commit(); delete R; T.begin(); char [] sql = "insert into ciudades values ('Trujillo', 10000);"; sql ~= "insert into ciudades values ('Huertas', 3000);"; sql ~= "insert into ciudades values ('Madrid', 5000000);"; R = T.exec(sql); if (!R.commandOk) { printf("error insertando registros: %.*s\n", R.errorMessage()); T.rollBack(); } else T.commit(); return 0; } regards, Julio
Mar 10 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Wed, 10 Mar 2004 19:20:21 +0100, Julio Jiménez wrote:

 Really a complete code navigation
 in a Tree view you can put all the classes and functions of the active 
 file (d file)
 you can expand the tree and see all the class members (grouped by 
 visibility... public, private....)
 double clicking in the tree the current cursor position at the code will 
 be moved member or function you selected.
that's doable. leds already shows you the members for and opened module (kind of alpha quality but I'm looking at it). later I don't really fill the need for it. You know that you can select any variable on leds and open the module that defines it's type, right? (again, kind of alpha quality but I'm looking at it)
 Ok. really for text editing no need a great speed but the visual aspect 
 is better for antialiases fonts
done! already I can feel that the page down/page up it's a bit slower. of course the non anti-aliasing is still available it's interesting how pango and gtk do the size differently...
 
 Gtk2 uses UTF8 so i use UTF8 for my file encodings (no translating strings)
 No need to know codepage.... is character encoding and you can select 
 those you want
done! things happen on my system but I don't realy know how to test.
 Not only combo.....
yes, I was talking about leds. I have I major problem on DUI: accessing the C structs directly combo needs it, values for TreeView (tables and trees) needs it... (combo doesn't work at all on the windows version) (I'll keep this bookmarked, thanks)
 
 All right... waiting
:)
 
 now i'm working in my PostgreSQL >= 7.4 D interface ..... ;)
you know about my dpq, right? http://dpq.sourceforge.net (will redirect to the old page) that project is on hold because I don't need a DB right now, but when I do I think I'm gonna look into ODBC for PostgreSQL. Ant
Mar 10 2004
parent reply =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Ant wrote:
 On Wed, 10 Mar 2004 19:20:21 +0100, Julio Jiménez wrote:
 
 
Really a complete code navigation
in a Tree view you can put all the classes and functions of the active 
file (d file)
you can expand the tree and see all the class members (grouped by 
visibility... public, private....)
double clicking in the tree the current cursor position at the code will 
be moved member or function you selected.
that's doable. leds already shows you the members for and opened module (kind of alpha quality but I'm looking at it). later I don't really fill the need for it. You know that you can select any variable on leds and open the module that defines it's type, right?
as you said... in alpha quality... :) but it's the beginning some things in leds don't run fine for me may be because i'm using the binary package.... When i try to create a new project, i get a messagedialog with: Unable to load project definition for project. :( then i can write the specs for the project and compile and make.... but can't save the project itself... so i have to create the project again when i run leds.... :(
 (again, kind of alpha quality but I'm looking at it)
 
 
 
Ok. really for text editing no need a great speed but the visual aspect 
is better for antialiases fonts
done! already I can feel that the page down/page up it's a bit slower. of course the non anti-aliasing is still available it's interesting how pango and gtk do the size differently...
I can't fell the difference comparing leds and SciTE (may be computer speed.... don't know) it's quick for both
 
Gtk2 uses UTF8 so i use UTF8 for my file encodings (no translating strings)
No need to know codepage.... is character encoding and you can select 
those you want
done! things happen on my system but I don't realy know how to test.
Not only combo.....
yes, I was talking about leds. I have I major problem on DUI: accessing the C structs directly combo needs it, values for TreeView (tables and trees) needs it... (combo doesn't work at all on the windows version) (I'll keep this bookmarked, thanks)
All right... waiting
:)
now i'm working in my PostgreSQL >= 7.4 D interface ..... ;)
you know about my dpq, right?
Yes. i changed some code to run in PostgreSQL 7.4.1 but you need a lot of code for communicating and sending comands to backend.... and some bugs..... :) every time you execute.... result = exec.exec("FETCH ALL in mycursor"); create a new DPQResult object... (returned by exec.exec....) then you execute result.clear(); for clear the PGresult* but the created DPQResult still alive.... then you execute again... result = exec.exec(........ and get a stack of unused objects..... that's because i wrote a new client interface for my own use (but i'll do it public when i finish it) I have writen it using another concept.... near libpqxx (c++ client interface) but more basic and easy to use, (transactions based). The blocking mode is running ok.... now i'm writing the non blocking mode code
 http://dpq.sourceforge.net (will redirect to the old page)
 
 that project is on hold because I don't need a DB right now,
 but when I do I think I'm gonna look into ODBC for PostgreSQL.
 
PostgreSQL provides a type 4 JDBC driver. Type 4 indicates that the driver is written in Pure Java, and communicates in the database system's own network protocol. Because of this, the driver is platform independent; once compiled, the driver can be used on any system. A model for D implementation.
 Ant
 
I'll wait for your new leds version for test it, and if i could help to you, i'll do it. Thanks for your great work. Regards Julio
Mar 10 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Wed, 10 Mar 2004 20:49:15 +0100, Julio Jiménez wrote:

 When i try to create a new project, i get a messagedialog with: Unable 
 to load project definition for project. :(
I think you can just ignore that (it's gone on the delopement version)
 
 then i can write the specs for the project and compile and make.... but 
 can't save the project itself... so i have to create the project again 
 when i run leds.... :(
I thought that was fixed :( check if you have the directories: .leds .leds_data .leds_data/projects on your user home directory. I think the last published version already accepts the 'home' and 'data' parameters: leds --home anyDirectory --data anyDirectory
 Thanks for your great work.
:) Ant
Mar 10 2004
parent =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Ant wrote:
 On Wed, 10 Mar 2004 20:49:15 +0100, Julio Jiménez wrote:
 
 
When i try to create a new project, i get a messagedialog with: Unable 
to load project definition for project. :(
I think you can just ignore that (it's gone on the delopement version)
then i can write the specs for the project and compile and make.... but 
can't save the project itself... so i have to create the project again 
when i run leds.... :(
I thought that was fixed :( check if you have the directories: .leds .leds_data .leds_data/projects
no .leds_data/projects directory.... mkdir and saving projects.... :)
 on your user home directory.
 
 I think the last published version already accepts
 the 'home' and 'data' parameters:
 leds --home anyDirectory --data anyDirectory
 
 
Thanks for your great work.
:) Ant
Mar 10 2004
prev sibling parent reply =?ISO-8859-1?Q?Sigbj=F8rn_Lund_Olsen?= <sigbjorn lundolsen.net> writes:
Ant wrote:

 On Wed, 10 Mar 2004 16:11:01 +0100, Sigbjørn Lund Olsen wrote:
 
 
The most annoying syntax error I tend to make is when I forget 
to close a literal string somewhere.
(Ah! another opportunity to talk about leds.) leds will highlight unclosed literals with a different color. (This is standard on Scintilla) Ant
Oh, yes, syntax highlighting... I guess I just have a thing for EditPad :-o Seriously, though, I haven't yet found a syntax highlighting editor that let's me much about with every little detail, generally resulting in me becoming unhappy with some nitpicky detail and uninstalling. Not that I've looked very hard. (There, now you can talk more about leds :-p) Cheers, Sigbjørn Lund Olsen
Mar 10 2004
parent Ant <duitoolkit yahoo.ca> writes:
On Thu, 11 Mar 2004 02:48:22 +0100, Sigbjørn Lund Olsen wrote:

 Seriously, though, I haven't yet found a syntax highlighting editor that 
   let's me much about with every little detail, generally resulting in 
 me becoming unhappy with some nitpicky detail and uninstalling.
hey!, just build your own! or better yet pick an open source one and boost it up ;) ever hear about leds?...
 
 (There, now you can talk more about leds :-p)
 
:) Ant
Mar 10 2004
prev sibling parent "C. Sauls" <ibisbasenji yahoo.com> writes:
At times like these, EditPlus is your friend.  :)  Or any other editor 
that will highlight embedded PHP.  (I don't plug EditPlus enough...)

-C. Sauls
-Invironz

 Hmm. FYI, and because I'm waiting for my downloads to end (never 
 happens). The most annoying syntax error I tend to make is when I forget 
 to close a literal string somewhere. Mind, I only do this when I use PHP 
 - never had this problem elsewhere, probably because I use less literal 
 strings elsewhere. At any rate, while PHP tends to output fairly good 
 error messages (certainly better than any other "compiler" I've ever 
 used including dmd at the moment, but hopefully not forever(?)) in this 
 case it just cannot figure out the whereabouts of the error, so I 
 usually end up checking ever singly literal string I've written. (I 
 should really run scripts/compile a lot more often, it's a bad habit of 
 mine to write 200-400 lines and *then* sort out all the errors, just to 
 finally find that the logic is broken, and then I can't find it.)
Mar 10 2004
prev sibling next sibling parent reply Ilya Minkov <minkov cs.tum.edu> writes:
It would raise the ambiguity even further. While languages like Python 
(which has line-based formatting) and Eiffel (which ignores line ends, 
but semicolons are optional) can afford that, i think C-like languages 
cannot. This would cause too much ambiguity and lead to even more stupid 
bugs! Don't you have enough of ambiguities?

Don't see how it would be besser to readability.

-eye


imr1984 schrieb:

 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
 
 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.
 
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, as well as making the
 code more readable
 
 
Mar 10 2004
parent reply "Phill" <phill pacific.net.au> writes:
"Ilya Minkov" <minkov cs.tum.edu> wrote in message
news:c2nbmv$15cs$1 digitaldaemon.com...
 It would raise the ambiguity even further. While languages like Python
 (which has line-based formatting) and Eiffel (which ignores line ends,
 but semicolons are optional) can afford that, i think C-like languages
 cannot. This would cause too much ambiguity and lead to even more stupid
 bugs! Don't you have enough of ambiguities?

 Don't see how it would be besser to readability.

 -eye
I agree, it would take much more time to read code. For instance a for loop: for(int i = 0 i < somthin i++) Even that small amount of code is much harder to read than this: for(int i = 0; i < somthin; i++) In my opinion it would be like taking the full stops out of sentences. Phill
 imr1984 schrieb:

 the other day i was studying assembly programming, and it struck me -
why does D
 need semicolons after statements at all? they seem like a waste of time.

 I think statements should be seperated by new lines OR semicolons, so
that
 existing D code will still work.

 Ive been programming C style languages for years now and i still often
forget a
 semicolon - so i think this would be a big time saver, as well as making
the
 code more readable
Mar 12 2004
parent reply J C Calvarese <jcc7 cox.net> writes:
Phill wrote:
 "Ilya Minkov" <minkov cs.tum.edu> wrote in message
 news:c2nbmv$15cs$1 digitaldaemon.com...
 
It would raise the ambiguity even further. While languages like Python
(which has line-based formatting) and Eiffel (which ignores line ends,
but semicolons are optional) can afford that, i think C-like languages
cannot. This would cause too much ambiguity and lead to even more stupid
bugs! Don't you have enough of ambiguities?

Don't see how it would be besser to readability.

-eye
I agree, it would take much more time to read code. For instance a for loop: for(int i = 0 i < somthin i++) Even that small amount of code is much harder to read than this: for(int i = 0; i < somthin; i++) In my opinion it would be like taking the full stops out of sentences.
now that you mention it that is a very good point i think that semi colons are as important to d as periods and other punctuation marks are essential to written communications in english actually i find it quite difficult to either read or write without using punctuation i think it might be easier to get the code to compile but that doesnt count for much if it doesnt run right and is unmaintainable as always though your mileage may vary
 
 Phill
-- Justin http://jcc_7.tripod.com/d/
Mar 12 2004
parent "Phill" <phill pacific.net.au> writes:
very witty! :o))

Phill.
"J C Calvarese" <jcc7 cox.net> wrote in message
news:c2tm2o$248$1 digitaldaemon.com...
 Phill wrote:
 "Ilya Minkov" <minkov cs.tum.edu> wrote in message
 news:c2nbmv$15cs$1 digitaldaemon.com...

It would raise the ambiguity even further. While languages like Python
(which has line-based formatting) and Eiffel (which ignores line ends,
but semicolons are optional) can afford that, i think C-like languages
cannot. This would cause too much ambiguity and lead to even more stupid
bugs! Don't you have enough of ambiguities?

Don't see how it would be besser to readability.

-eye
I agree, it would take much more time to read code. For instance a for loop: for(int i = 0 i < somthin i++) Even that small amount of code is much harder to read than this: for(int i = 0; i < somthin; i++) In my opinion it would be like taking the full stops out of sentences.
now that you mention it that is a very good point i think that semi colons are as important to d as periods and other punctuation marks are essential to written communications in english actually i find it quite difficult to either read or write without using punctuation i think it might be easier to get the code to compile but that doesnt count for much if it doesnt run right and is unmaintainable as always though your mileage may vary
 Phill
-- Justin http://jcc_7.tripod.com/d/
Mar 12 2004
prev sibling next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
imr1984 wrote:
 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
 
 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.
Not necessarily: qwert = yuiop (asdfg()) would change its meaning from qwert = yuiop(asdfg()); to qwert = yuiop; asdfg();
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, 
I think the time spent by the rest of us somehow resolving the resulting ambiguities/syntax errors/bugs would outweigh the benefits.
 as well as making the code more readable
How, exactly? Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Mar 10 2004
prev sibling next sibling parent reply Juan C <Juan_member pathlink.com> writes:
<snip>
In article <c2n4fj$lva$1 digitaldaemon.com>, imr1984 says...
Ive been programming C style languages for years now and i still often forget a
semicolon - so i think this would be a big time saver, as well as making the
code more readable
</snip> How can one keystroke in fifty be a big time saver? I still spend much more time typing SPACEs for my indents (still trying to remember to use TAB now that I use editors that will insert SPACEs). I like the semi-colons, especially when several statements are on one line (yuck). Is: x = y f(z) two statements? Or did I forget an operator? If I missed an operator I want the compiler to tell me something's wrong, rather than hum happily along. And wouldn't the time spent finding such a bug far outweigh any potential time saving from not typing that one simple character? The first programming language I learned was BASIC Plus on a PDP-11, it allowed a colon to separate multiple statements on a line, so the above could be unambiguous as: x = y : f(z) (I used to see how few lines I could use for my programs, now I've learned to use as many lines for one statement as possible, especially for .net)
Mar 10 2004
parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Juan C wrote:

<snip>
 How can one keystroke in fifty be a big time saver? I still spend much more
time
 typing SPACEs for my indents (still trying to remember to use TAB now that I
use
 editors that will insert SPACEs).
What have you against TABs? <snip>
 x = y f(z)
 
 two statements? Or did I forget an operator?
<snip>
 The first programming language I learned was BASIC Plus on a PDP-11, it allowed
 a colon to separate multiple statements on a line,
So does nearly every BASIC dialect ever invented.
 so the above could be unambiguous as:
 
 x = y : f(z)
<snip> But probably not what the programmer intended. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Mar 10 2004
prev sibling next sibling parent reply Alex Fitzpatrick <alex.nospam.fitzpatrick videotron.nospam.ca> writes:
imr1984 wrote:
 the other day i was studying assembly programming, and it struck me - why does
D
 need semicolons after statements at all? they seem like a waste of time.
 
 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.
 
 Ive been programming C style languages for years now and i still often forget a
 semicolon - so i think this would be a big time saver, as well as making the
 code more readable
Over the past five years I've worked quite extensively in C, C++ and JavaScript. (and Smalltalk and APL, but let's not go there...) I'm in the process of adding Python and Java to the mix. Hopefully D will be part of that mix. Except for Python, all of these language support a "C like syntax". Semi-colons as line terminators are optional in both JavaScript and Python. <rant> IMHO *optional* line terminators are just about the daftist feature I can think of. (Right after operator overloading in C++, one of my coworkers just found a byte buffer class in the depths of our code that *knows* how to cast itself into a BSTR, try figuring that one out...) This *feature* has caused more trouble than it's worth. Even worse, because it's optional, it becomes hard to enforce good coding practices. </rant> Since I did actually take a course in compiler construction [or at least my transcript says I did, it's a little fuzzy] I can also testify that a line terminator makes the grammer easier to parse. [I noticed in the Rhino implementation of JavaScript that one of the parsing steps is to figure out where the semi-colons should go... that was when I started adding semi-colons to some of the sloppier files in my project...] -- Alex
Mar 10 2004
parent reply kinghajj <kinghajj_member pathlink.com> writes:
why can't the compiler look for both '\n' and ';' for parsering?

example: why not let this be legal

int main()
{
printf("HELLO!");int i = 1
i = 22
while(i < 32)
{
printf("%i",i);
i++;
}
return 0
}

the only downside to this is that, with a mix of semicolons and no semicolons,
the code could look messy.
Mar 10 2004
parent Alex Fitzpatrick <alex.nospam.fitzpatrick videotron.nospam.ca> writes:
kinghajj wrote:
 why can't the compiler look for both '\n' and ';' for parsering?
 
 example: why not let this be legal
 
 int main()
 {
 printf("HELLO!");int i = 1
 i = 22
 while(i < 32)
 {
 printf("%i",i);
 i++;
 }
 return 0
 }
 
 the only downside to this is that, with a mix of semicolons and no semicolons,
 the code could look messy.
Have you ever worked on a project that had more than a few hundred lines of javascript? The biggest javascript project I worked on had about 30,000 lines and was far from the largest in my company. Maintaining that many lines of code with a flaky grammar is a royal pain. (And let's not even get into bugs like: this.test = 1; if(this.testT) alert("it's good") Believe me being messy is not the only downside. When it comes to software engineering, consistency and maintainability are big issues. Besides, Walter wants line terminators. :-) -- Alex
Mar 10 2004
prev sibling parent "Walter" <walter digitalmars.com> writes:
"imr1984" <imr1984_member pathlink.com> wrote in message
news:c2n4fj$lva$1 digitaldaemon.com...
 the other day i was studying assembly programming, and it struck me - why
does D
 need semicolons after statements at all? they seem like a waste of time.

 I think statements should be seperated by new lines OR semicolons, so that
 existing D code will still work.

 Ive been programming C style languages for years now and i still often
forget a
 semicolon - so i think this would be a big time saver, as well as making
the
 code more readable
This is exactly what javascript does. Since I have implemented a javascript compiler, DMDScript, I have some experience with how this works. It doesn't work too well :-( One winds up with some wierd parsing ambiguities that get resolved by fiat. Error detection and recovery is adversely affected, as there is less redundancy in the grammar. Worst of all, having newline be sometimes whitespace and sometimes a statement separator breaks the clean separation between the tokenizer and the parser.
Mar 10 2004