[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Alist versus Hash-table

From: Peter Bex
Subject: Re: [Chicken-users] Alist versus Hash-table
Date: Tue, 12 Nov 2013 12:24:53 +0100
User-agent: Mutt/

On Tue, Nov 12, 2013 at 03:13:49PM +0400, Loïc Faure-Lacroix wrote:
> Ah right, I believed the update! would add the element to the list 
> destructively. After changing the second variant to include the newly created 
> element when not found. The alist gets much more slower than the hash-table. 
> Now it makes much more sense. The second variant was only fast because it was 
> searching an empty list. I changed the second variant to loop with the 
> returned value of “alist-update!” and it is much more slower now.
> I can’t really argue why alist-update and alist-update! were designed but I 
> was really expecting the element to get automatically added to the list with 
> the destructive version. But I guess for speed reasons, it makes sense to 
> just return a (cons element lst) instead of adding it. The doc should 
> probably be more clear about that.

Unfortunately you can't destructively add anything to the empty list,
as it is atomic.  The only possible way to do this is to cons it, so
that sort of falls out of the way Scheme works.

Perhaps you have a suggestion on how to improve the wording in the manual?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]