comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: access & address
Date: Fri, 15 Oct 2004 10:53:39 +0200
Date: 2004-10-15T10:53:39+02:00	[thread overview]
Message-ID: <1137756.92Qd5cOqoD@linux1.krischik.com> (raw)
In-Reply-To: ckmleq$dlm1@cui1.lmms.lmco.com

Xenos wrote:

> 
> "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. 

Born out of experience. Prehaps I have just seen to much code where the
result of sizeof or std::string::lenght was stored in an int or long or
whatever else is just available. The returnvalue for both is size_t.

I am not suprising that Win64 takes so long to finish.

And then there was the infamous netscape installer which refused the
installation because I had "-2147483648" bytes free. Well, the drive had in
fact 6GB free and the 32 bit free function returend maximum availability -
4GB.

> Besides,
> if
> you think Ada'a Natural  is equivalent to C++'s unsigned, that is what is
> sad.

No. Natural is an int with only positive values. Which means that it can be
savely converted into either int or unsigned int.

>> 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.

Well, I see the difference between a hack and versatility it terms of syntax
clutter (I am not against typing if it make things clear) and sematic
clutter (Does the average developer understand what i am doing)

> 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). 

Well actually, for the type Month it is quite cool.

> Besides, ugly or not, the language does give you the 
> ability to overcome its weaknesses.  Ugly is a different matter.

But there are two killer question:

Does the stl have it?
Does the average library vendor use it?

I am not sitting on an island programming for fun.

With Regards

Martin 

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




  reply	other threads:[~2004-10-15  8:53 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
2004-10-15  8:53           ` Martin Krischik [this message]
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