comp.lang.ada
 help / color / mirror / Atom feed
From: Darren New <dnew@san.rr.com>
Subject: Re: FAQ and string functions
Date: Mon, 05 Aug 2002 17:48:53 GMT
Date: 2002-08-05T17:48:53+00:00	[thread overview]
Message-ID: <3D4EBA9B.848B572D@san.rr.com> (raw)
In-Reply-To: aimb0j$1mr$1@a1-hrz.uni-duisburg.de

Georg Bauhaus wrote:
> This says something about fast processors and a nice Tcl library
> working with a lot of memory. 

Why do you think it would be exceptionally slower to do it one line at a
time? Indeed, it might very well be faster, with fewer calls to realloc()
internally.

The question was "Yeah, but what if you had two meg of data?" I answered
that. It's not a problem. 

> Now the point is, I think, what
> do you intend to do with a DAT-tape sized text file?

while {-1 != [gets $dat line]} {
  set x [split $line =]
  set y [split [lindex $x 1] ,]
}

Same as you would in Ada. So? What's the point of asking the question?

You seem to be making the statement "your method is not useful because there
are some situations where you need something more sophisticated."  But that
doesn't make it useless, any more than arrays in Ada are useless just
because they have to fit in memory, or integers are useless because GNAT
can't declare one ranging from 0..2**360. 

> When is split useful?

Asking such a thing is like asking if arrays are useful, given that
sometimes you have DAT tapes that won't fit in memory. It's useful whenever
you have a string and you want to break it into substrings based on
separator characters. Happens all the time. 

> The result of a split in your example is, I presume, a list in each
> case (correct?).

Yes.

> This list has a lot of entries some of which might
> be of interest. Which one do you need?

Perhaps all of them. Perhaps only some of them. So? If I only needed a few
specific values, I'd probably already be storing them in a built-in map
(hastable) structure. :-)

"Your result is an array. Which element do you need?" It's a pointless
question. That "split" doesn't implement your entire program's semantics
shouldn't be surprising. Hashtables don't tell you what value you should be
using to look up data of interest either. That doesn't make hashtables
useless.

I'm really confused. First someone argues that you don't need variable-sized
arrays because you can use recursion to build up the array you want,
pointing out that recursion is natural in LISP. Then I introduce something
like split, and the argument is "to work with it, you might need something
like map()", which is natural in LISP. Huh?

> In this case you would either have to know the correct index or
> use a table,

Or if you're iterating over all of them for some reason, you just iterate
over all of them. How is the lack of a "split" function superior to having a
split function, if you don't know what you're looking for in either case?

> Splitting is not parsing :-)

Not very sophisticated parsing, no. So?

Note that if you expect (for example) exactly one = in the list, you do
things like

set x [split $y =]
if {2 != [llength $x]} {error "Need exactly one ="}
.... use $x ....
 
> : How long did it take you to write the unbounded array package? To compile
> : it? :-)
> 
> How long will it take to write the code that actually works with
> the values split into a list?

Depends what you want to do with them. Just like in Ada. So? "How long will
it take you to write the code that indexes into an array and uses the
value?"  What kind of answer are you expecting?

Part of my point in asking that was "say it takes me 2 seconds to split the
file, and your Ada can do it in 1 second, but you spend 10,000 seconds
writing the code to support that". How often are you going to run your code?

The other part of my point in asking is that you still have to write that
code, and I don't. :-) Of course, once you no longer need to write that code
because it's widely available in a widely-used library, then Ada becomes
easy for newbies to get used to again. :-)

> In how many cases can you assume these values are homogenous enough
> to justify the omission of separate treatment?

Almost always that I'm not reading from a file. When I *am* reading from a
file, it's no harder to check it's accurate when I'm using split than when
I'm using something else. 

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

They looked up at me like I was a T-bone steak
  walking into an all-you-can-eat seafood buffet.



  reply	other threads:[~2002-08-05 17:48 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 [this message]
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
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