comp.lang.ada
 help / color / mirror / Atom feed
From: "Ken Garlington" <Ken.Garlington@computer.org>
Subject: Re: Static typing (Was Re: Better support for garbage collection)
Date: Mon, 02 Apr 2001 23:29:18 GMT
Date: 2001-04-02T23:29:18+00:00	[thread overview]
Message-ID: <iX7y6.780$dI3.198465593@newssvr16.news.prodigy.com> (raw)
In-Reply-To: wccg0frz5hz.fsf@world.std.com


"Robert A Duff" <bobduff@world.std.com> wrote in message
news:wccg0frz5hz.fsf@world.std.com...
: "Ken Garlington" <Ken.Garlington@computer.org> writes:
:
: > "Robert A Duff" <bobduff@world.std.com> wrote in message
: > news:wccvgorkl54.fsf@world.std.com...
: >
: > : > I understand that you see it as a "malformed literal"... but WHY is
it a
: > : > malformed literal, any more than
: > : >
: > : > X : constant Float := 1;
: > : >
: > : > would NOT be a malformed literal under your proposal? Isn't the
desired
: > : > result "obvious" in each case?
: > :
: > : I find it obvious in this case, but not in the String case.  Shrug.
: > : That's only a minor point.
: >
: > Again, the inconsistency is rooted in an inability to articulate WHY
it's
: > "obvious" in one case, but not in another.
:
: I thought I articulated it already.  I'm basing my thinking on
: fourth-grade maths, rather than on computer hardware.

What part of "4th grade maths" covers text?

:  In 4th grade
: maths, the integers are a subset of the rational numbers.  The Ada
: integers are a subset of the mathematical integers, and the Ada floats
: are a subset of the rational numbers, but the number we refer to in
: English as "one" is a member of both.

Which is irrelevant, since we both previously agreed that the imprecision of
English was insufficient, right?

: That's why I see nothing wrong
: with denoting this number as 1, no matter what it's Ada type.
:
: You claim I'm being inconsistent by not going further, and allowing
: 1_000 (without quotes) if the type is String.  Well, maybe that's
: inconsistent, but so what.  I think we both agree that the rules about
: what forms of literals are allowed should be different for different
: types.

If we both agree that "what forms of literals are allowed should be
different for different types," then you must agree that it is reasonable
for integer literals to be restricted to their dictionary form.

Of course, if you don't see inconsistency as an issue, then of course you
don't have to agree on anything :)

: >... Presumably, we want to write the
: > language so that the expected result is "obvious" to the largest number
of
: > people. For example, if I see
: >
: > X: constant Float := 1/2;
: >
: > I would intuitively expect this to have the same effect as if I wrote
: >
: > A : constant Integer := 1;
: > B : constant Integer := 2;
: >
: > X : constant Float := A/B;
: >
: > If they both work, then I would also expect the following to work:
: >
: > function Q (Z: in Float) return Float;
: >
: > X : constant Float := Q(A);
: >
: > and at this point we are talking about implicit casts, which I don't
like.
:
: I don't like it either.  But I claim the two issues are different.  The
: literal 1 is *not* inherently of type Integer.  The reason you can't
: implicitly convert Integer to Float is the same reason you can't
: implicitly convert My_Float to Float (even if My_Float has the same
: 'Digits as Float, and therefore the same underlying representation, and
: the same mathematical properties).

See previous post about the dangers of mixing specific Ada types (Integer,
Float) into the discussion, as well as machine representations.

: > Not being able to articulate the difference here is the same problem as
: > insisting that the term "floating-point" MUST be limited to hardware
: > representations... it's fine, so long as everyone shares your mindset
(and
: > there's counter-evidence to that already). However, if someone believes
: > otherwise, then they may be confused and frustrated when the more
widespread
: > definition is not supported by the language.
:
: Perhaps I misspoke when I said something about hardware
: representations.
:
: The point is that floating point types in Ada (and all other programming
: languages) are intended for doing certain kinds of approximate
: calculations, which has little to do with the representation of these
: things on the screen -- that is, every programming language disagrees
: with all those dictionaries you quoted.

Again, you're confusing the concept of a *type* with the much-narrower
concept of a *literal*. See the definition of type at www.foldoc.org for
more information.

: That's not too surprising -- after all, Ada uses the term "integer" to
: refer to a rather small subset of the mathematical integers.  ;-)

Which integer is not permitted in Ada as an integer literal (vs. an Integer
type)? Are you worried about line length limits?

: > In your other post, you said:
: >
: > : My proposal does not "loosen" -- in fact (other than the minor ".0"
: > : thing), my proposal makes more programs illegal -- it tightens.
: >
: > First, this seems to be a Bad Thing -- to make legal programs, that use
a
: > more strict definition of literals, illegal.
:
: First, recall that I am not proposing to change Ada -- of course I agree
: that such an incompatible change would be a Bad Thing.  I am talking
: about what I would do if I were designing an Ada-like language, from
: scratch, with no compatibility concerns.
:
: > Second, isn't this contradicted by the example above? GNAT says two of
these
: > are illegal, you say all four are legal.
:
: Sorry -- I was unclear.  In the "other post", I was saying that my rule
: saying "the expected type for a literal is any type" is a *restriction*.
: You are correct that allowing to leave off the ".0" is an *extension*.
:
: >... Note that it's not limited to ".0";
: > all sorts of literal forms (exponents, based numbers, etc.) would now be
: > exchangable. All you have to do is leave off one digit (e.g. 1.00000E5
: > instead of 1.000001E5), and suddenly your floating-point value can be an
: > integer!
:
: That's a good point.  I agree that it would be confusing for 1.00000E5
: to be an allowed form for an integer literal.

Now it starts to get really strange in that we have to introduce a new
literal form, presumably <sign><digits>.0, to allow as integers. Are we sure
we need this extra complexity?

: > :> J: constant String := a; -- is this a literal "a", or a reference to
: > :> something that I forgot to import? Both are possible...
: >
: > : The a is an identifier, not a literal, and I don't propose to change
: > : that.
: >
: > Again, WHY is it a an identifier, if there's no identifier named A in my
: > program?
:
: Oh, come on!  I know that you know perfectly well that the a above is an
: identifier, and not a literal -- this is the syntax defined in chap 2 of
: the RM.  I never proposed to change that.

This statement appears to parse as "it's not allowed because the ARM doesn't
allow it." In which case, your whole proposal is dead, since the ARM doesn't
allow it, either :)

You'll have to depend on a different line of argument -- if it's "obvious"
what was intended here, what's the problem with being consistent and
allowing this to be parsed?

: I think literals and identifiers should be syntactically
: distinguishable, and I'm sure you agree.

(1) You seem to be making a "proof by authority" here -- even if we both
agreed, at least one of us should be able to explain why.

(2) This still doesn't answer the case where the literal *is* syntactically
distinguishable, e.g.

X : constant String := 1;

: - Bob





  reply	other threads:[~2001-04-02 23:29 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-13 18:37 Better support for garbage collection Nick Roberts
2001-03-14  8:16 ` Florian Weimer
2001-03-14 18:52   ` Robert A Duff
2001-03-14 19:40     ` Florian Weimer
2001-03-15 13:18       ` Nick Roberts
2001-03-14 19:29 ` Robert A Duff
2001-03-14 20:59   ` Brian Rogoff
2001-03-16 16:42     ` Robert A Duff
2001-03-17  6:13       ` Lao Xiao Hai
2001-03-24  4:08       ` Brian Rogoff
2001-03-15  4:35   ` Nick Roberts
2001-03-15 21:37     ` Randy Brukardt
2001-03-15 22:36     ` Stephen Leake
2001-03-16 16:26     ` Robert A Duff
2001-03-16 16:59       ` Brian Rogoff
2001-03-16 17:31         ` Robert A Duff
2001-03-16 18:29           ` Brian Rogoff
2001-03-17  2:30           ` Nick Roberts
2001-03-17 21:59             ` Robert A Duff
2001-03-17 22:57             ` Static typing (Was Re: Better support for garbage collection) Brian Rogoff
2001-03-17 23:45               ` Robert A Duff
2001-03-18  0:58                 ` Brian Rogoff
2001-03-19 15:24                   ` Robert A Duff
2001-03-20  4:21                     ` Brian Rogoff
2001-03-21  1:32                       ` Ken Garlington
2001-03-21 13:28                         ` Robert A Duff
2001-03-22  2:08                           ` Ken Garlington
2001-03-22 16:40                             ` Robert A Duff
2001-03-25 16:21                               ` Ken Garlington
2001-03-25 16:56                                 ` Ken Garlington
2001-03-25 22:31                                 ` Robert A Duff
2001-03-27  0:24                                   ` Ken Garlington
2001-03-28 23:15                                     ` Robert A Duff
2001-03-29  5:02                                       ` Ken Garlington
2001-03-29  6:13                                         ` David Starner
2001-03-29 10:10                                           ` AG
2001-03-29 14:28                                           ` Ken Garlington
2001-03-29 23:46                                         ` Robert A Duff
2001-03-30  3:41                                           ` Ken Garlington
2001-03-30 21:21                                             ` Robert A Duff
2001-03-31 19:30                                               ` Ken Garlington
2001-04-02 15:27                                                 ` Robert A Duff
2001-04-02 23:29                                                   ` Ken Garlington [this message]
2001-03-30 21:29                                             ` Robert A Duff
2001-03-30  9:16                                           ` Dmitry Kazakov
2001-03-30  9:51                                             ` Florian Weimer
2001-04-02  8:54                                               ` Dmitry Kazakov
2001-03-30 16:13                                             ` Ken Garlington
2001-04-02 11:00                                               ` Dmitry Kazakov
2001-03-30 20:44                                             ` Robert C. Leif, Ph.D.
2001-04-02 11:29                                               ` Dmitry Kazakov
2001-04-02 13:15                                                 ` Robert A Duff
2001-04-03  8:57                                                   ` Dmitry Kazakov
2001-03-27  2:39                             ` Andrew Berg
2001-03-27  3:33                               ` Ken Garlington
2001-03-27 14:23                                 ` Robert A Duff
2001-03-27 23:36                                   ` Ken Garlington
2001-03-29 23:50                       ` Robert A Duff
2001-03-19 18:24       ` Better support for garbage collection Tucker Taft
     [not found]   ` <87bsr46kxv.fsf@deneb.enyo.de>
2001-03-15 14:18     ` Robert A Duff
2001-03-15 16:36       ` Florian Weimer
2001-03-14 22:05 ` Laurent Guerby
2001-03-16 16:47   ` Robert A Duff
2001-03-16 19:46     ` Laurent Guerby
2001-03-16 20:10       ` Robert A Duff
2001-03-17 13:14         ` Support for per allocation pool selection (was: Better support for garbage collection) Laurent Guerby
2001-03-17 17:06           ` Robert A Duff
2001-03-17 19:19           ` Florian Weimer
2001-03-17 21:10             ` Robert A Duff
2001-03-15 17:56 ` Better support for garbage collection Ray Blaak
2001-03-21 16:15 ` Implementing C/C++ style #include bhazzard
2001-03-21 16:45   ` Marin David Condic
2001-03-22 15:13     ` Ira D. Baxter
2001-03-22 15:23       ` Marin David Condic
2001-03-25 15:45         ` Anton Gibbs
2001-03-26 14:24           ` Ted Dennison
2001-03-26 15:00             ` Marin David Condic
2001-03-26 14:49           ` Marin David Condic
2001-03-26 18:19             ` Stephen Leake
2001-03-26 18:44               ` Pascal Obry
2001-03-26 21:44                 ` Robert A Duff
2001-03-27  3:02                   ` Andrew Berg
2001-03-27  3:27                     ` Phaedrus
2001-03-27 17:41                   ` Pascal Obry
2001-03-26 19:18               ` Ted Dennison
2001-03-27 18:51                 ` Anton Gibbs
2001-03-26 19:35               ` Marin David Condic
2001-03-26 23:04                 ` Mark Lundquist
2001-03-27 14:38                   ` Marin David Condic
2001-03-26 16:12           ` Florian Weimer
2001-03-26 17:34             ` David Starner
2001-03-26 22:25               ` Florian Weimer
2001-03-27  3:29                 ` David Starner
2001-03-26 18:23             ` Stephen Leake
2001-03-26 22:34               ` Florian Weimer
2001-03-27  7:34         ` Ole-Hjalmar Kristensen
2001-03-27 12:43           ` Dale Stanbrough
2001-03-27 14:40             ` Marin David Condic
2001-03-27 15:01             ` Ted Dennison
2001-03-27 13:20           ` Preben Randhol
2001-03-23 17:39       ` Wes Groleau
2001-03-21 18:07   ` Mark Lundquist
2001-03-22 12:50   ` Chris M. Moore
2001-03-22 14:30     ` Marin David Condic
2001-03-22 21:15       ` singlespeeder
2001-03-22 21:42         ` Marin David Condic
2001-03-23 14:43           ` Georg Bauhaus
2001-03-23 18:51             ` Marin David Condic
2001-03-22 15:02     ` Pat Rogers
2001-03-22 15:28       ` Marin David Condic
2001-03-22 16:32       ` Chris M. Moore
2001-03-22 16:57       ` Robert A Duff
2001-03-26 16:13   ` Martin Dowie
2001-03-26 22:55   ` Phaedrus
2001-03-27  1:36     ` tmoran
replies disabled

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