comp.lang.ada
 help / color / mirror / Atom feed
From: "Xenos" <dont.spam.me@spamhate.com>
Subject: Re: access & address
Date: Thu, 14 Oct 2004 15:52:55 -0400
Date: 2004-10-14T15:52:55-04:00	[thread overview]
Message-ID: <ckmleq$dlm1@cui1.lmms.lmco.com> (raw)
In-Reply-To: 1982479.VT7X1MC7VE@linux1.krischik.com


"Martin Krischik" <krischik@users.sourceforge.net> wrote in message
news:1982479.VT7X1MC7VE@linux1.krischik.com...
> Most used type is "Ada::Natural" since most C++ programmers can't even get
> int and unsigned right and sadly they do write libraries I have to use.
That's a very insulting, generalizing, and incorrect statement.  Besides, if
you think Ada'a Natural  is equivalent to C++'s unsigned, that is what is
sad.

>
> There is of corse a weekness:
>
> typedef Ada::Range<int, 1, 12> Month;
> typedef Ada::Range<int, 1, 12> US_Hours;
>
> And please: I know I could use classes. But that is just another ugly
hack!
> And why must save and secure be an ugly hack?
>
One man's ugly hack is another's versatility.  Besides, you don't have to
use a class to make your above instanitations unique.  You can use enums.
If you define an enum such as:

enum month {First_Month = 0, Last_Month = 12};

The C++ standard says that any value within the range is valid (actually its
any value less than or equal to the closed power of 2, not less than 12, but
close enough).  It also treats month as a unique type for overload
resolution. So, your typedef becomes:

typedef Ada::Range<month, First_Month, Last_Month> Month;  Which will be
unique from Hours.  You, of course, will still proclaim it an ugly hack, but
you don't need an extra class (and you now have "better" names for your
months than 1-12).  Besides, ugly or not, the language does give you the
ability to overcome its weaknesses.  Ugly is a different matter.

Regards.





  reply	other threads:[~2004-10-14 19:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14  9:05 access & address Hans Van den Eynden
     [not found] ` <1347924.5V7QhTSfdI@linux1.krischik.com>
     [not found]   ` <ckm14i$erb2@cui1.lmms.lmco.com>
2004-10-14 18:09     ` Martin Krischik
2004-10-14 20:13       ` CBFalconer
2004-10-15  8:18         ` Martin Krischik
     [not found]     ` <2t7jm8F1sp752U1@uni-berlin.de>
2004-10-14 18:17       ` Martin Krischik
2004-10-14 19:52         ` Xenos [this message]
2004-10-15  8:53           ` Martin Krischik
2004-10-15 17:30             ` Xenos
2004-10-16 14:25               ` Martin Krischik
2004-10-16 15:15                 ` Rich Herrick
2004-10-15 15:46           ` Björn Persson
2004-10-15 17:09             ` Xenos
2004-10-17 23:38               ` Björn Persson
2004-10-18  7:42                 ` Martin Krischik
2004-10-14 19:37       ` Xenos
2004-10-15  8:30         ` Martin Krischik
replies disabled

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