comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: why Ada type casting is different from other languages? newType(value) vs. (newType)value
Date: Sun, 13 Jul 2014 07:42:16 -0700 (PDT)
Date: 2014-07-13T07:42:16-07:00	[thread overview]
Message-ID: <69d75ff9-18f1-4ecf-bcb1-02a625a492e7@googlegroups.com> (raw)
In-Reply-To: <lpsoun$5b0$1@speranza.aioe.org>

On Sunday, July 13, 2014 1:26:16 AM UTC-5, Jeffrey Carter wrote: 
> On 07/12/2014 06:55 PM, Nasser M. Abbasi wrote: 
> > Just wondering on this choice and its advantage over the more 
> > common syntax. 

It is not that uncommon.  See C++'s exact equivalent below. 

> For the same reason Ada has type conversions, not type casts. "Type conversion" 
> is clear; "type cast" must be explained if you haven't encountered it before. 
> Ada's notation is clear; conversions involve some processing and so are like 
> functions. C's unintuitive notation must be explained when 1st encountered. 

C++ has conversion operators [i.e., operator destinationType(const originType&) without any type occupying the customary return-type slot] that have exactly the same syntax as Ada's type conversion.  C++ borrowed the idea & syntax from Ada.  (Yes, C++ has dynamic_cast, static_cast, and reinterpret_cast as well as the obsolescent cast from C, but that is in situ type casting, not type conversion from one type of instance to another type of freshly-synthesized instance.)  In modern C++, conversion operators come in 2 varieties:  implicit (i.e., the early-C++ variety) and explicit when annotated at time of declaration with the explicit keyword. 

Here is what I believe to be the most historically-correct answer to your question, but only the early Green team, especially Ichbiah) would know for sure: 
Ada was probably influenced by Algol68's mode coercion, where mode is Algol68-speak for type and coercion is Algol68-speak for conversion or casting or dereferencing or bit-widening numerics among its 7 categories of mode coercion.  [Why did Algol68 utilize mode as the term for type?  Think modus operandi:  the mode of operation of that bit-string.]  Algol68 utilized the exact same syntax for explicit mode conversions as Ada borrowed for type conversions and that C++ borrowed (from either Algol68 or Ada or both as early C++'s mantra was "Ada done right") for conversion operators.  Algol68 had multiple strengths of implicit (soft, weak, meek, firm, and strong) mode coercion.  (I could be incorrect that all of soft, weak, meek, firm, and strong are always implicit.)

  parent reply	other threads:[~2014-07-13 14: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.
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 [this message]
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