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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value Date: Mon, 14 Jul 2014 18:36:16 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <1cqb2iccfzox2$.f74qor2zqcub.dlg@40tude.net> <53c25e58$0$6665$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1405380979 29827 69.95.181.76 (14 Jul 2014 23:36:19 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 14 Jul 2014 23:36:19 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:20938 Date: 2014-07-14T18:36:16-05:00 List-Id: "Georg Bauhaus" wrote in message news:53c25e58$0$6665$9b4e6d93@newsspool3.arcor-online.net... ... > I have read plausible justifications for the choice of type conversion > syntax > of both Ada and C. But conceptually, I think that C++ has found a better > solution. It is more Ada like, perhaps, whenever C++ suggests to > explicitly > state the intent: > > static_cast(i + j) > > seems pretty clear (even when it might be unnecessary). Ada's and C's > overloading of round brackets for several different things might be > tempting at first, but the temptation ceases once ease of understanding > the differences is considered more important. But the question here is whether a detailed understanding of the differences is necessary the vast majority of the time. In Ada, at least, that's typically not necessary. One simply thinks of anything of the form "name(args)" as a named mapping from "args" to some result type. Assuming one is looking at existing code that already compiles (which is typically the case when one is trying to understand an expression [if you just wrote it, you hopefully still remember what you meant, and hopefully no one is checking in code that doesn't compiler], you usually don't need to know the exact types involved. And if you do, in a language like Ada you need to look up every name involved and try to figure out which declaration is involved. Hopefully you have an IDE to do it, because it's never fun with just text tools. And that's true for type conversions (finding the location of the declaration can be unpleasant if there are a lot of use clauses and withs) as well as functions and arrays (since objects can be the results of parameterless functions and possibly hidden by nesting). My point being, that knowing that something is a type conversion or an array indexing only helps a little. And they're really ways of looking at the same thing (a mapping) -- something that Dmitry likes to call an interface. Randy.