From: Josef Eschgfaeller
Subject: length
Date: 
Message-ID: <Pine.LNX.4.04.9906201134060.17236-100000@arbzi.zuhause.fe>
How fast is length for strings (or vectors)? If I understand well,
when there is a fill pointer, the result should be immediate. But
for a normal string, does Lisp go through memory until a terminating
symbol is reached, or is there always a value associated to each
string, which gives the length? I suspect the first one is true.

J. Eschgfaeller

From: Nick Levine
Subject: Re: length
Date: 
Message-ID: <7kifc8$q4n$1@epos.tesco.net>
Josef Eschgfaeller wrote in message ...
>
>How fast is length for strings (or vectors)? If I understand well,
>when there is a fill pointer, the result should be immediate. But

Indeed it ought.

>for a normal string, does Lisp go through memory until a terminating
>symbol is reached, or is there always a value associated to each
>string, which gives the length? I suspect the first one is true.


I guess it's up to the implementation, but I find it hard to imagine an
implementor not caching the length of the string in an easily accessible
location.

If you want to be paranoid, time length on strings of length 1000 , 10000,
100000, 1000000 etc on your implementation. Should take the same time (naff
all)  in each case.

- n
From: Erik Naggum
Subject: Re: length
Date: 
Message-ID: <3138883782875459@naggum.no>
* Josef Eschgfaeller <ยทยทยท@felix.unife.it>
| How fast is length for strings (or vectors)?

  LENGTH is a simple accessor for any subtype of ARRAY.

| But for a normal string, does Lisp go through memory until a terminating
| symbol is reached, or is there always a value associated to each string,
| which gives the length?  I suspect the first one is true.

  why?  Common Lisp is designed, unlike C.  do yourself a favor and stop
  thinking in C terms.  and please note that very few languages other than
  C use strings that cannot hold all possible characters.

#:Erik
-- 
@1999-07-22T00:37:33Z -- pi billion seconds since the turn of the century