May 25, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Your right! How'd I miss that. "Pavel Minayev" <evilone@omen.ru> wrote in message news:acn1km$1q7p$1@digitaldaemon.com... > "anderson" <anderson@firestar.com.au> wrote in message news:acmt64$1mru$1@digitaldaemon.com... > > > I'd have to dissagree (I don't know if the code is correct for D but > > consider and if-else) > > > > if (...) ... > > if (...) ... > > if (...) ... > > else ... > > else ... > > else ... > > > > (... = some code) > > > > a try-finally should be considered one statement just as if-else. > > No, no, I didn't mean that. Of course it should. But in your code, in the try block (not in the catch block!), you had two statements: declaration, and function call. > > > |
May 26, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to C.R.Chafer | "C.R.Chafer" <blackmarlin@nospam.asean-mail.com> wrote in message news:aclb1b$8rh$1@digitaldaemon.com... <SNIP> > > I disagree - the language should be internally consistant, therefore anywhere where block statements are permissable it should be possible should be possible to be replace them with a singe statement - even if the result is less than perfect, as in this case. > > C 2002/5/24 Agreed! -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail |
May 26, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:aclmhe$jit$1@digitaldaemon.com... > > "C.R.Chafer" <blackmarlin@nospam.asean-mail.com> wrote in message news:aclb1b$8rh$1@digitaldaemon.com... > > > > I disagree - the language should be internally consistant, therefore anywhere where block statements are permissable it should be possible should be possible to be replace them with a singe statement - even if the > > result is less than perfect, as in this case. > > Sure, then we can apply it to functions: > > int func(int x, int y, int z) return x+2*y+3*z*x; > void func2(int x, int *y) *y = func(x, x+*y, x-*y); > > Or to switch: > > switch(number) case 1: return 0; > > Good. And what about structs: > > struct Astruct > int i; > Mmmm... I didn't think he meant declarations, but statements. struct and function declarations surely should have mandatory braces! But I do think that in a switch braces should not be necessary. And that the fall-through behaviour should be fixed, but that is another point! > Beautiful. :-( > I vote for mandatory brackets everywhere (so the language would be > internally consistant). > > Ciao. > Yuck! Compare this: if (i < 0) { printf ('a'); } else if (i == 0) { printf ('b'); } else { printf ('c'); } To this: if (i < 0) printf ('a'); else if (i == 0) printf ('b'); else printf ('c'); -- Stijn OddesE_XYZ@hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail |
May 26, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to OddesE | "OddesE" <OddesE_XYZ@hotmail.com> wrote in message news:acqeh4$6d5$1@digitaldaemon.com... > Yuck! > Compare this: > > if (i < 0) > { > printf ('a'); > } > else if (i == 0) > { > printf ('b'); > } > else > { > printf ('c'); > } In fact, the right version would be even worse if brackets are mandatory: if (i < 0) { printf("a"); } else { if (i == 0) { printf("b"); } else { printf("c"); } } |
May 27, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to C.R.Chafer | In article <aclulo$r5i$1@digitaldaemon.com>, C.R.Chafer <blackmarlin@nospam.asean-mail.com> wrote: > > I vote for mandatory brackets everywhere (so the language would be > > internally consistant). > > Had I designed the language that would have been the case, however the language was designed to be like C - and therefore the block / statement rule - special cases are bad and lead to gotchas in the language, D so far seems to be good at avoiding these so why should the try .. finally be different from the if .. else statement? After all you are not required to omit the braces. C doesn't have try...finally so language compatibility isn't an issue. -- C. Keith Ray <http://homepage.mac.com/keithray/xpminifaq.html> |
May 27, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | On Fri, 24 May 2002 16:39:16 +0100, Roberto Mariottini wrote:
> Or to switch:
>
> switch(number) case 1: return 0;
That works in GCC and (I'm told) Visual C++. I don't know whether it's
actually valid C.
|
May 27, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Keith Ray | Keith Ray wrote:
> In article <aclulo$r5i$1@digitaldaemon.com>,
> C.R.Chafer <blackmarlin@nospam.asean-mail.com> wrote:
>
>> > I vote for mandatory brackets everywhere (so the language would be
>> > internally consistant).
>>
>> Had I designed the language that would have been the case, however the
>> language was designed to be like C - and therefore the block / statement
>> rule - special cases are bad and lead to gotchas in the language, D so
>> far seems to be good at avoiding these so why should the try .. finally
>> be
>> different from the if .. else statement? After all you are not required
>> to omit the braces.
>
> C doesn't have try...finally so language compatibility isn't an issue.
Compatability is an issue in the remainder of the language (id est - if .. else, for, while, etcetra) and to ease new users into the language it should be internally consistant (so that if a particular format works with one type of statement it should work with any applicable similar statements). By the reasoning I concude try .. finally should have a similar syntax to if .. else.
C 2002/5/27
|
May 27, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Keith Ray | "Keith Ray" <k1e2i3t4h5r6a7y@1m2a3c4.5c6o7m> wrote in message news:k1e2i3t4h5r6a7y-1983E2.21242926052002@digitalmars.com... > C doesn't have try...finally so language compatibility isn't an issue. But C++ does have try..catch, which was NOT consistent to the other parts of the language. I'm glad to see D not going this track... |
May 27, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Keith Ray | Although D doesn't try to be 100% compatible with c++, it is very simular. I'm sure that was done on purpose. Taking what was learned from C++ and applying/improving it to D is a good thing. It also reduces the learning curve and helps with reportability. -- If apples and oranges both tasted like water, which would you pick? (I'd have both) "Keith Ray" <k1e2i3t4h5r6a7y@1m2a3c4.5c6o7m> wrote in message news:k1e2i3t4h5r6a7y-1983E2.21242926052002@digitalmars.com... > In article <aclulo$r5i$1@digitaldaemon.com>, > C.R.Chafer <blackmarlin@nospam.asean-mail.com> wrote: > > > > I vote for mandatory brackets everywhere (so the language would be > > > internally consistant). > > > > Had I designed the language that would have been the case, however the language was designed to be like C - and therefore the block / statement rule - special cases are bad and lead to gotchas in the language, D so far > > seems to be good at avoiding these so why should the try .. finally be different from the if .. else statement? After all you are not required to > > omit the braces. > > C doesn't have try...finally so language compatibility isn't an issue. > -- > C. Keith Ray > > <http://homepage.mac.com/keithray/xpminifaq.html> |
May 28, 2002 Re: real destructors | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | Completely agree. Once you get in the habit any additional effort is unnoticeable (esp. where one uses IDE macros to insert them) "Roberto Mariottini" <rmariottini@lycosmail.com> wrote in message news:aclmhe$jit$1@digitaldaemon.com... > > "C.R.Chafer" <blackmarlin@nospam.asean-mail.com> wrote in message news:aclb1b$8rh$1@digitaldaemon.com... > > > > I disagree - the language should be internally consistant, therefore anywhere where block statements are permissable it should be possible should be possible to be replace them with a singe statement - even if the > > result is less than perfect, as in this case. > > Sure, then we can apply it to functions: > > int func(int x, int y, int z) return x+2*y+3*z*x; > void func2(int x, int *y) *y = func(x, x+*y, x-*y); > > Or to switch: > > switch(number) case 1: return 0; > > Good. And what about structs: > > struct Astruct > int i; > > Beautiful. :-( > I vote for mandatory brackets everywhere (so the language would be > internally consistant). > > Ciao. > > |
Copyright © 1999-2021 by the D Language Foundation