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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f316de357ae35e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-05 10:48:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!news-west.rr.com!cyclone.kc.rr.com!news.kc.rr.com!cyclone3.kc.rr.com!news3.kc.rr.com!twister.socal.rr.com.POSTED!not-for-mail Message-ID: <3D4EBA9B.848B572D@san.rr.com> From: Darren New X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions References: <20020730093206.A8550@videoproject.kiev.ua> <20020731182308.K1083@videoproject.kiev.ua> <20020801161052.M1080@videoproject.kiev.ua> <20020802193535.N1101@videoproject.kiev.ua> <3D4EA5DA.E764BFD7@san.rr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 05 Aug 2002 17:48:53 GMT NNTP-Posting-Host: 66.74.216.166 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1028569733 66.74.216.166 (Mon, 05 Aug 2002 10:48:53 PDT) NNTP-Posting-Date: Mon, 05 Aug 2002 10:48:53 PDT Organization: RoadRunner - West Xref: archiver1.google.com comp.lang.ada:27718 Date: 2002-08-05T17:48:53+00:00 List-Id: 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.