speed on default functor

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

speed on default functor

Post by newdep »

Hi lutz,

-> (setq biglist:biglist '( a b c d e ... ... ... ))
(a b c d e ... ... ...)
-> (setq referer biglist)
biglist
->

Do i understand it correclty that when it now comes to speed on this "list"
working on the 'referer results in speed performance? Or can i now also work
on the functor biglist, because its a functor?

(So actualy the 'referer is a pointer based list?)
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

So actualy the 'referer is a pointer based list?
Yes:

Code: Select all

newLISP v.9.9.95 on OSX IPv4 UTF-8, execute 'newlisp -h' for more info.

> (setq biglist:biglist '( a b c d e ... ... ... ))
(a b c d e ... ... ...)
> (setq referer biglist)
biglist
> (setf (referer 0) 'Z)
Z
> biglist:biglist
(Z b c d e ... ... ...)
> referer:biglist
(Z b c d e ... ... ...)
> 

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

So if creating a refererence of the default-function results in reference
data handling this means that also for hash tables its better to work
on a referer of the default-function then on the default-function itself?
(Actualy its better to always work on the referer..?)

What about the speed difference between array-lists and the referer or
what if the default-function would be an array with a referer? Is that
even quicker?
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

There is no measurable speed difference between using the original symbol or a referrer, no matter if it is a hash, array or list which is referred.

Here is as hort textual description how the newLISP evaluator looks at this expression:

Code: Select all

(Foo x)
- Foo gets evaluated and turns up one of five things:

- the context Foo -> proceed with default functor Foo:Foo
- another context Ctx -> proceed with default functor Ctx:Ctx
- a list -> proceed with implicit indexing of a list
- an array -> proceed with implicit indexing of an array
- a string -> proceed with implicit indexing of a string

Foo:Foo -> check the contents of Foo:Foo
Ctx:Ctx -> check the contents of Ctx:Ctx

IF nil -> do hashing with key-string in x
IF list -> do implicit indexing with with number-index in x
IF array -> do implicit indexing with number-index in x
IF string -> do implicit indexing with number-index in x

Locked