comp.lang.ada
 help / color / mirror / Atom feed
From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov)
Subject: Re: ada vs. cpp
Date: Tue, 13 Nov 2001 10:21:36 GMT
Date: 2001-11-13T10:21:36+00:00	[thread overview]
Message-ID: <3bf0e265.74480421@News.CIS.DFN.DE> (raw)
In-Reply-To: Rj%H7.109781$WW.6592266@bgtnsc05-news.ops.worldnet.att.net

On Tue, 13 Nov 2001 02:12:01 GMT, "David Thompson"
<david.thompson1@worldnet.att.net> wrote:

>Dmitry Kazakov <dmitry@elros.cbb-automation.de> wrote :
>> On Tue, 16 Oct 2001 04:52:02 GMT, "David Thompson"
>> <david.thompson1@worldnet.att.net> wrote:
>...
>> >> Sorry, but Ada is one of rare languages which are able to manipulate
>> >> strings allocated on the stack. IMO strings are indeed one of Ada
>> >> strengths, especially if you need an efficient parsing code. ...
>>
>> [..] Strings in COBOL, PL/1, FORTRANs [,Pascal] etc
>...
>> No, said that Ada has excellent strings. It is true that many
>> languages have strings. Even FORTRAN IV arrays of LOGICAL*1 could be
>> counted as strings (:-)). However, to have an excellent string support
>> one should fulfil some requrements, which include IMO:
>>
>I think the fair measure is whether strings are supported to the same
>or an equivalent extent as other data types in the same language.
>(Equivalence is of course a judgement call.)
>
>> 1. There are stack allocated strings
>Yes for all of the above.
>
>> 2. There are in, out, inout parameters and returns of the string type
>Modern Fortran yes.  Older FORTRAN, COBOL, and PL/1 have
>all parameters by reference with no modes (for all data types).
>Pascal distinguishes by-value and by-reference, and ExtdPascal
>adds nonmodifiable, but not out vs inout (again for all types).
>Fortran PL/1 and Pascal do support string return values;
>COBOL does not support return values of any data type.
>
>> 3. The string bounds are not a part of the type
>I think you have to distinguish between parameters and
>actual variables/objects.  Even in Ada except for Unbounded
>an actual string object has a type constrained by (max) size,
>but for Bounded the current (valid) contents may be <= size;
>the same is true for PL/1 and ExtdPascal.  For COBOL,
>Fortran, and basicPascal a string object is a fixed size
>(although COBOL can have a DEPENDING array).
>
>Fortran and basicPascal (level 1) in addition to PL/1 do
>support _parameters_ with size determined at runtime
>by the actual argument.  (Most?) COBOL implementations
>(like C) actually work for any size actual argument
>but this is not a defined feature of the language.
>
>In all except Pascal a string lower bound is always 1,
>only the upper bound varies.  (PL/1 supports other lower
>bounds for _arrays_ but strings are not arrays there.)

I didn't mean the actual bounds of an object. I meant that the bounds
are not used for type checks. So objects of *same* type may have
different bounds. Consider, in C++:

template <int From, int To> class String {...};

Here the string bounds identify the type. Which has a nasty
consequence that String<1,10> and String<1,80> are two different
types.

>> 4. Bounds can be obtained from any string object
>(Or upper bound, where the lower bound is fixed.)
>Again I think there are several cases:  for actual objects
>(except Ada Unbounded, which is not stack allocated
>at least not in general) the size is determined either
>explicitly or implicitly in the declaration, so this is
>"only" a convenience (though sometimes a useful one).

It is not so simply. Consider:

procedure Foo (X : Time; Y : Fuzzy;  Z : ManaFlux) is
   Internal : String (1..SomethingAwfulComplex (X, Y, Z));
begin
   ...
 
>For parameters whose (argument) size is known only
>at runtime, Fortran, PL/1, and Pascal yes.

It is also a simplification. Consider an inline subroutine. If the
bounds of a string parameter are statically known, then the compiler
might optimize the routine code.

>For Bounded strings whose current contents are distinct
>from the object size, the current bound is available in
>PL/1 and ExtdPascal, the only ones that have this type.
>
>> 5. There are constrained string subtypes
>Yes, as above.
>
>> 6. String slices
>Yes except basic Pascal.  In COBOL and Fortran using
>an array-like syntax, in PL/1 and ExtdPascal using a
>function-like syntax but usable as an lvalue.
>
>...
>> Maybe. However, I would like to see an example of such new ground
>> breaking. [by Ada in string handling]
>
>You mean you would like to find something that is in Ada already
>that was/is not in other languages?  I don't see anything major.
>Or you want to propose adding new features to Ada that other
>languages don't have?  That's a different question.  I don't see
>anything I consider vitally needed that I would push for, but
>I can imagine many things I wouldn't mind having.

Just, I see nothing that Ada should borrow for string handling from
other languages. There might be some problems, when for instance, one
implements pattern matching in Ada, but they are not string problems.

>> ... Some people here have argued that C++ has strings because
>> one can develop them. Very well, to follow this logic I expect that
>> there is something extr-r-r-emely important and new for strings that
>> cannot be [efficiently] implemented in Ada 95. And?
>>
>I for one have argued that one can easily implement in C++
>the equivalent of Strings.Fixed and Bounded, although this is
>not as convenient (for integration, reuse, etc.) as having them
>standard.  It already has the equivalent of Unbounded.
>I don't understand the rest of your statement.

If there is something (let denote it as ***) that Ada 95 does not
have, then according to the logic: "C++ has strings", Ada 95 indeed
has ***, because ***  can be implemented in Ada 95. Thus to say that
Ada 95 does not have ***, one should prove that *** cannot be
[efficently] implemented in Ada 95...

>...
>> >As previously noted C++ std::string is closely comparable
>> >to Ada.Strings.Unbounded (and dynamically allocated).
>>
>> As I have pointed in other post I disagree with this logic. What can
>> be expressed in the language terms is *not* a part of the language.
>>
>Then Annex A is not part of Ada? 

No, it is: "A.1(8) type Integer is range implementation-defined;".
"Implementation-defined" cannot be expressed in Ada terms.

>Nor loops because they can be constructed from goto? 

One always can write an equivalent program that uses gotos instead of
loops, but it is not so that Ada loops can be expressed using gotos.
There are lot of problems here. Declaration of the loop variable. A
unique label is required, exit statements, the requirement that a loop
can be entered only through its header etc.

Consider the language constructs as axioms, and programs as theorems.
Any [provable] theorem can be deduced from axioms. It is of course
useless to compare axiom sets by analyzing theorems, provided (as we
all know) that the sets of theorems are more or less equivalent.

>I think the the language definition defines
>the language.

The opposite is also true: the language defines a language definition
(:-))

>One could argue that early versions of C++ were
>deficient in this respect, but not now; std::string is required to be
>present (and provide the same functionality) on all implementations.

Well, if we would define "language definition" as "a pile of paper
sheets with something written upon them", then of course, from such
sort of definition will follow anything. [Please do not consider this
a blame on C++ standard (:-))].

The fact that the name of a program containing definition of a type
called "std::string" is written on some sheets from that "pile" proves
nothing [or anything, depending on the point of view (:-))].

>> Yes, in C++ one may have what bounded or unbounded Ada strings are.
>> Then there are ready to use string implementations like STL or MFC.
>> But C++ have nothing comparable with the type String in Ada.
>>
>MFC is a very different matter.  It is NOT standard.  Neither is STL
>as such, although it has a _big_ overlap with the C++ standard library.

Regards,
Dmitry Kazakov



  reply	other threads:[~2001-11-13 10:21 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-03 20:42 ada vs. cpp Ralph M�ritz
2001-10-03 20:56 ` Preben Randhol
2001-10-03 21:07   ` Ralph M�ritz
2001-10-04  5:08     ` Pi
2001-10-04  5:07       ` Ed Falis
2001-10-04  5:13       ` David Starner
2001-10-04 10:57         ` Preben Randhol
2001-10-04 13:18           ` Marin David Condic
2001-10-04 16:30             ` Pascal Obry
2001-10-04 17:05               ` Marin David Condic
2001-10-05 15:22               ` Mike Mohr
2001-10-06  9:15                 ` Pascal Obry
2001-10-06 11:23                   ` MM
2001-10-06 12:27                     ` Marc A. Criley
2001-10-06 16:53                     ` James Rogers
2001-10-09 13:51                     ` Marin David Condic
2001-10-09 14:13                       ` James Rogers
2001-10-09 14:25                         ` Marin David Condic
2001-10-10 16:46                           ` Warren W. Gay VE3WWG
2001-10-09 15:10                         ` Robert*
2001-10-09 16:17                           ` James Rogers
2001-10-11 12:03                             ` David Botton
2001-10-09 14:43                       ` Robert*
2001-10-09 15:18                         ` Wes Groleau
2001-10-09 18:21                           ` Marin David Condic
2001-10-09 20:37                             ` James Rogers
2001-10-09 16:21                         ` James Rogers
2001-10-09 16:43                           ` Lutz Donnerhacke
2001-10-10  5:18                         ` Richard Riehle
2001-10-10 13:21                           ` Marin David Condic
2001-10-10 14:15                           ` Wes Groleau
2001-10-22  2:07                             ` David Thompson
2001-10-22 13:35                               ` Wes Groleau
2001-10-22 19:14                                 ` Ole-Hjalmar Kristensen
2001-10-23  5:40                               ` Richard Riehle
2001-10-09 15:06                       ` Ole-Hjalmar Kristensen
     [not found]                       ` <9pv2f20jf4@drn.newsguy <3BC3240B.96703A8B@worldnet.att.net>
2001-10-10  5:47                         ` Simon Wright
2001-10-06 22:38                   ` Frode Tennebø
2001-10-06 23:48                     ` mike
2001-10-07  7:31                       ` Pascal Obry
2001-10-08 14:55                   ` Mike Mohr
2001-10-08 15:07                     ` Mike Mohr
2001-10-08 16:34                     ` Robert*
2001-10-08 17:47                       ` Mike Mohr
2001-10-08 18:38                         ` Robert*
2001-10-09 14:56                           ` Mike Mohr
2001-10-09 15:20                             ` Wes Groleau
2001-10-09 16:14                             ` Steven Deller
2001-10-09 16:55                             ` Pascal Obry
2001-10-08 19:19                         ` James Rogers
2001-10-09  8:17                         ` Pascal Obry
2001-10-09 15:46                         ` Ted Dennison
2001-10-09 17:35                           ` Mike Mohr
2001-10-09 18:45                             ` Ted Dennison
2001-10-08 18:02                   ` Ted Dennison
2001-10-09  4:59               ` David Thompson
2001-10-04 13:16         ` Ted Dennison
2001-10-05  7:50         ` Dmitry Kazakov
2001-10-05 13:31           ` David Starner
2001-10-05 15:34             ` Ted Dennison
2001-10-05 17:49               ` David Starner
2001-10-05 18:54                 ` Wes Groleau
2001-10-05 22:02                   ` James Rogers
2001-10-05 22:35                     ` Wes Groleau
2001-10-06  3:44                   ` David Starner
2001-10-08  8:18             ` Dmitry Kazakov
2001-10-08 13:33               ` David Starner
2001-10-09 13:36                 ` Wes Groleau
2001-10-09 15:29                   ` David Starner
2001-10-10 11:01                     ` Dmitry Kazakov
2001-10-10 11:20                       ` Lutz Donnerhacke
2001-10-10 12:14                         ` Robert*
2001-10-10 13:31                           ` Lutz Donnerhacke
2001-10-10 14:36                         ` Steven Deller
2001-10-10 14:59                           ` Wes Groleau
2001-10-10 15:15                           ` Lutz Donnerhacke
2001-10-10 15:16                           ` Dmitry Kazakov
2001-10-10 16:10                             ` Florian Weimer
2001-10-11  8:02                               ` Dmitry Kazakov
2001-10-10 15:59                         ` Brian Rogoff
2001-10-10 18:50                           ` David Starner
2001-10-11  9:28                             ` Lutz Donnerhacke
2001-10-10 14:03                       ` David Starner
2001-10-10 16:40                         ` Ted Dennison
2001-10-10 17:53                         ` Pascal Obry
2001-10-10 23:11                           ` David Starner
2001-10-11  3:00                             ` James Rogers
2001-10-22  2:10                               ` David Thompson
2001-10-05 13:52           ` James Rogers
2001-10-05 14:28             ` Larry Kilgallen
2001-10-05 14:07           ` Ted Dennison
2001-10-16  4:52           ` David Thompson
2001-10-16 10:21             ` Dmitry Kazakov
2001-11-13  2:12               ` David Thompson
2001-11-13 10:21                 ` Dmitry A. Kazakov [this message]
2001-11-13 16:05                   ` Ted Dennison
2001-11-14  9:29                     ` Dmitry A. Kazakov
2001-10-04  6:01       ` mike
2001-10-04  8:42         ` Pi
2001-10-04 12:22           ` James Rogers
2001-10-04 17:50         ` perl Warren W. Gay VE3WWG
2001-10-04 19:27           ` perl maa
2001-10-05 12:15             ` perl Georg Bauhaus
2001-10-04 19:28           ` perl Larry Kilgallen
2001-10-05  7:24           ` perl Lutz Donnerhacke
2001-10-05 12:38             ` perl Georg Bauhaus
2001-10-06 19:00               ` perl Florian Weimer
2001-10-04 16:26       ` ada vs. cpp Pascal Obry
2001-10-04 18:47         ` David Botton
2001-10-04 22:29         ` Jacob Sparre Andersen
2001-10-04 22:31           ` Wes Groleau
2001-10-04 22:52           ` Preben Randhol
2001-10-05 12:43             ` Georg Bauhaus
2001-10-05 13:09               ` Preben Randhol
2001-10-06  1:05         ` Mike Silva
2001-10-04 13:50     ` Ted Dennison
2001-10-03 21:03 ` Marin David Condic
2001-10-04  2:40 ` Jeff
2001-10-05  1:23 ` Adrian Hoe
2001-10-05  4:34   ` mike
2001-10-05  4:42   ` mike
2001-10-05 11:13     ` Adrian Hoe
  -- strict thread matches above, loose matches on Subject: below --
2001-10-12 20:54 Richard Pinkall-Pollei
2001-10-12 21:28 ` Vector..
2001-10-13  7:07   ` Dale Stanbrough
2001-10-14  8:15   ` Jean-Marc Bourguet
2001-10-15 10:04   ` Nexus
2001-10-15 12:18   ` Lutz Donnerhacke
2001-10-15 21:25     ` Florian Weimer
2001-10-22  2:08       ` David Thompson
2001-10-22  7:04         ` Florian Weimer
2001-10-22  7:31           ` Lutz Donnerhacke
2001-11-13  2:12           ` David Thompson
2001-10-16  8:47     ` Jean-Marc Bourguet
2001-10-16 10:08       ` Lutz Donnerhacke
2001-10-16 11:07         ` Jean-Marc Bourguet
2001-10-16 12:00           ` Lutz Donnerhacke
2001-10-16 19:08           ` Darren New
2001-10-16 15:46         ` Florian Weimer
2001-10-16 19:31           ` Stephen Leake
2001-10-16 20:13             ` Florian Weimer
2001-10-16 21:42               ` Stephen Leake
2001-10-17  8:37                 ` Florian Weimer
2001-10-17  8:45                   ` Lutz Donnerhacke
2001-10-16 13:45       ` Ted Dennison
2001-10-16 13:54         ` Jean-Marc Bourguet
2001-10-16 13:54         ` Lutz Donnerhacke
2001-10-15 13:44   ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox