comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value
Date: Tue, 15 Jul 2014 20:42:03 +0200
Date: 2014-07-15T20:42:03+02:00	[thread overview]
Message-ID: <lq3slq$n75$1@dont-email.me> (raw)
In-Reply-To: <lq1phj$t43$1@loke.gir.dk>

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?

What's a enough syntax, though?

I think the typical cases of language use can be put to
the test. For example, there is iteration as one use case
and Ada provides syntax (though not just one).

   for ... loop
      iterated_statements;
   end loop;

Another example is placing data in some containing object.
For arrays, again, Ada does have syntax,

    a(x) := 9;

which is, however, partially the same, considering context,
as for functions and type conversions.

Now, for testing, if I go to some high school and ask those who
have had some introduction to programming, about the meaning of

    foo(x) := 9;

and then go to another high school for asking a similar question,

    foo[x] := 9;

what answers will I get in each case? Will () vs [] be an issue?
Maybe less so if 'a' is substituted for 'foo', assuming that 'a'
suggests arrays, but do we know this? "f(x) := y" is at odds with
what I have learned at school. The notation f(x) invariably meant
function. I guess that explaining to students that you can think
of *defining* array-as-function f(x) by use of assignment might
be a surprise.

So, style as a guiding principle of language design could be
contrasted with such test results.

And later, is it really good or bad if it takes years or not
to be competent enough to understand

   ptrdiff_t x = *(ptrdiff_t*)main;

vs

   X : Integer_Address := To_Integer (Main'Address);

if they are comparable?
__
(*) "Every terminating algorithm computes a function after all,
so why think in terms of procedures at all and not just declare..."

  reply	other threads:[~2014-07-15 18:42 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. [this message]
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
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