From: Eric Merritt <cyberlync@yahoo.com>
To: comp.lang.ada@ada.eu.org
Subject: A question and a request
Date: Tue, 6 Nov 2001 20:44:19 -0800 (PST)
Date: 2001-11-06T20:44:19-08:00 [thread overview]
Message-ID: <mailman.1005116423.21054.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <9s9t16$11ia3i$1@ID-25716.news.dfncis.de>
As some of you may know I am fairly new to Ada and I
just found out something that surprised me. I declared
two subtypes of an integer. I was then able to add
these two types together and assign the result to an
instance of one of the above subtypes. or
subtype type_1 is Integer;
subtype type_2 is Integer;
type_1_instance : type_1;
type_2_instance : type_2;
type_1_instance_2 : type_1;
type_1_instance := 1;
type_2_instance := 2;
type_1_instance_2 := type_1_instance +
type_2_instance;
The addition operator is taking two disparate but
related types and adding them. This is fine,
up-casting is a normal thing. However, when the result
is returned it is not (should not be?) an instance of
the subtype. It seems that the compiler is
down-casting automatically. This bothers me and it
seams that is violates Ada's strong typing. What am I
missing here?
My request is a bit simpler, is there any one out
there willing to serve as kind of a quasi-mentor.
Basically look at some simple code occasionally and
tell me when I am getting bad habits. I have found
when learning other languages without experienced
input that I am able to pick up the language in a few
weeks or months and then it takes me a couple of years
to realize I have bad habits and attempt to rectify
them. This shouldn't be too time consuming for the
volunteer. I have been programming in other languages
professionally (C/C++, Java, Perl and Python) and I
have a good understanding of the theory. I just need
someone to occasionally look and say "hey this is
stupid, in Ada do it this way" or "In Ada its better
to take this approach". I could post stuff to the list
but this seams to be poor etiquette.
In any case, if I get an answer to my first question I
will be happy. Thanks
__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com
next prev parent reply other threads:[~2001-11-07 4:44 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-06 16:45 List Container Straw Man Nick Roberts
2001-11-06 17:29 ` Stephen Leake
2001-11-06 18:25 ` Marin David Condic
2001-11-06 23:02 ` Nick Roberts
2001-11-07 19:49 ` Stephen Leake
2001-11-07 20:30 ` Marin David Condic
2001-11-07 23:58 ` Nick Roberts
2001-11-08 4:34 ` Jeffrey Carter
2001-11-08 10:45 ` Ehud Lamm
2001-11-08 19:09 ` Nick Roberts
2001-11-09 16:32 ` Ted Dennison
2001-11-10 2:20 ` Nick Roberts
2001-11-10 19:50 ` Ehud Lamm
2001-11-11 3:48 ` Nick Roberts
2001-11-08 10:41 ` Ehud Lamm
2001-11-08 19:20 ` Marin David Condic
2001-11-08 20:35 ` Ehud Lamm
2001-11-09 16:39 ` Ted Dennison
2001-11-08 0:06 ` Nick Roberts
2001-11-09 16:16 ` Stephen Leake
2001-11-09 16:24 ` Ehud Lamm
2001-11-09 16:52 ` Brian Rogoff
2001-11-09 18:04 ` Darren New
2001-11-09 20:05 ` Stephen Leake
2001-11-10 3:24 ` Nick Roberts
2001-11-06 23:52 ` Nick Roberts
2001-11-07 4:44 ` Eric Merritt [this message]
2001-11-07 11:00 ` A question and a request Preben Randhol
2001-11-07 12:54 ` David C. Hoos, Sr.
2001-11-08 2:35 ` dale
2001-11-07 13:24 ` Eric Merritt
2001-11-07 13:58 ` James Rogers
2001-11-07 16:32 ` Jeffrey Carter
2001-11-09 23:32 ` Matthew Heaney
[not found] <3BE93E12.7BB33908@worldnet.att.net>
2001-11-07 17:38 ` Eric Merritt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox