From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail From: "fabio de francesco" Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: 23 Mar 2005 05:58:54 -0800 Organization: http://groups.google.com Message-ID: <1111586334.958702.249050@o13g2000cwo.googlegroups.com> References: <395uqaF5rhu2mU1@individual.net> <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <1111464133.508323@athnrd02> <423fe9df$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111521825.653841@athnrd02> <424094b0$0$11481$9b4e6d93@newsread2.arcor-online.net> <1111568404.687226@athnrd02> <1111572591.296439@athnrd02> <1111574207.72969@athnrd02> <42414f88$0$9217$9b4e6d93@newsread4.arcor-online.net> <1111576802.823362@athnrd02> <1111577078.934620@athnrd02> NNTP-Posting-Host: 82.49.51.133 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1111586344 4277 127.0.0.1 (23 Mar 2005 13:59:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 23 Mar 2005 13:59:04 +0000 (UTC) In-Reply-To: <1111577078.934620@athnrd02> User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: o13g2000cwo.googlegroups.com; posting-host=82.49.51.133; posting-account=Lp02jQ0AAABMd3TAghNf0TM2YBZqD_JE Xref: g2news1.google.com comp.lang.ada:9798 comp.lang.c++:46810 comp.realtime:1615 comp.software-eng:5215 Date: 2005-03-23T05:58:54-08:00 List-Id: Ioannis Vranos wrote: > Ioannis Vranos wrote: > > > OK, one can use a vector then. And as I said in other messages, it is > > not difficult to define an array that takes arbitrary signed ranges, but > > this does not make much sense in C++. > > > > > > In other words, the direct equivalent of your array is probably > > valarray/vector, ignoring the signed ranges. > > > BTW does Ada provide dynamic arrays like vector/deque? > > -- > Ioannis Vranos Ciao, I think we don't have to care about the presence of a high-level construct like whatever container. When C++ hadn't yet standardised containers, everyone could actually build these higher-level structures by himself. The only problem is standardisation. If you have languages that are sufficienly low-level like C++ and Ada you can manufacture every type of algorithm and containers you need. You build higher-level components by using lower-level built-in language features. Every compile-time or run-type check that you can have for built-in types you "inherit" for user created structures. This is said to answer your past question about Ada having or not same checks for built-in types and user defined types. I suppose std::vector is a simple array which must be copied to a larger one in order to insert a new element while it is full. You know it can be done in Ada too. What's more in Ada is that you can, in a standardised way, directly create low-level representation of user defined types with a lot of attributes that C++ doesn't provide. Ada programmers prefer to build their own types rather than using built-in Integer, Float, Long_Float (int, float, double) and so on in order to gain a much finer control. In Ada you can decide representation attributes like range, digit, delta, mod, address, alignment, size, byte-order (little or big endian) in record component, and many other things like these. As an example you can write: type Counter is new Integer; for Counter'Size use 48; for Counter'Alignment use 16; What's more, you get a compiler error if your machine can't use some sort of representation you need in order to free you from knowing how much space a type can provide. You said that real C++ code hardly need to specify ranges, because you should be careful not to assign a value that can't be held by a variable of some specific type. Imagine you have know a variable is to hold numbers not larger than 99_999 and you choose to store them in an "int" knowing that you have enough space. When later you port your program to a machine where "int" is 16 bits you don't have any warning from a C++ compiler and program run for years until for some reason that variable is assigned with say 86_000. I think you know what happens.. If you had that type declared as "type Var_T is range 0 .. 99_999;", at the very moment you port your program to this new machine the compiler would choose the correct size to hold values of that type so program is no more restricted to this 16 bits C++ "int" and consequently won't raise this bug. Do you still think you don't need ranges? Regards, fabio de francesco