Re: Teaching new tricks to an old dog (C++ -->Ada)
From: Dmitry A. Kazakov (mailbox_at_dmitry-kazakov.de)
Date: 03/23/05
- Next message: Ivan Vecerina: "Re: Python to c++ conversion problem"
- Previous message: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- In reply to: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Next in thread: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Reply: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Mar 2005 12:25:08 +0100
On Wed, 23 Mar 2005 12:36:46 +0200, Ioannis Vranos wrote:
> Pascal Obry wrote:
>
>> For a domain problem where you have to create an area centered on (0,0)
>> for example. What about a vector representing altitude, the sub-zero values
>> being under the water. Just some examples, I bet you'll be able to think about
>> lot more :)
>
> I think an associative container like map fits better to this. What do
> you do in Ada if you want to associate product names with prices, in the
> style
>
> productlist["something"]= 71.2;
>
> or a name with a number (string with string) in an address book
> application for example?
>
> namelist["Obry Pascal"]="321-45563";
In general, we use ADT. It is also a recommended practice in C++, BTW. What
would you do with
namelist["Pascal Obry"]="+0 321/45563 ";
or
namelist["321-45563"]="Pascal Obry";
Note that both Ada and C++ support ADT. Ada's arrays is just an example of
ADT. It is possible in C++ to implement an array as a set of classes though
it will be much more verbose and suffer from numerous drawbacks.
> Also may you tell me if that famous compile-time boundary checking
> applies (can be used) to user-defined containers too?
Of course it does. It is no different. The bounds can be specified either
as discriminants or as generic parameters (the latter has C++ equivalent).
As for the types with discriminants, they can be statically/dynamically
constrained and this is propagated down to the implementation where the
constraints are used. If corresponding methods are inlined then nothing
prevents the compiler from checking statically known bounds at
compile-time.
I seems to me that you still missing the point. Ada's ability to check
bounds is based on the idea of constrained subtypes. It is a fundamental
concept which C++ lacks. (The only weak form of constraining C++ supports
is templates specialization.)
-- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
- Next message: Ivan Vecerina: "Re: Python to c++ conversion problem"
- Previous message: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- In reply to: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Next in thread: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Reply: Ioannis Vranos: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|