comp.lang.ada
 help / color / mirror / Atom feed
From: Darren New <dnew@san.rr.com>
Subject: Re: FAQ and string functions
Date: Sat, 03 Aug 2002 00:58:27 GMT
Date: 2002-08-03T00:58:27+00:00	[thread overview]
Message-ID: <3D4B2ACD.FDA29B9A@san.rr.com> (raw)
In-Reply-To: 3D4B2382.7030209@telepath.com

Ted Dennison wrote:
> > More like his problem is not having ubiquitous variable-sized arrays so you
> > could write a function that does the splitting and returns the result as an
> > array. That's the sort of thing that makes Perl quicker to put together than
> 
> But we *do*, with Ada.Strings.Unbounded.

Errr, Ada.Strings.Unbounded is character arrays. Hardly ubiquitous. I think
if there had been a generic Ada.Unbounded that exports the same sort of
array stuff that Ada.Strings.Unbounded supports, all kinds of things could
have much more obvious interfaces.

> However, you generally don't
> need to work with variable-sized arrays.

No. *You* don't generally need to work with variable-sized arrays. :-) The
kinds of work done by people who find Perl effective *do* work with
variable-sized arrays, extensively.
 
> I really don't see what the problem with fixed array slicing is.
> 
> I'll agree that there is probably some room for improvement with Ada's
> string libraries. But slicing and joining are there just fine right now.

Yes. But when you chop up a string, what do you do with the result? You
can't just declare an array in Ada and say "I'm not sure how much this will
hold" or "add one more element to the end of this array" like you can with
Ada.Strings.Unbounded.
 
> It looks like what he is talking about

... is a specific case of a wider problem.

> (in Ada.Strings.Unbounded)
> 
> type String_Pair is array (Left..Right) of Unbounded_String;
> 
> function Split (Around : String; Source : Unbounded_String) return
> String_Pair;

No, I think the issue is (in part) when you say (for example) here's a
string, return me an array of strings, where each component of the returned
array is a whitespace-delimited work from the input string. So 
  Words("one two three four")
would return an array A such that
  A[1] = "one", A[2] = "two", and so on.

The problem is that there's no Ada.* declaration for anything like A.

At least, that's one of the problems I see.
 
> And I *have* written such routines before. It doesn't always happen, but
> I've been known to learn from the experience. :-)

Sure. I think the problem is that there's a host of low-efficiency
operations in Perl that take advantage of built-in data structures. That Ada
offers fixed strings, bounded strings, and unbounded strings indicates that
it has a focus on efficiency that something like Perl doesn't. If Ada didn't
have unbounded strings, people would have to keep reimplementing it. Ada
doesn't have unbounded arrays, and people have to keep reimplementing that
(when they need it). The assign-to-a-local-in-a-declaration doesn't really
work well when you have long-lived arrays. 

I've been working in scripting languages for the last few years, and I see a
lack in Ada of basic simple data structures, like variable sized arrays,
content-addressable arrays, and a few other things like that. I can see how
someone coming from Perl could miss all that. Once you've written programs
using built-in hashtables, arrays, etc, it's difficult to look at a language
that doesn't use such things and see how to do simple things. And that it
isn't built in means it's not going to get used everywhere it should. Even
if you build a library for UnboundedArrays, the (pulls example out of left
ear) MIME-parsing library isn't going to return an UnboundedArray compatible
with the one that goes into the XML parser. The MIME library's output
strings might be Ada.Strings.Unbounded, and the XML parser's input strings
might be Ada.Strings.Unbounded, but if you want to pass the array of lines
that's the body of the message into the array of lines that's the XML
parser's input, you're going to need to do conversions.

Yes, you *could* build all that. But from a "newbie" point of view, having
multitasking with extensive typing and all that, but lacking something as
simple as a variable-length array, really slows down learning the language,
because you're constantly stumbling when you're trying to do *simple* stuff.

Of course, Ada has excellent numeric support, type support, multithreading,
etc etc etc. It also looks like the support for large-scale programming is
excellent, altho I haven't had a chance to test that out.

-- 
Darren New 
San Diego, CA, USA (PST). Cryptokeys on demand.
   ** http://images.fbrtech.com/dnew/ **

They looked up at me like I was a slab of beef
  walking into an all-you-can-eat seafood buffet.



  reply	other threads:[~2002-08-03  0:58 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-30  6:32 FAQ and string functions Oleg Goodyckov
2002-07-30  8:52 ` Colin Paul Gloster
2002-07-30 13:48 ` Ted Dennison
2002-07-31  4:52   ` Brian May
2002-08-01 16:09     ` Ted Dennison
2002-08-02  0:21       ` Brian May
2002-08-02  1:56         ` tmoran
2002-08-02 13:59         ` Ted Dennison
2002-07-31  7:46   ` Oleg Goodyckov
2002-07-31  9:04     ` Lutz Donnerhacke
2002-07-31  9:39       ` Pascal Obry
2002-07-31 15:06         ` Oleg Goodyckov
2002-07-31 16:50       ` Oleg Goodyckov
2002-07-31 20:16     ` Simon Wright
2002-07-31 20:56       ` Robert A Duff
2002-08-01  0:11         ` Darren New
2002-08-01  1:08           ` tmoran
2002-08-01  9:25           ` Brian May
2002-08-01 11:20           ` Oleg Goodyckov
2002-08-01 15:43             ` Darren New
2002-08-01 21:37               ` Robert A Duff
2002-08-03  0:42                 ` Ted Dennison
2002-08-03 13:51                   ` Robert A Duff
2002-08-03 16:43                   ` Darren New
2002-08-05 13:37                   ` Stephen Leake
2002-08-02  8:01               ` Oleg Goodyckov
2002-08-02 16:09                 ` Darren New
2002-08-01 11:09         ` Oleg Goodyckov
2002-08-01 14:08           ` Frank J. Lhota
2002-08-01 15:06             ` Robert A Duff
2002-08-01 16:05             ` Oleg Goodyckov
2002-08-01 14:57         ` Georg Bauhaus
2002-07-31 22:04     ` Dmitry A.Kazakov
2002-07-31 15:23       ` Oleg Goodyckov
2002-08-01 21:57         ` Dmitry A.Kazakov
2002-08-01 13:10           ` Oleg Goodyckov
2002-08-02 23:29             ` Dmitry A.Kazakov
2002-08-02 16:35               ` Oleg Goodyckov
2002-08-05 11:50                 ` Dmitry A. Kazakov
2002-08-05 14:29                   ` Larry Kilgallen
2002-08-05 14:57                     ` Dmitry A. Kazakov
2002-08-05 15:12                   ` Oleg Goodyckov
2002-08-05 16:20                   ` Darren New
2002-08-05 17:01                     ` Georg Bauhaus
2002-08-05 17:48                       ` Darren New
2002-08-05 19:06                         ` tmoran
2002-08-05 20:08                           ` Darren New
     [not found]                     ` <slrnakv3q9.p2.lutz@taranis.iks-jena.de>
     [not found]                       ` <3D4FEFCB.3B74F5E5@san.rr.com>
2002-08-14  0:07                         ` Randy Brukardt
2002-08-01 14:29     ` Ted Dennison
2002-08-01 16:47       ` Oleg Goodyckov
2002-08-02 14:05         ` Ted Dennison
2002-08-02 16:11           ` Darren New
2002-08-03  0:30             ` Ted Dennison
2002-08-03  0:58               ` Darren New [this message]
2002-08-03  2:04                 ` Dale Stanbrough
2002-08-03  2:32                 ` Ted Dennison
2002-08-03  2:47                   ` Darren New
2002-08-03 12:41                     ` Ted Dennison
2002-08-03 16:53                       ` Darren New
2002-08-04  1:08                         ` Ted Dennison
2002-08-04 16:23                           ` Darren New
2002-08-05  2:16                             ` Robert Dewar
2002-08-05  3:45                               ` Darren New
2002-08-05  9:56                     ` Lutz Donnerhacke
2002-08-05 16:02                       ` Darren New
2002-08-14  0:42                         ` Randy Brukardt
2002-08-14  1:45                           ` Darren New
2002-08-14 19:37                             ` Randy Brukardt
2002-08-14 20:25                               ` Stephen Leake
2002-08-14 20:22                           ` Stephen Leake
2002-08-15 19:24                             ` Randy Brukardt
     [not found]                         ` <jb1vkustkugeutalhvrhv1n0k9hqn2fpip@4ax.com>
     [not found]                           ` <3D4FF351.8F4A6C0A@san.rr.com>
2002-08-14  1:03                             ` Randy Brukardt
2002-08-14  1:05                       ` Robert A Duff
     [not found]                       ` <3D4EA1AC.80D17170@s <wccofc6b66u.fsf@shell01.TheWorld.com>
2002-08-14 20:29                         ` Stephen Leake
2002-08-26 17:53                           ` Robert A Duff
2002-08-26 18:40                             ` Chad R. Meiners
2002-08-26 18:52                               ` Robert A Duff
2002-08-26 21:46                                 ` Chad R. Meiners
2002-08-05 13:29                     ` Stephen Leake
2002-08-03  5:07                   ` achrist
2002-08-03 12:52                     ` Ted Dennison
2002-08-05 15:34                       ` Ted Dennison
2002-08-05 13:24                 ` Stephen Leake
2002-08-05 16:02                   ` Darren New
2002-08-05  7:18           ` Oleg Goodyckov
2002-08-02  1:04     ` tmoran
replies disabled

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