From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1901f265c928a511 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!atl-c02.usenetserver.com!c03.atl99!c01.usenetserver.com!news.usenetserver.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!d9c68f36!not-for-mail Message-ID: <40BDBBFA.2020203@noplace.com> From: Marin David Condic User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Typing in Ada References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 02 Jun 2004 11:38:04 GMT NNTP-Posting-Host: 209.165.3.141 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1086176284 209.165.3.141 (Wed, 02 Jun 2004 04:38:04 PDT) NNTP-Posting-Date: Wed, 02 Jun 2004 04:38:04 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: controlnews3.google.com comp.lang.ada:1021 Date: 2004-06-02T11:38:04+00:00 List-Id: You may be right about structs, but making the argument that because C can introduce a new type that it is therefore a strongly typed language doesn't seem to follow. Ada won't let you assign a character to an integer. C will. While a typedef example may not be 100% equivalent to an Ada type, that doesn't cause C to be strongly typed - which was the original point. I'd also observe that just because there is a secret handshake that will get C to complain about type compatibility doesn't mean much. Following that logic, an assembler program can be made to complain about type compatibility (at least at runtime) if you want to do enough work. The problem is that typedef doesn't do what one who is acustomed to Ada would think it should: "type" - "def" - Define a type. MDC Peter C. Chapin wrote: > > I guess my point was that in C typedef does not even attempt to define a > new type so comparing it to Ada's 'type' declaration seems unfair. For > example if you replace the type declarations in the OP's example with > unconstrained subtype declarations, the OP's Ada program compiles with no > complaints just like the the example C program using typedef does. > > Now in C there *is* a mechanism for creating new types... it's just that > typedef isn't it. Thus it would be more appropriate to compare an Ada > program that introduces a new type that is a numeric range to a C program > that implements numeric ranges as structs. There is no doubt that the Ada > way of creating ranged types is easier and cleaner than any kind of > "equivalent" solution in plain C might be. On the other hand, I'm sure C++ > could do a much better job of emulating the Ada solution by using > templates and overloaded operators. > > In any case, the OP's example didn't seem like a good example of how Ada > is more strongly typed than C. It is certainly true that Ada does not do > automatic type conversions the way C does, but the OP's example doesn't > illustrate that point. In contrast, when I think about a weakly typed > language I think about languages like AWK, the shell scripting languages, > or perhaps Perl... where the type of a variable shifts around depending on > how it is used. For example: > > #!/bin/bash > COUNT=1 > echo "COUNT is now $COUNT" # Treat COUNT as a string > COUNT=$(($COUNT + 1)) # Treat COUNT as a number > echo "COUNT is now $COUNT" > > Peter -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jsf.mil/NSFrames.htm Send Replies To: m o d c @ a m o g c n i c . r "Face it ladies, its not the dress that makes you look fat. Its the FAT that makes you look fat." -- Al Bundy ======================================================================