From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.acm.org>
Subject: Re: Noob question: universal_integer type
Date: Fri, 21 May 2010 16:37:41 -0700
Date: 2010-05-21T16:37:41-07:00 [thread overview]
Message-ID: <ht75h2$d37$1@tornado.tornevall.net> (raw)
In-Reply-To: <buEJn.4423$Z6.586@edtnps82>
Duke Normandin wrote:
>
> Let me get this right... if I use an undeclared integer in an expression,
> Ada will "deem it" to be a "universal_integer" and not choke at
> compile-time?
I don't know, and I've been using Ada since 1984. What is "an undeclared integer"?
17 is an integer literal; all integer literals are universal_integer. 17 is not
an undeclared integer.
What the tutorial is trying to get across is that Ada, unlike some languages,
does not have typed numeric literals (see also universal_real). You might
encounter a language in which 10 is a literal of type int and 10L a literal of
long int, for example. In Ada, all integer literals are universal_integer, and
implicitly converted to specific integer types as required.
Partly this makes life easier: you can change the type of a variable and not
have to change all the literals used with that variable; and partly it's pretty
much needed in a language that lets you define your own numeric types.
--
Jeff Carter
"C's solution to this [variable-sized array parameters] has real
problems, and people who are complaining about safety definitely
have a point."
Dennis Ritchie
25
next prev parent reply other threads:[~2010-05-21 23:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 23:15 Noob question: universal_integer type Duke Normandin
2010-05-21 23:33 ` Yannick Duchêne (Hibou57)
2010-05-21 23:34 ` Yannick Duchêne (Hibou57)
2010-05-21 23:37 ` Jeffrey R. Carter [this message]
2010-05-22 2:04 ` Duke Normandin
2010-05-22 7:16 ` Niklas Holsti
2010-05-22 13:04 ` Duke Normandin
2010-05-22 13:47 ` Dmitry A. Kazakov
2010-05-22 14:51 ` Duke Normandin
2010-05-22 20:08 ` Yannick Duchêne (Hibou57)
2010-05-23 2:28 ` Duke Normandin
2010-05-23 2:36 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox