comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <rm-dash-bau-haus@dash.futureapps.de>
Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value
Date: Mon, 14 Jul 2014 18:24:22 +0200
Date: 2014-07-14T18:24:21+02:00	[thread overview]
Message-ID: <53c40435$0$6612$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <cbfb8648-9b91-4b02-bfc6-e9389b949f33@googlegroups.com>

On 14.07.14 17:25, Adam Beneschan wrote:
> I don't like the (type)expression syntax because I can never remember what the precedence is.  This is especially a problem for (type)object.method(args), because I have to look up whether the type conversion applies to just the object or to the result of the function call.
>
> In general, questions such as this are meaningless, because for the most part they come down someone's style preference.

It appears that in some situations style alone is not a permissible
language design guide. WRT syntax, McIver and Conway explain, with
novice programmers in mind, that there needs to be a good signal
to noise ratio and that this may mean just enough syntax, but also
enough syntax.  In particular, they address "homonyms",
as in "type(expression)" vs "something-else(expression)".

"Alternatively, it may be better to increase the complex-
  ity of the syntax in order to reduce homonyms which blur
  the signal. For example, the meaning of the various compo-
  nents of the Turing expression^7:


    f(C(p).A(I))(N)

"might be better conveyed with the syntax:

    f(C::p->A_{I})[N]

"The second form, whilst regrettably no more mnemonic than
  the first, does at least provide adequate visual differen-
  tiation between pointer dereference, array indexing, func-
  tion call, and substring extraction.

^7:
"Create a substring consisting of the Nth letter of
  the string returned by the function f when passed
  the Ith element of the array member A of the object
  within collection C which is pointed to by p".

Linda McIver & Damian Conway,
Seven Deadly Sins of Introductory Programming Language Design


  reply	other threads:[~2014-07-14 16:24 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
2014-07-13 14:42 ` Dan'l Miller
2014-07-14 15:25 ` Adam Beneschan
2014-07-14 16:24   ` G.B. [this message]
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