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!news.stack.nl!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: Tue, 15 Jul 2014 17:00:41 -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 1405461642 9772 69.95.181.76 (15 Jul 2014 22:00:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 15 Jul 2014 22:00:42 +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:20956 Date: 2014-07-15T17:00:41-05:00 List-Id: "G.B." wrote in message news:lq3slq$n75$1@dont-email.me... > On 15.07.14 01:36, Randy Brukardt wrote: >> 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. > > The authors seem to think that, for newcomers at least, it is better > to have different syntax for different things, irrespective of > experienced linguists' abstract views. Should we learn abstraction > first in order to be able to understand that different things have a > common interface warranting the same syntax for using the different > things? Ah, but my point is that these are all the same thing. If people aren't teaching novices that, then that's on the teachers, not on the programming language. In the case of Ada, and especially in Ada 2012, it's common to switch between arrays and functions without changing any of the uses. After all, the "syntax sugar" of a generalized index effectively replaces a logical array indexing by a function call. That works in part because they have the same syntax, so a user can think of Container(C) := Obj; as indexing into a cursor (even though what's really happening is that one is making a function call with an implicit dereferencee of the result). At a high enough level, there is no visible difference between array indexing and a function call and a type conversion. They're all just mappings. (There's also the question of whether proper encapsulation effectively eliminates the use of indexing and to a lesser extent, type conversions anyway -- they're all functions in the end because the implementation shouldn't be exposed -- and array indexing is clearly an artifact of the implementation.) Randy.