home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / lisp / 2204 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  1.3 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!yeh
  2. From: yeh@cs.purdue.EDU (Wei Jen Yeh)
  3. Newsgroups: comp.lang.lisp
  4. Subject: portable O(1) strlen
  5. Keywords: strlen, format, AKCL
  6. Message-ID: <19247@ector.cs.purdue.edu>
  7. Date: 13 Aug 92 07:23:45 GMT
  8. Sender: news@cs.purdue.EDU
  9. Organization: Department of Computer Science, Purdue University
  10. Lines: 19
  11.  
  12. Hello,
  13.   I just found a bug in my program caused by thinking that
  14.     (array-dimension (format NIL "1234") 0) = 4.
  15. Strange thing is that the answer is correct if I call string-downcase
  16. on the value that format returns.  I can understand why they behave so.
  17. But are there some related rules on this matter? I checked Cltl I, but could
  18. not find discussions on strlen in the string section.  A quick solution that
  19. I'm using now is to (1) scan the array, (2) coerce it to list then call
  20. length, or (3) write a C function.  Solution (1) doesn't seem safe, since
  21. I cannot be sure that the strings will be padded with some fixed chars.
  22. (2) is O(n), and (3) is not portable.
  23.  
  24. So, is there a portable O(1) STRLEN?
  25.  
  26. Thanks.
  27. Wei Jen Yeh                      yeh@cs.purdue.edu
  28.                                  Department of Computer Science
  29.                                  Purdue University
  30.                                  West Lafayette, Indiana
  31.