comp.lang.ada
 help / color / mirror / Atom feed
* Thought this was funny
@ 2003-10-21 19:49 Xenos
  2003-10-21 20:26 ` Ching Bon Lam
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Xenos @ 2003-10-21 19:49 UTC (permalink / raw)


Reviewing some old code we are converting from Ada 83 to 95, I came across
this:

case <boolean expression> is
  when true =>
       <do something>

  when false =>
       <do something else>

end case;


Kind of made me chuckle a little.  The guy how wrote it is Canadian, so I
took to calling it the "Canadian If Statement" (not in a cruel way).


DrX





^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
@ 2003-10-21 20:26 ` Ching Bon Lam
  2003-10-21 20:44   ` Lutz Donnerhacke
  2003-10-21 20:36 ` Ed Falis
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Ching Bon Lam @ 2003-10-21 20:26 UTC (permalink / raw)


"Xenos" <dont.spam.me@spamhate.com> wrote in
news:bn42kf$ca3@cui1.lmms.lmco.com: 

> Reviewing some old code we are converting from Ada 83 to 95, I came
> across this:
> 
> case <boolean expression> is
>   when true =>
>        <do something>
> 
>   when false =>
>        <do something else>

isn't it good programming style to always include "when others"? :)

> 
> end case;
> 
> 
> Kind of made me chuckle a little.  The guy how wrote it is Canadian,
> so I took to calling it the "Canadian If Statement" (not in a cruel
> way). 
> 
> 
> DrX
> 
> 
> 




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
  2003-10-21 20:26 ` Ching Bon Lam
@ 2003-10-21 20:36 ` Ed Falis
  2003-10-21 21:08 ` Stephane Richard
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Ed Falis @ 2003-10-21 20:36 UTC (permalink / raw)


On Tue, 21 Oct 2003 15:49:13 -0400, Xenos <dont.spam.me@spamhate.com> 
wrote:

> Reviewing some old code we are converting from Ada 83 to 95, I came 
> across
> this:
>
> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;

Isn't that more like the "defense contractor who hates Ada 'if' statement"?

<do_something>!!!!

;-)

- Ed



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 20:26 ` Ching Bon Lam
@ 2003-10-21 20:44   ` Lutz Donnerhacke
  0 siblings, 0 replies; 23+ messages in thread
From: Lutz Donnerhacke @ 2003-10-21 20:44 UTC (permalink / raw)


* Ching Bon Lam wrote:
>> case <boolean expression> is
>>   when true =>
>>        <do something>
>> 
>>   when false =>
>>        <do something else>
> 
> isn't it good programming style to always include "when others"? :)

No. Its good programming style to not include "when others" in order to
detect changes of the enumeration type in the program flow.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
  2003-10-21 20:26 ` Ching Bon Lam
  2003-10-21 20:36 ` Ed Falis
@ 2003-10-21 21:08 ` Stephane Richard
  2003-10-21 22:16   ` Robert I. Eachus
  2003-10-21 22:23   ` Simon Wright
  2003-10-22  2:57 ` Steve
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Stephane Richard @ 2003-10-21 21:08 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

"Xenos" <dont.spam.me@spamhate.com> wrote in message
news:bn42kf$ca3@cui1.lmms.lmco.com...
> Reviewing some old code we are converting from Ada 83 to 95, I came across
> this:
>
> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;
>
> Kind of made me chuckle a little.  The guy how wrote it is Canadian, so I
> took to calling it the "Canadian If Statement" (not in a cruel way).
>
> DrX
>

I'm canadian and that code made me chuckle too ;-). The programmer much have
read how to handle the enumeration type first, then read about the Boolean
type being an enumeration of True and False maybe? ;-).

-- 
St�phane Richard
"Ada World" Webmaster
http://www.adaworld.com






^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 21:08 ` Stephane Richard
@ 2003-10-21 22:16   ` Robert I. Eachus
  2003-10-21 22:24     ` Ed Falis
                       ` (2 more replies)
  2003-10-21 22:23   ` Simon Wright
  1 sibling, 3 replies; 23+ messages in thread
From: Robert I. Eachus @ 2003-10-21 22:16 UTC (permalink / raw)


Stephane Richard wrote:

> I'm canadian and that code made me chuckle too ;-). The programmer much have
> read how to handle the enumeration type first, then read about the Boolean
> type being an enumeration of True and False maybe? ;-).

No, he must have been taught that your program design should allow for 
changes in requirements.  He was prepared for another value being added 
to Boolean. ;-)

-- 
                                                     Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the 
goal of Art. It remains to work these concepts into a practical, 
down-to-earth context, and for this there is nothing more practical or 
down-to-earth than what I have been talking about all along...the repair 
of an old motorcycle."  -- from Zen and the Art of Motorcycle 
Maintenance by Robert Pirsig




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 21:08 ` Stephane Richard
  2003-10-21 22:16   ` Robert I. Eachus
@ 2003-10-21 22:23   ` Simon Wright
  1 sibling, 0 replies; 23+ messages in thread
From: Simon Wright @ 2003-10-21 22:23 UTC (permalink / raw)


"Stephane Richard" <stephane.richard@verizon.net> writes:

> I'm canadian and that code made me chuckle too ;-). The programmer
> much have read how to handle the enumeration type first, then read
> about the Boolean type being an enumeration of True and False maybe?
> ;-).

Or perhaps he's an XSLT programmer -- 

<xsl:choose>
  <xsl:when test="some-test">
    <!-- stuff -->
  </xsl:when>
  <xsl:otherwise>
    <!-- other stuff -->
  </xsl:otherwise>
</xsl:choose>

Helps if you have the right Emacs mode, of course.

(errm, perhaps I should rephrase that sig!)

-- 
Simon Wright                               100% Ada, no bugs.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 22:16   ` Robert I. Eachus
@ 2003-10-21 22:24     ` Ed Falis
  2003-10-22  0:36       ` Robert I. Eachus
  2003-10-21 23:13     ` Georg Bauhaus
  2003-10-22  0:23     ` Alexandre E. Kopilovitch
  2 siblings, 1 reply; 23+ messages in thread
From: Ed Falis @ 2003-10-21 22:24 UTC (permalink / raw)


On Tue, 21 Oct 2003 22:16:16 GMT, Robert I. Eachus <rieachus@comcast.net> 
wrote:

> No, he must have been taught that your program design should allow for 
> changes in requirements.  He was prepared for another value being added 
> to Boolean. ;-)

I don't know, but you're starting to sound like an ExtremeProgramming 
aficionado ;-)

- Ed



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 22:16   ` Robert I. Eachus
  2003-10-21 22:24     ` Ed Falis
@ 2003-10-21 23:13     ` Georg Bauhaus
  2003-10-22  0:23     ` Alexandre E. Kopilovitch
  2 siblings, 0 replies; 23+ messages in thread
From: Georg Bauhaus @ 2003-10-21 23:13 UTC (permalink / raw)


Robert I. Eachus <rieachus@comcast.net> wrote:
: Stephane Richard wrote:
: 
:> I'm canadian and that code made me chuckle too ;-). The programmer much have
:> read how to handle the enumeration type first, then read about the Boolean
:> type being an enumeration of True and False maybe? ;-).
: 
: No, he must have been taught that your program design should allow for 
: changes in requirements.  He was prepared for another value being added 
: to Boolean. ;-)

Or he is just a careful programmer, who knows GNAT, case statements,
and Unchecked_Conversion :-)

with Unchecked_Conversion;
with Ada.Text_IO; use Ada;

procedure test is

   type This_Or_That is (This, That);
   for This_Or_That use (That => 17, This => 4);
   for This_Or_That'Size use 8;

   type My_Truth is new Boolean;
   for My_Truth'Size use 8;



   function from_This_Or_That is
      new Unchecked_Conversion(This_Or_That, My_Truth);

begin

   if from_This_Or_That(This) then
      Text_IO.put_line("Y");
   else
      Text_IO.put_line("N");
   end if;


   case from_This_Or_That(This) is
      when True =>
         Text_IO.put_line("Y");

      when False =>
         Text_IO.put_line("N");
   end case;

end test;


$ ./test
Y

raised CONSTRAINT_ERROR : test.adb:27 invalid data


Georg



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 22:16   ` Robert I. Eachus
  2003-10-21 22:24     ` Ed Falis
  2003-10-21 23:13     ` Georg Bauhaus
@ 2003-10-22  0:23     ` Alexandre E. Kopilovitch
  2 siblings, 0 replies; 23+ messages in thread
From: Alexandre E. Kopilovitch @ 2003-10-22  0:23 UTC (permalink / raw)
  To: comp.lang.ada

Robert I. Eachus wrote:

> he must have been taught that your program design should allow for 
> changes in requirements.  He was prepared for another value being added 
> to Boolean. ;-)

Perhaps yes (and it may be not so funny as it seems - Boolean may be easily
changed to anything in some application domains).

But there may be another reason: he may found that his manager or analyst
understands this form better (this is practical observation also).




Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 22:24     ` Ed Falis
@ 2003-10-22  0:36       ` Robert I. Eachus
  2003-10-22  1:37         ` Ed Falis
  0 siblings, 1 reply; 23+ messages in thread
From: Robert I. Eachus @ 2003-10-22  0:36 UTC (permalink / raw)


Ed Falis wrote:
> On Tue, 21 Oct 2003 22:16:16 GMT, Robert I. Eachus 
> <rieachus@comcast.net> wrote:
> 
>> No, he must have been taught that your program design should allow for 
>> changes in requirements.  He was prepared for another value being 
>> added to Boolean. ;-)
> 
> I don't know, but you're starting to sound like an ExtremeProgramming 
> aficionado ;-)

Take that back!  I was making fun of ExtremeProgramming nutcases. ;-)

Seriously, programming is an art.  I think that software engineering is 
an art as well, but it is actually a different art. Sort of like the 
relationship between architecture and good city planning. But any one 
who takes subtle relationships of form and composition in any art and 
tries to reduce them to rules or laws commits sin.  Anyone who then 
tries to carry these rules to extremes commits lunacy.

-- 
                                                     Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the 
goal of Art. It remains to work these concepts into a practical, 
down-to-earth context, and for this there is nothing more practical or 
down-to-earth than what I have been talking about all along...the repair 
of an old motorcycle."  -- from Zen and the Art of Motorcycle 
Maintenance by Robert Pirsig




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  0:36       ` Robert I. Eachus
@ 2003-10-22  1:37         ` Ed Falis
  2003-10-22  3:56           ` Robert I. Eachus
  0 siblings, 1 reply; 23+ messages in thread
From: Ed Falis @ 2003-10-22  1:37 UTC (permalink / raw)


On Wed, 22 Oct 2003 00:36:47 GMT, Robert I. Eachus <rieachus@comcast.net> 
wrote:

> Take that back!  I was making fun of ExtremeProgramming nutcases. ;-)
>

Ah, but an Extreme Programming nutcase would have agreed with you, saying 
"YAGNI!" (You Ain't Gonna' Need It!) when faced with that construct.  He 
also would agree with your philosophy of developing your unit tests as you 
design.  So, you must be careful, Grasshopper - you might find yourself 
post-classified, like I have.

- Ed



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
                   ` (2 preceding siblings ...)
  2003-10-21 21:08 ` Stephane Richard
@ 2003-10-22  2:57 ` Steve
  2003-10-22  6:26 ` Anders Wirzenius
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Steve @ 2003-10-22  2:57 UTC (permalink / raw)


It's hard to say, but maybe the compiler generated better code for a case
statement than an if statement?  I know I have resorted to funny looking
sources based on funny stuff the compiler does (including working around
compiler bugs)... generally accompanied by a comment to that effect.


Steve
(The Duck)

"Xenos" <dont.spam.me@spamhate.com> wrote in message
news:bn42kf$ca3@cui1.lmms.lmco.com...
> Reviewing some old code we are converting from Ada 83 to 95, I came across
> this:
>
> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;
>
>
> Kind of made me chuckle a little.  The guy how wrote it is Canadian, so I
> took to calling it the "Canadian If Statement" (not in a cruel way).
>
>
> DrX
>
>





^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  1:37         ` Ed Falis
@ 2003-10-22  3:56           ` Robert I. Eachus
  2003-10-22 13:44             ` Ed Falis
  0 siblings, 1 reply; 23+ messages in thread
From: Robert I. Eachus @ 2003-10-22  3:56 UTC (permalink / raw)


Ed Falis wrote:
> On Wed, 22 Oct 2003 00:36:47 GMT, Robert I. Eachus 
> <rieachus@comcast.net> wrote:
> 
>> Take that back!  I was making fun of ExtremeProgramming nutcases. ;-)

> Ah, but an Extreme Programming nutcase would have agreed with you, 
> saying "YAGNI!" (You Ain't Gonna' Need It!) when faced with that 
> construct.  He also would agree with your philosophy of developing your 
> unit tests as you design.  So, you must be careful, Grasshopper - you 
> might find yourself post-classified, like I have.

Come on, if they say YAGNI! they can't be XP nutcases.  The real 
nutcases would chastise you for not being prepared for fuzzy logic values:

if <boolean expression> >= Certainty
then
   ...
elsif <booolean expression> <= Unlikely
then
   ...
else -- uncertain cases.
   ...
end if;

That paragraph I wrote was an attempt to separate the Zen of XP, which 
is very good, from the nutcase version that tries to convert ethetics 
into moral laws.  Yes, there is a lot of good thinking in XP. However, I 
was recently looking at some books "how to" on XP in Barnes & Nobles 
that made me sick.  They tried to tell you what to do, not why you 
should do it, and to make absolutes out of what should be esthetic 
judgements.

I guess the charlatans have taken over XP as the latest fad.

Oh, and don't let anything I said about make you think I disagree with 
use of fuzzy logic in programming.  There are places where it is very 
useful.  But let's keep it where it belongs.  Please!

-- 
                                          Robert I. Eachus

"Quality is the Buddha. Quality is scientific reality. Quality is the 
goal of Art. It remains to work these concepts into a practical, 
down-to-earth context, and for this there is nothing more practical or 
down-to-earth than what I have been talking about all along...the repair 
of an old motorcycle."  -- from Zen and the Art of Motorcycle 
Maintenance by Robert Pirsig




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
                   ` (3 preceding siblings ...)
  2003-10-22  2:57 ` Steve
@ 2003-10-22  6:26 ` Anders Wirzenius
  2003-10-22  6:36 ` Vinzent 'Gadget' Hoefler
  2003-10-22 15:00 ` Martin Dowie
  6 siblings, 0 replies; 23+ messages in thread
From: Anders Wirzenius @ 2003-10-22  6:26 UTC (permalink / raw)



"Xenos" <dont.spam.me@spamhate.com> wrote in message
news:bn42kf$ca3@cui1.lmms.lmco.com...
> Reviewing some old code we are converting from Ada 83 to 95, I came
across
> this:
>
> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;
>
>
> Kind of made me chuckle a little.  The guy how wrote it is Canadian,
so I
> took to calling it the "Canadian If Statement" (not in a cruel way).
>

It could be a maintainer�s first (quick�ndirty) version of a design
change in an old code. The further enhancement of the code was
prohibited by his manager: "ifitaintbrokedonttouchit".

Anders




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
                   ` (4 preceding siblings ...)
  2003-10-22  6:26 ` Anders Wirzenius
@ 2003-10-22  6:36 ` Vinzent 'Gadget' Hoefler
  2003-10-22 12:38   ` Christopher J. Henrich
  2003-10-22 15:00 ` Martin Dowie
  6 siblings, 1 reply; 23+ messages in thread
From: Vinzent 'Gadget' Hoefler @ 2003-10-22  6:36 UTC (permalink / raw)


Xenos wrote:

>Reviewing some old code we are converting from Ada 83 to 95, I came across
>this:
>
>case <boolean expression> is
>  when true =>
>       <do something>
>
>  when false =>
>       <do something else>
>
>end case;

Well, perhaps the programmer expected that the code might change to
fuzzy booleans later... :)

I've seen worse things:

|if <boolean expression> = True then
|   Boolean_Variable := True;
|else
|   Boolean_Variable := False;
|end if;

(Well, the original was written in Pascal, but that doesn't matter for
the demonstration, I guess)...

Can someone here see any reason, why someone should not simply write

|Boolean_Variable := <boolean expression>;

instead?

The "<boolean expression> = True" construct alone... *sigh*


Vinzent.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
@ 2003-10-22  6:44 christoph.grein
  2003-10-22  7:31 ` Dmitry A. Kazakov
  2003-10-23  2:17 ` Wes Groleau
  0 siblings, 2 replies; 23+ messages in thread
From: christoph.grein @ 2003-10-22  6:44 UTC (permalink / raw)
  To: comp.lang.ada

> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;

What's so funny about this code. I also normally use if-statements with booleans but 
there are circumstances where a case statement seems more appropriate to the 
problem at hand.

Take e.g. kind of double-buffering. I use an array indexed by Boolean and switch 
via
  "X := not X;"

In such cases, neither True nor False denote something which is wrong or right, 
so I prefer the case statement.

Switching with a two-valued enumeration is not so elegant, you need a switch 
table or a case statement instead of the simple "X := not X;".

[Ducking away because this is an abstraction inversion :-]



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  6:44 Thought this was funny christoph.grein
@ 2003-10-22  7:31 ` Dmitry A. Kazakov
  2003-10-22  8:48   ` Vinzent 'Gadget' Hoefler
  2003-10-23  2:17 ` Wes Groleau
  1 sibling, 1 reply; 23+ messages in thread
From: Dmitry A. Kazakov @ 2003-10-22  7:31 UTC (permalink / raw)


On Wed, 22 Oct 2003 08:44:44 +0200 (MET DST),
christoph.grein@eurocopter.com wrote:

>> case <boolean expression> is
>>   when true =>
>>        <do something>
>>
>>   when false =>
>>        <do something else>
>>
>> end case;
>
>What's so funny about this code. I also normally use if-statements with booleans but 
>there are circumstances where a case statement seems more appropriate to the 
>problem at hand.
>
>Take e.g. kind of double-buffering. I use an array indexed by Boolean and switch 
>via
>  "X := not X;"
>
>In such cases, neither True nor False denote something which is wrong or right, 
>so I prefer the case statement.
>
>Switching with a two-valued enumeration is not so elegant, you need a switch 
>table or a case statement instead of the simple "X := not X;".

This is not elegant, but it should work for all enumeration types
having two values:

 X := Enumeration'Val (1 - Enumeration'Pos (X));

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  7:31 ` Dmitry A. Kazakov
@ 2003-10-22  8:48   ` Vinzent 'Gadget' Hoefler
  0 siblings, 0 replies; 23+ messages in thread
From: Vinzent 'Gadget' Hoefler @ 2003-10-22  8:48 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> X := Enumeration'Val (1 - Enumeration'Pos (X));

Well, for the special case Christoph mentioned:

|type Double_Buffer_Index is mod 2;

and a simple "+ 1" should do nicely.

This abstracts away the fact that a double buffer is just a special
case of a ring buffer. ;-)


Vinzent.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  6:36 ` Vinzent 'Gadget' Hoefler
@ 2003-10-22 12:38   ` Christopher J. Henrich
  0 siblings, 0 replies; 23+ messages in thread
From: Christopher J. Henrich @ 2003-10-22 12:38 UTC (permalink / raw)


In article <bn58ip$skq6o$3@ID-175126.news.uni-berlin.de>, Vinzent
'Gadget' Hoefler <ada.rocks@jlfencey.com> wrote:

> Xenos wrote:
> I've seen worse things:
> 
> |if <boolean expression> = True then
> |   Boolean_Variable := True;
> |else
> |   Boolean_Variable := False;
> |end if;
> 
> (Well, the original was written in Pascal, but that doesn't matter for
> the demonstration, I guess)...
> 
> Can someone here see any reason, why someone should not simply write
> 
> |Boolean_Variable := <boolean expression>;
> 
> instead?
> 
> The "<boolean expression> = True" construct alone... *sigh*
I think these are the signs of a larval-form programmer, who is not
sure of what is legal, or of how to understand the more abstract
definitions of what is legal.

Once upon a time, I was a larval-form FORTRAN IV programmer, and the
DO-loop was the most powerful programming construct I knew.  Or thought
I knew... I knew that "DO I = 1, 10" was legal code, and I knew that
"DO I = M1, M2" was legal code, but I was not sure if other, more
general, integer-valued expressions could be used in a DO-loop.  After
all, there were those strange, non-orthogonal restrictions on what
expressions could be used as array indices.

So, I coded by copying examples or adapting examples to my needs. 
After a while, I learned.

-- 
Chris Henrich
"Try thinking of outrage as an addiction, and see if that helps."   -- Nancy
Lebowitz



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  3:56           ` Robert I. Eachus
@ 2003-10-22 13:44             ` Ed Falis
  0 siblings, 0 replies; 23+ messages in thread
From: Ed Falis @ 2003-10-22 13:44 UTC (permalink / raw)


On Wed, 22 Oct 2003 03:56:04 GMT, Robert I. Eachus <rieachus@comcast.net> 
wrote:

> That paragraph I wrote was an attempt to separate the Zen of XP, which 
> is very good, from the nutcase version that tries to convert ethetics 
> into moral laws.  Yes, there is a lot of good thinking in XP. However, I 
> was recently looking at some books "how to" on XP in Barnes & Nobles 
> that made me sick.  They tried to tell you what to do, not why you 
> should do it, and to make absolutes out of what should be esthetic 
> judgements.

Spoken like an ex-Grasshopper ;-)

Gassho!

- Ed



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-21 19:49 Xenos
                   ` (5 preceding siblings ...)
  2003-10-22  6:36 ` Vinzent 'Gadget' Hoefler
@ 2003-10-22 15:00 ` Martin Dowie
  6 siblings, 0 replies; 23+ messages in thread
From: Martin Dowie @ 2003-10-22 15:00 UTC (permalink / raw)


"Xenos" <dont.spam.me@spamhate.com> wrote in message
news:bn42kf$ca3@cui1.lmms.lmco.com...
> Reviewing some old code we are converting from Ada 83 to 95, I came across
> this:
>
> case <boolean expression> is
>   when true =>
>        <do something>
>
>   when false =>
>        <do something else>
>
> end case;

Thinks that's bad, I reviewed one guys work with:

   case Boolean_Expression is
      when False => ...
      when True => ...
      when others => ...
   end case;

Now try and get 100% path coverage with that beauty!! :-)





^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Thought this was funny
  2003-10-22  6:44 Thought this was funny christoph.grein
  2003-10-22  7:31 ` Dmitry A. Kazakov
@ 2003-10-23  2:17 ` Wes Groleau
  1 sibling, 0 replies; 23+ messages in thread
From: Wes Groleau @ 2003-10-23  2:17 UTC (permalink / raw)


christoph.grein@eurocopter.com wrote:
> Switching with a two-valued enumeration is not so elegant, you need a switch 
> table or a case statement instead of the simple "X := not X;".

Next_Buffer : array (Buffer_Index) of Buffer_Index := (A => B, B => A);

Buffer := Next_Buffer (Buffer);


Of course what you really want to do is
add "++" to Ada and override it to act
as a toggle.  (I'm just trying to comply
with the subject line)

-- 
Wes Groleau

    Nobody believes a theoretical analysis -- except the guy who did it.
    Everybody believes an experimental analysis -- except the guy who did it.
                                  -- Unknown




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2003-10-23  2:17 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-22  6:44 Thought this was funny christoph.grein
2003-10-22  7:31 ` Dmitry A. Kazakov
2003-10-22  8:48   ` Vinzent 'Gadget' Hoefler
2003-10-23  2:17 ` Wes Groleau
  -- strict thread matches above, loose matches on Subject: below --
2003-10-21 19:49 Xenos
2003-10-21 20:26 ` Ching Bon Lam
2003-10-21 20:44   ` Lutz Donnerhacke
2003-10-21 20:36 ` Ed Falis
2003-10-21 21:08 ` Stephane Richard
2003-10-21 22:16   ` Robert I. Eachus
2003-10-21 22:24     ` Ed Falis
2003-10-22  0:36       ` Robert I. Eachus
2003-10-22  1:37         ` Ed Falis
2003-10-22  3:56           ` Robert I. Eachus
2003-10-22 13:44             ` Ed Falis
2003-10-21 23:13     ` Georg Bauhaus
2003-10-22  0:23     ` Alexandre E. Kopilovitch
2003-10-21 22:23   ` Simon Wright
2003-10-22  2:57 ` Steve
2003-10-22  6:26 ` Anders Wirzenius
2003-10-22  6:36 ` Vinzent 'Gadget' Hoefler
2003-10-22 12:38   ` Christopher J. Henrich
2003-10-22 15:00 ` Martin Dowie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox