comp.lang.ada
 help / color / mirror / Atom feed
* Integer'Class
@ 2004-10-05  0:10 Rick Santa-Cruz
  2004-10-05  0:52 ` Integer'Class Jeffrey Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rick Santa-Cruz @ 2004-10-05  0:10 UTC (permalink / raw)


Hi,

sorry for so many questions.... maybe that's easy to answer, but I don't 
find any senseful answer to that:
Why can't I use: Integer'Class, but I can derive a new class from Integer in 
writing:
type New_Int is new Integer range 1..100;

Isn't this unlogical? Or have I missunderstand something completly?

Thanks tons,
A becoming desperated Rick 





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

* Re: Integer'Class
  2004-10-05  0:10 Integer'Class Rick Santa-Cruz
@ 2004-10-05  0:52 ` Jeffrey Carter
  2004-10-05  1:00   ` Integer'Class Rick Santa-Cruz
  2004-10-05  7:16 ` Integer'Class Martin Krischik
  2004-10-05  8:45 ` Integer'Class Dmitry A. Kazakov
  2 siblings, 1 reply; 8+ messages in thread
From: Jeffrey Carter @ 2004-10-05  0:52 UTC (permalink / raw)


Rick Santa-Cruz wrote:

> Why can't I use: Integer'Class, but I can derive a new class from
> Integer in writing:
> type New_Int is new Integer range 1..100;
> 
> Isn't this unlogical? Or have I missunderstand something completly?

It is inconsistent. 'Class only applies to tagged types.

This is compounded further by the discussion of type classes, such as 
the class of integer types, floating-point types, and so on. 'Class was 
introduced in Ada 95 to allow OOP; type classes existed in Ada 83.

-- 
Jeff Carter
"You tiny-brained wipers of other people's bottoms!"
Monty Python & the Holy Grail
18




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

* Re: Integer'Class
  2004-10-05  0:52 ` Integer'Class Jeffrey Carter
@ 2004-10-05  1:00   ` Rick Santa-Cruz
  2004-10-05 19:45     ` Integer'Class Jeffrey Carter
  0 siblings, 1 reply; 8+ messages in thread
From: Rick Santa-Cruz @ 2004-10-05  1:00 UTC (permalink / raw)



"Jeffrey Carter" <spam@spam.com> schrieb im Newsbeitrag 
news:hfm8d.2844$UP1.1203@newsread1.news.pas.earthlink.net...
> Rick Santa-Cruz wrote:
>
>> Why can't I use: Integer'Class, but I can derive a new class from
>> Integer in writing:
>> type New_Int is new Integer range 1..100;
>>
>> Isn't this unlogical? Or have I missunderstand something completly?
>
> It is inconsistent. 'Class only applies to tagged types.
>
> This is compounded further by the discussion of type classes, such as the 
> class of integer types, floating-point types, and so on. 'Class was 
> introduced in Ada 95 to allow OOP; type classes existed in Ada 83.
So, it's only a notation-problem and I am not only using "new" to derive (in 
the conext of OOP) from a type? If this is the case, I can use the 
new-keyword always and not only in cases of tagged types... is this true?

Bye,
Rick 





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

* Re: Integer'Class
  2004-10-05  0:10 Integer'Class Rick Santa-Cruz
  2004-10-05  0:52 ` Integer'Class Jeffrey Carter
@ 2004-10-05  7:16 ` Martin Krischik
  2004-10-05 19:49   ` Integer'Class Jeffrey Carter
  2004-10-05  8:45 ` Integer'Class Dmitry A. Kazakov
  2 siblings, 1 reply; 8+ messages in thread
From: Martin Krischik @ 2004-10-05  7:16 UTC (permalink / raw)


Rick Santa-Cruz wrote:

> Hi,
> 
> sorry for so many questions.... maybe that's easy answer, but I don't
> find any senseful answer to that:
> Why can't I use: Integer'Class, but I can derive a new class from Integer
> in writing:
> type New_Int is new Integer range 1..100;

> Isn't this unlogical? Or have I missunderstand something completly?

'Class is the tag of OO-classes. In C++ talk: virtual function table and
RTTI rolled in one. 

The parent for simple types is 'Base. The 'Base of Integer is
universal_integer - a compiler internal type which cannot be used directly.

Saying that, I now start to wonder what 'Base of a tagged type is...

With Regards

Martin

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




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

* Re: Integer'Class
@ 2004-10-05  7:35 Christoph Karl Walter Grein
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Karl Walter Grein @ 2004-10-05  7:35 UTC (permalink / raw)
  To: comp.lang.ada

There are several mistakes in the post:

> The parent for simple types is 'Base. The 'Base of Integer is
> universal_integer - a compiler internal type which cannot be used directly.
> 
> Saying that, I now start to wonder what 'Base of a tagged type is...

'Base is defined for scalar subtypes only. So there is no such thing for tagged types.

Integer is the "first subtype" (constrained) of an anomymous unconstrained base type
accessible via the 'Base attribute.

The parent of all integer types is root integer, which again is anonymous. All integer
literals are of this type; they are implicitly converted to the correct target type.
You may informally think of root integer as Integer'Class.
__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/?mc=021201




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

* Re: Integer'Class
  2004-10-05  0:10 Integer'Class Rick Santa-Cruz
  2004-10-05  0:52 ` Integer'Class Jeffrey Carter
  2004-10-05  7:16 ` Integer'Class Martin Krischik
@ 2004-10-05  8:45 ` Dmitry A. Kazakov
  2 siblings, 0 replies; 8+ messages in thread
From: Dmitry A. Kazakov @ 2004-10-05  8:45 UTC (permalink / raw)


On Tue, 5 Oct 2004 02:10:55 +0200, Rick Santa-Cruz wrote:

> sorry for so many questions.... maybe that's easy to answer, but I don't 
> find any senseful answer to that:
> Why can't I use: Integer'Class, but I can derive a new class from Integer in 
> writing:
> type New_Int is new Integer range 1..100;
> 
> Isn't this unlogical? Or have I missunderstand something completly?

Not at all. It is quite logical, all types should have T'Class, (probably
T'Class ones too (:-)). But when Ada 83 was extended to Ada 95, a decision
was taken not to go that far. I suppose, because the amount of changes
needed was considered too large. So only tagged types may be grouped in
classes, presently. Constructors/destructors were implemented as a hack
etc. Alas.

As for New_Int, it is not just deriving from Integer. It is something like:

-- This is not Ada!
type <Anonymous_Subtype> is -- Deriving a subtype
   new Integer
      with null record              -- No extension
      with constraint range 1..100; -- Constraint on the values
type New_Int is new <Anonymous_Subtype>; -- Cloning the subtype

The result is a clone of a subtype of Integer. It is an unrelated to
Integer type. Therefore it cannot be put into Integer'Class, it induces a
class of its own. A related construct is:

subtype Sub_Int is Integer range 1..100;

This only puts a constraint, but produces no true new type. So you cannot
override Integer operations in Sub_Int, only overload (with nasty
consequences). This is a heavy heritage of Ada 83, which considered all
subtypes as constrained bases.

I do hope that Ada 2010 will have T'Class for all specific types, let's
see.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Integer'Class
  2004-10-05  1:00   ` Integer'Class Rick Santa-Cruz
@ 2004-10-05 19:45     ` Jeffrey Carter
  0 siblings, 0 replies; 8+ messages in thread
From: Jeffrey Carter @ 2004-10-05 19:45 UTC (permalink / raw)


Rick Santa-Cruz wrote:

> So, it's only a notation-problem and I am not only using "new" to
> derive (in the conext of OOP) from a type? If this is the case, I can
> use the new-keyword always and not only in cases of tagged types...
> is this true?

I'm not sure what you're asking. You can derive from any type, but 
usually you neither want or need to.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail
16




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

* Re: Integer'Class
  2004-10-05  7:16 ` Integer'Class Martin Krischik
@ 2004-10-05 19:49   ` Jeffrey Carter
  0 siblings, 0 replies; 8+ messages in thread
From: Jeffrey Carter @ 2004-10-05 19:49 UTC (permalink / raw)


Martin Krischik wrote:

> The parent for simple types is 'Base. The 'Base of Integer is 
> universal_integer - a compiler internal type which cannot be used
> directly.

No, the 'Base of Integer is Integer'Base, which is usually identical to 
Integer. Universal_Integer and Root_Integer are different concepts, and 
not normally a concern for a beginner.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail
16




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

end of thread, other threads:[~2004-10-05 19:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-05  7:35 Integer'Class Christoph Karl Walter Grein
  -- strict thread matches above, loose matches on Subject: below --
2004-10-05  0:10 Integer'Class Rick Santa-Cruz
2004-10-05  0:52 ` Integer'Class Jeffrey Carter
2004-10-05  1:00   ` Integer'Class Rick Santa-Cruz
2004-10-05 19:45     ` Integer'Class Jeffrey Carter
2004-10-05  7:16 ` Integer'Class Martin Krischik
2004-10-05 19:49   ` Integer'Class Jeffrey Carter
2004-10-05  8:45 ` Integer'Class Dmitry A. Kazakov

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