February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | I have a personal coding standard that says an empty block *must* be represented with {} and not { } or {;} or ; etc. This makes it very easy to not get caught up on false +ves. (Of course, false -ves are poss. <G>) But since it's a personal one, others may have something different that works equally well ... "Unknown W. Brackets" <unknown@simplemachines.org> wrote in message news:cvbc9d$129h$1@digitaldaemon.com... > Yep, or, in the more common cases: > > foreach (char c; "") > continue; > > while (true) > continue; > > Which makes it a lot cleaner and more readable imho (but obviously cannot be done for if.) > > -[Unknown] > > >> "Derek Parnell" <derek@psych.ward> wrote in message news:fewqzt2viqdl.btneu9e85pr2$.dlg@40tude.net... >> >>>On Mon, 21 Feb 2005 00:22:49 +0100, Anders F Björklund wrote: >>> >>> >>>>Are any of these extra semicolons really errors ? >>>> >>>> >>>>>void f() >>>>>{ >>>>> >>>>>}; >>>>> >>>>>class C >>>>>{ >>>>> >>>>>}; >>>>> >>>>>struct S >>>>>{ >>>>> char c; >>>>>}; >>>>> >>>>>union U >>>>>{ >>>>> char c; >>>>>}; >>>>> >>>>>void main() >>>>>{ >>>>> if (false) >>>>> { >>>>> >>>>> }; >>>>> >>>>> foreach(char c; "") >>>>> { >>>>> >>>>> }; >>>>> >>>>> ; >>>>> null; >>>>>} >>>> >>>>They all pass the current D compiler silently... >>>> >>> >>>Not to me ;-) But a naked semi-colon and the 'null;' is fairly >>>meaningless >>>to point where one may think that the coder has made a mistake. >>> >>>However note that >>> >>> if (true); >>> >>> foreach(char c; ""); >>> >>> while(true); >>> >>>are compiler errors. >> >> >> I presume that one needs to do >> >> if(true) >> {} >> >> foreach(char c; "") >> {} >> >> while(true) >> {} >> >> ?? >> >> |
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath |
> [Against]
> - One more keyword to learn.
>
Programmers may become confused as to the meaning of noop.
Ie, noop is pure syntactic sugar.
the NOP instruction in an assembler instruction that is often used to control pipeline flushing, etc.
I would hope anyone needing a genuine NOP would check the assembler output, but maybe not.
Brad
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to brad | On Mon, 21 Feb 2005 16:16:47 +1300, <brad@domain.invalid> wrote:
>> [Against]
>> - One more keyword to learn.
>>
> Programmers may become confused as to the meaning of noop.
> Ie, noop is pure syntactic sugar.
> the NOP instruction in an assembler instruction that is often used to control pipeline flushing, etc.
>
> I would hope anyone needing a genuine NOP would check the assembler output, but maybe not.
Good point, is there another better keyword maybe?
or do you think it's a bad idea in general?
Regan
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | What do you think of creating a keyword for it, and making the rest illegal. eg. if (true) <keyword> instead of all the possible premutations. ; has been made illegal in cases like the above as it's a source of bugs, having a keyword does the same, plus makes the code more obvious to others. Can the compiler optimise if it's told this explicitly? At the cost of adding another keyword. I suggested "noop" but Brad suggested it might get confused with the NOP assembler instruction. This was really just a random thought passing through my head, I'm not sure there is a problem that needs solving, the possible error cases i.e. using ';' are illegal the rest are unlikely to be done accidently and make sense to most people (everyone?) Regan On Mon, 21 Feb 2005 13:56:21 +1100, Matthew <admin@stlsoft.dot.dot.dot.dot.org> wrote: > I have a personal coding standard that says an empty block *must* be > represented with > > {} > > and not > > { > } > > or > > {;} > > or > > ; > > etc. > > This makes it very easy to not get caught up on false +ves. (Of course, > false -ves are poss. <G>) > > But since it's a personal one, others may have something different that > works equally well ... > > > > "Unknown W. Brackets" <unknown@simplemachines.org> wrote in message > news:cvbc9d$129h$1@digitaldaemon.com... >> Yep, or, in the more common cases: >> >> foreach (char c; "") >> continue; >> >> while (true) >> continue; >> >> Which makes it a lot cleaner and more readable imho (but obviously >> cannot be done for if.) >> >> -[Unknown] >> >> >>> "Derek Parnell" <derek@psych.ward> wrote in message >>> news:fewqzt2viqdl.btneu9e85pr2$.dlg@40tude.net... >>> >>>> On Mon, 21 Feb 2005 00:22:49 +0100, Anders F Björklund wrote: >>>> >>>> >>>>> Are any of these extra semicolons really errors ? >>>>> >>>>> >>>>>> void f() >>>>>> { >>>>>> >>>>>> }; >>>>>> >>>>>> class C >>>>>> { >>>>>> >>>>>> }; >>>>>> >>>>>> struct S >>>>>> { >>>>>> char c; >>>>>> }; >>>>>> >>>>>> union U >>>>>> { >>>>>> char c; >>>>>> }; >>>>>> >>>>>> void main() >>>>>> { >>>>>> if (false) >>>>>> { >>>>>> >>>>>> }; >>>>>> >>>>>> foreach(char c; "") >>>>>> { >>>>>> >>>>>> }; >>>>>> >>>>>> ; >>>>>> null; >>>>>> } >>>>> >>>>> They all pass the current D compiler silently... >>>>> >>>> >>>> Not to me ;-) But a naked semi-colon and the 'null;' is fairly >>>> meaningless >>>> to point where one may think that the coder has made a mistake. >>>> >>>> However note that >>>> >>>> if (true); >>>> >>>> foreach(char c; ""); >>>> >>>> while(true); >>>> >>>> are compiler errors. >>> >>> >>> I presume that one needs to do >>> >>> if(true) >>> {} >>> >>> foreach(char c; "") >>> {} >>> >>> while(true) >>> {} >>> >>> ?? >>> >>> > |
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote:
> What do you think of creating a keyword for it, and making the rest illegal.
> eg.
>
> if (true)
> <keyword>
>
Personally, when I am writing code that doesn't do something I just comment it - ie:
while (wait_on_some_event () { /* do nothing */ };
I don't see that having a compiler keyword helps or hinders the programmer either way.
Brad
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath |
"Regan Heath" <regan@netwin.co.nz> wrote in message news:opsmi2tdqc23k2f5@ally...
> What do you think of creating a keyword for it, and making the rest illegal.
Not much
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | The way it is right now is sufficient {}. Why make a new keyword for this? There are plenty of other more important areas to concentrate on in D.
On Mon, 21 Feb 2005 16:33:03 +1300, Regan Heath wrote:
> What do you think of creating a keyword for it, and making the rest
> illegal.
> eg.
>
> if (true)
> <keyword>
>
> instead of all the possible premutations.
>
> ; has been made illegal in cases like the above as it's a source of bugs, having a keyword does the same, plus makes the code more obvious to others.
>
> Can the compiler optimise if it's told this explicitly?
>
> At the cost of adding another keyword.
>
> I suggested "noop" but Brad suggested it might get confused with the NOP assembler instruction.
>
> This was really just a random thought passing through my head, I'm not sure there is a problem that needs solving, the possible error cases i.e. using ';' are illegal the rest are unlikely to be done accidently and make sense to most people (everyone?)
>
> Regan
>
> On Mon, 21 Feb 2005 13:56:21 +1100, Matthew <admin@stlsoft.dot.dot.dot.dot.org> wrote:
>> I have a personal coding standard that says an empty block *must* be represented with
>>
>> {}
>>
>> and not
>>
>> {
>> }
>>
>> or
>>
>> {;}
>>
>> or
>>
>> ;
>>
>> etc.
>>
>> This makes it very easy to not get caught up on false +ves. (Of course,
>> false -ves are poss. <G>)
>>
>> But since it's a personal one, others may have something different that works equally well ...
>>
>>
>>
>> "Unknown W. Brackets" <unknown@simplemachines.org> wrote in message news:cvbc9d$129h$1@digitaldaemon.com...
>>> Yep, or, in the more common cases:
>>>
>>> foreach (char c; "")
>>> continue;
>>>
>>> while (true)
>>> continue;
>>>
>>> Which makes it a lot cleaner and more readable imho (but obviously
>>> cannot be done for if.)
>>>
>>> -[Unknown]
>>>
>>>
>>>> "Derek Parnell" <derek@psych.ward> wrote in message news:fewqzt2viqdl.btneu9e85pr2$.dlg@40tude.net...
>>>>
>>>>> On Mon, 21 Feb 2005 00:22:49 +0100, Anders F Björklund wrote:
>>>>>
>>>>>
>>>>>> Are any of these extra semicolons really errors ?
>>>>>>
>>>>>>
>>>>>>> void f()
>>>>>>> {
>>>>>>>
>>>>>>> };
>>>>>>>
>>>>>>> class C
>>>>>>> {
>>>>>>>
>>>>>>> };
>>>>>>>
>>>>>>> struct S
>>>>>>> {
>>>>>>> char c;
>>>>>>> };
>>>>>>>
>>>>>>> union U
>>>>>>> {
>>>>>>> char c;
>>>>>>> };
>>>>>>>
>>>>>>> void main()
>>>>>>> {
>>>>>>> if (false)
>>>>>>> {
>>>>>>>
>>>>>>> };
>>>>>>>
>>>>>>> foreach(char c; "")
>>>>>>> {
>>>>>>>
>>>>>>> };
>>>>>>>
>>>>>>> ;
>>>>>>> null;
>>>>>>> }
>>>>>>
>>>>>> They all pass the current D compiler silently...
>>>>>>
>>>>>
>>>>> Not to me ;-) But a naked semi-colon and the 'null;' is fairly
>>>>> meaningless
>>>>> to point where one may think that the coder has made a mistake.
>>>>>
>>>>> However note that
>>>>>
>>>>> if (true);
>>>>>
>>>>> foreach(char c; "");
>>>>>
>>>>> while(true);
>>>>>
>>>>> are compiler errors.
>>>>
>>>>
>>>> I presume that one needs to do
>>>>
>>>> if(true)
>>>> {}
>>>>
>>>> foreach(char c; "")
>>>> {}
>>>>
>>>> while(true)
>>>> {}
>>>>
>>>> ??
>>>>
>>>>
>>
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | > Is using "noop" more obvious that the various connotations you've shown so far for telling other programmers that you intend for nothing to happen at that point in the code?
How about a comment? ;)
if(x)
{
// nothing happens here. really.
}
|
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | On Sun, 20 Feb 2005 20:00:03 -0800, John Reimer <brk_6502@yahoo.com> wrote: > The way it is right now is sufficient {}. Cool. > Why make a new keyword for > this? I was just asking. > There are plenty of other more important areas to concentrate on in > D. Sure, and once they're done? Regan > On Mon, 21 Feb 2005 16:33:03 +1300, Regan Heath wrote: > >> What do you think of creating a keyword for it, and making the rest >> illegal. >> eg. >> >> if (true) >> <keyword> >> >> instead of all the possible premutations. >> >> ; has been made illegal in cases like the above as it's a source of bugs, >> having a keyword does the same, plus makes the code more obvious to others. >> >> Can the compiler optimise if it's told this explicitly? >> >> At the cost of adding another keyword. >> >> I suggested "noop" but Brad suggested it might get confused with the NOP >> assembler instruction. >> >> This was really just a random thought passing through my head, I'm not >> sure there is a problem that needs solving, the possible error cases i.e. >> using ';' are illegal the rest are unlikely to be done accidently and make >> sense to most people (everyone?) >> >> Regan >> >> On Mon, 21 Feb 2005 13:56:21 +1100, Matthew >> <admin@stlsoft.dot.dot.dot.dot.org> wrote: >>> I have a personal coding standard that says an empty block *must* be >>> represented with >>> >>> {} >>> >>> and not >>> >>> { >>> } >>> >>> or >>> >>> {;} >>> >>> or >>> >>> ; >>> >>> etc. >>> >>> This makes it very easy to not get caught up on false +ves. (Of course, >>> false -ves are poss. <G>) >>> >>> But since it's a personal one, others may have something different that >>> works equally well ... >>> >>> >>> >>> "Unknown W. Brackets" <unknown@simplemachines.org> wrote in message >>> news:cvbc9d$129h$1@digitaldaemon.com... >>>> Yep, or, in the more common cases: >>>> >>>> foreach (char c; "") >>>> continue; >>>> >>>> while (true) >>>> continue; >>>> >>>> Which makes it a lot cleaner and more readable imho (but obviously >>>> cannot be done for if.) >>>> >>>> -[Unknown] >>>> >>>> >>>>> "Derek Parnell" <derek@psych.ward> wrote in message >>>>> news:fewqzt2viqdl.btneu9e85pr2$.dlg@40tude.net... >>>>> >>>>>> On Mon, 21 Feb 2005 00:22:49 +0100, Anders F Björklund wrote: >>>>>> >>>>>> >>>>>>> Are any of these extra semicolons really errors ? >>>>>>> >>>>>>> >>>>>>>> void f() >>>>>>>> { >>>>>>>> >>>>>>>> }; >>>>>>>> >>>>>>>> class C >>>>>>>> { >>>>>>>> >>>>>>>> }; >>>>>>>> >>>>>>>> struct S >>>>>>>> { >>>>>>>> char c; >>>>>>>> }; >>>>>>>> >>>>>>>> union U >>>>>>>> { >>>>>>>> char c; >>>>>>>> }; >>>>>>>> >>>>>>>> void main() >>>>>>>> { >>>>>>>> if (false) >>>>>>>> { >>>>>>>> >>>>>>>> }; >>>>>>>> >>>>>>>> foreach(char c; "") >>>>>>>> { >>>>>>>> >>>>>>>> }; >>>>>>>> >>>>>>>> ; >>>>>>>> null; >>>>>>>> } >>>>>>> >>>>>>> They all pass the current D compiler silently... >>>>>>> >>>>>> >>>>>> Not to me ;-) But a naked semi-colon and the 'null;' is fairly >>>>>> meaningless >>>>>> to point where one may think that the coder has made a mistake. >>>>>> >>>>>> However note that >>>>>> >>>>>> if (true); >>>>>> >>>>>> foreach(char c; ""); >>>>>> >>>>>> while(true); >>>>>> >>>>>> are compiler errors. >>>>> >>>>> >>>>> I presume that one needs to do >>>>> >>>>> if(true) >>>>> {} >>>>> >>>>> foreach(char c; "") >>>>> {} >>>>> >>>>> while(true) >>>>> {} >>>>> >>>>> ?? >>>>> >>>>> >>> > |
February 21, 2005 Re: Extra semicolons, Errors or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to brad | On Mon, 21 Feb 2005 16:35:46 +1300, <brad@domain.invalid> wrote:
> Regan Heath wrote:
>> What do you think of creating a keyword for it, and making the rest illegal.
>> eg.
>> if (true)
>> <keyword>
>>
> Personally, when I am writing code that doesn't do something I just comment it - ie:
> while (wait_on_some_event () { /* do nothing */ };
>
> I don't see that having a compiler keyword helps or hinders the programmer either way.
Sure, but A comment is not 'required'.
Regan
|
Copyright © 1999-2021 by the D Language Foundation