comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
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
Date: 2014-07-15T17:00:41-05:00	[thread overview]
Message-ID: <lq48a9$9hc$1@loke.gir.dk> (raw)
In-Reply-To: lq3slq$n75$1@dont-email.me

"G.B." <bauhaus@futureapps.invalid> 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.


  parent reply	other threads:[~2014-07-15 22:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13  1:55 why Ada type casting is different from other languages? newType(value) vs. (newType)value Nasser M. Abbasi
2014-07-13  3:01 ` Shark8
2014-07-13  6:26 ` Jeffrey Carter
2014-07-13 14:33   ` Dan'l Miller
2014-07-13  9:01 ` Niklas Holsti
2014-07-13  9:08   ` Dmitry A. Kazakov
2014-07-13 10:20     ` AdaMagica
2014-07-13 10:24     ` Georg Bauhaus
2014-07-14 23:36       ` Randy Brukardt
2014-07-15 18:42         ` G.B.
2014-07-15 19:14           ` Niklas Holsti
2014-07-15 22:47             ` Georg Bauhaus
2014-07-15 19:19           ` Jeffrey Carter
2014-07-15 23:07             ` Georg Bauhaus
2014-07-15 22:00           ` Randy Brukardt [this message]
2014-07-13 14:42 ` Dan'l Miller
2014-07-14 15:25 ` Adam Beneschan
2014-07-14 16:24   ` G.B.
2014-07-14 17:41     ` Simon Wright
2014-07-14 19:41     ` Simon Clubley
2014-07-14 20:51       ` Dan'l Miller
2014-07-14 23:23       ` Randy Brukardt
2014-07-15 19:22 ` Marius Amado-Alves
replies disabled

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