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: Mon, 14 Jul 2014 18:36:16 -0500
Date: 2014-07-14T18:36:16-05:00	[thread overview]
Message-ID: <lq1phj$t43$1@loke.gir.dk> (raw)
In-Reply-To: 53c25e58$0$6665$9b4e6d93@newsspool3.arcor-online.net

"Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> wrote in message 
news:53c25e58$0$6665$9b4e6d93@newsspool3.arcor-online.net...
...
> I have read plausible justifications for the choice of type conversion 
> syntax
> of both Ada and C. But conceptually, I think that C++ has found a better
> solution. It is more Ada like, perhaps, whenever C++ suggests to 
> explicitly
> state the intent:
>
>    static_cast<float>(i + j)
>
> seems pretty clear (even when it might be unnecessary). Ada's and C's
> overloading of round brackets for several different things might be
> tempting at first, but the temptation ceases once ease of understanding
> the differences is considered more important.

But the question here is whether a detailed understanding of the differences 
is necessary the vast majority of the time. In Ada, at least, that's 
typically not necessary. One simply thinks of anything of the form 
"name(args)" as a named mapping from "args" to some result type. Assuming 
one is looking at existing code that already compiles (which is typically 
the case when one is trying to understand an expression [if you just wrote 
it, you hopefully still remember what you meant, and hopefully no one is 
checking in code that doesn't compiler], you usually don't need to know the 
exact types involved.

And if you do, in a language like Ada you need to look up every name 
involved and try to figure out which declaration is involved. Hopefully you 
have an IDE to do it, because it's never fun with just text tools. And 
that's true for type conversions (finding the location of the declaration 
can be unpleasant if there are a lot of use clauses and withs) as well as 
functions and arrays (since objects can be the results of parameterless 
functions and possibly hidden by nesting).

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.

                              Randy.



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