comp.lang.ada
 help / color / mirror / Atom feed
* Re: Typing in Ada
@ 2004-06-01  2:11 David C. Hoos, Sr.
  0 siblings, 0 replies; 38+ messages in thread
From: David C. Hoos, Sr. @ 2004-06-01  2:11 UTC (permalink / raw)
  To: Peter C. Chapin; +Cc: comp.lang.ada

But both examples for C disregard the fact that int, enum,
and char can be freely mixed, something that Ada would
never allow.

"Peter C. Chapin" <pchapin@sover.net> wrote in message
news:Xns94FAA347BFEA8pchapinsovernet@207.106.93.237...
> Jeffrey Carter <spam@spam.com> wrote in news:mxJuc.18113$be.10152
> @newsread2.news.pas.earthlink.net:
>
> > procedure Strongly_Typed is
> >     type I1 is new Integer;
> >     type I2 is new Integer;
> >     type I3 is range -100 .. 100;
> [snip]
> >
> > int main () { /* I cannot call this Strongly_Typed */
> >     typedef int   I1;
> >     typedef int   I2;
> >     typedef short I3;
>
> This isn't an entirely fair comparison because in C, typedef doesn't
> introduce a new type it simply creates a new name for an existing type. In
> Ada, it would be more similar to using a subtype, perhaps. Something like
>
>      subtype I1 is Integer;
>
> In any event to create a new type in C you need to introduce a structure.
In
> fact, different structures do have different types:
>
> typedef struct {
>   int x;
> } A;
>
> typedef struct {
>   int x;
> } B;
>
> int main()
> {
>   A a;
>   B b;
>
>   a = b;  // Error. A and B are different types.
>
>   ...
>
> I'm not sure if there is a formal definition of strong typing or not. I've
> always thought that it had to do with the property of every expression and
> variable having a well defined type. If so, that is as true of C as it is
of
> Ada (in some ways its even more true of C because in C literal numbers
have
> specific types... there is no "universal integer" type used, for example,
for
> integer literals). The real difference is that C does a bunch of automatic
> type conversions and, furthermore, normally performs these conversions
> without checking if the converted value will fit into the target type. I'm
> not sure that's a strong typing issue, however.
>
> Peter
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
>




^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: Typing in Ada
@ 2004-06-01  2:13 David C. Hoos, Sr.
  0 siblings, 0 replies; 38+ messages in thread
From: David C. Hoos, Sr. @ 2004-06-01  2:13 UTC (permalink / raw)
  To: Peter C. Chapin; +Cc: comp.lang.ada

But both examples for C disregard the fact that int, enum,
and char can be freely mixed, something that Ada would
never allow.

"Peter C. Chapin" <pchapin@sover.net> wrote in message
news:Xns94FAA347BFEA8pchapinsovernet@207.106.93.237...
> Jeffrey Carter <spam@spam.com> wrote in news:mxJuc.18113$be.10152
> @newsread2.news.pas.earthlink.net:
>
> > procedure Strongly_Typed is
> >     type I1 is new Integer;
> >     type I2 is new Integer;
> >     type I3 is range -100 .. 100;
> [snip]
> >
> > int main () { /* I cannot call this Strongly_Typed */
> >     typedef int   I1;
> >     typedef int   I2;
> >     typedef short I3;
>
> This isn't an entirely fair comparison because in C, typedef doesn't
> introduce a new type it simply creates a new name for an existing type. In
> Ada, it would be more similar to using a subtype, perhaps. Something like
>
>      subtype I1 is Integer;
>
> In any event to create a new type in C you need to introduce a structure.
In
> fact, different structures do have different types:
>
> typedef struct {
>   int x;
> } A;
>
> typedef struct {
>   int x;
> } B;
>
> int main()
> {
>   A a;
>   B b;
>
>   a = b;  // Error. A and B are different types.
>
>   ...
>
> I'm not sure if there is a formal definition of strong typing or not. I've
> always thought that it had to do with the property of every expression and
> variable having a well defined type. If so, that is as true of C as it is
of
> Ada (in some ways its even more true of C because in C literal numbers
have
> specific types... there is no "universal integer" type used, for example,
for
> integer literals). The real difference is that C does a bunch of automatic
> type conversions and, furthermore, normally performs these conversions
> without checking if the converted value will fit into the target type. I'm
> not sure that's a strong typing issue, however.
>
> Peter
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada-france.org
> http://www.ada-france.org/mailman/listinfo/comp.lang.ada
>




^ permalink raw reply	[flat|nested] 38+ messages in thread
* Typing in Ada
@ 2004-05-31 13:32 Empit
  2004-05-31 14:04 ` Poul-Erik Andreasen
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Empit @ 2004-05-31 13:32 UTC (permalink / raw)


From typing point of view, how strong is Ada than C?

or

Which is the most strongly typed language.

Responses appreciated



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

end of thread, other threads:[~2004-06-20 11:27 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-01  2:11 Typing in Ada David C. Hoos, Sr.
  -- strict thread matches above, loose matches on Subject: below --
2004-06-01  2:13 David C. Hoos, Sr.
2004-05-31 13:32 Empit
2004-05-31 14:04 ` Poul-Erik Andreasen
2004-05-31 17:01 ` Jeffrey Carter
2004-05-31 20:03   ` Peter C. Chapin
2004-05-31 22:56     ` tmoran
2004-06-01  1:09       ` Peter C. Chapin
2004-06-01  4:40         ` tmoran
2004-06-01 11:26           ` Peter C. Chapin
2004-06-10  3:01             ` Dave Thompson
2004-06-10  3:00         ` Dave Thompson
2004-05-31 23:22     ` Nick Roberts
2004-06-01  1:04       ` Peter C. Chapin
2004-06-01  2:29         ` Nick Roberts
2004-06-02  4:39         ` Robert I. Eachus
2004-06-02 15:17           ` Hyman Rosen
2004-06-01  2:36       ` Hyman Rosen
2004-06-01  4:27         ` Larry Kilgallen
2004-06-01  4:05           ` Hyman Rosen
     [not found]         ` <d4vnb0tepd4togdrvdrbqpok1ne6n9i2vp@4ax.com>
2004-06-01 14:36           ` Wes Groleau
2004-06-01 20:24         ` Niklas Holsti
2004-06-02  4:43           ` Wes Groleau
2004-06-02  5:28             ` Robert I. Eachus
2004-06-02  8:19               ` tmoran
2004-06-02 14:47               ` Wes Groleau
2004-06-02 11:26             ` Marin David Condic
2004-06-02  5:04           ` Robert I. Eachus
2004-06-01  2:14     ` David C. Hoos
2004-06-02  1:30     ` Jeffrey Carter
2004-06-02 10:53       ` Peter C. Chapin
2004-06-02 11:38         ` Marin David Condic
2004-06-17  2:50           ` Dave Thompson
2004-06-17  4:24             ` James Rogers
2004-06-17 12:28               ` Hyman Rosen
2004-06-17 23:42                 ` James Rogers
2004-06-20 11:27                   ` Nick Roberts
2004-06-01  1:02 ` Alexander E. Kopilovich

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