can't make symbol keyed hash table

Bug #181366 reported by Ken Dickey
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Low
Abdulaziz Ghuloum

Bug Description

Ikarus Scheme version 0.0.2patched+ (revision 1330, build 2008-01-05)
Copyright (c) 2006-2007 Abdulaziz Ghuloum

> (import (rnrs hashtables (6)))
> (define st (make-hashtable symbol-hash eq?))
Unhandled exception
 Condition components:
   1. &error
   2. &who: ikarus
   3. &message: "primitive not supported yet"
   4. &message: "please file a bug report to help us prioritize our goals"
   5. &url: "https://bugs.launchpad.net/ikarus/+filebug"
   6. &irritants: (make-hashtable)
>

Related branches

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 181366] can't make symbol keyed hash table

Just a question: Is there a reason why make-eq-hashtable doesn't fit
the bill?

It seems to be doing at least the same thing you wanted, given that
the comparison predicate you want to use is eq.

Revision history for this message
Ken Dickey (ken-dickey) wrote :

On Tuesday 08 January 2008 02:33:23 pm Abdulaziz Ghuloum wrote:
> Just a question: Is there a reason why make-eq-hashtable doesn't fit
> the bill?

I wanted to limit the keys be symbols.

I did switch now using an eq-hashtable.

This is not a show-stopper for me, I can use a cover-function. I just did
what the error diagnostic suggested was good citizenship.

Cheers,
-KenD

BTW: THANKS VERY MUCH FOR IKARUS!! I am having much fun learning the
language called "R6RS Scheme". ;^)

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

On Jan 8, 2008, at 6:16 PM, Ken Dickey wrote:

> This is not a show-stopper for me, I can use a cover-function. I
> just did
> what the error diagnostic suggested was good citizenship.

Thanks. I'll mark this as a low priority for now since, as you said,
it's not a show-stopper. I'll bump it if more people need it.

> BTW: THANKS VERY MUCH FOR IKARUS!! I am having much fun learning the
> language called "R6RS Scheme". ;^)

Glad to be of service :-)

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
leppie (leppie) wrote :

Unhandled exception
 Condition components:
   1. &error
   2. &who: ikarus
   3. &message: "primitive not supported yet"
   4. &message: "please file a bug report to help us prioritize our goals"
   5. &url: "https://bugs.launchpad.net/ikarus/+filebug"
   6. &irritants: (make-eqv-hashtable)

Was not sure if I should create a new report.

Cheers

leppie

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

It's fine here. Question to help me out: what are you using make-eqv-hashtable for? (I have only found eq hash tables useful, so, I'm interested in knowing what people use eqv hash tables for)

Revision history for this message
leppie (leppie) wrote :

I use chars or numbers for keys in my case. Specifically this group-by function:

; returns a list of grouping
(define (group-by sel proc lst)
  (let ((ht (make-eqv-hashtable)))
    (for-each
      (lambda (x)
        (let ((key (proc x)))
          (hashtable-update! ht key
            (lambda (o)
              (cons (sel x) o))
            '())))
      lst)
    (vector->list
      (vector-map
        (lambda (key)
          (make-grouping key (hashtable-ref ht key '())))
        (hashtable-keys ht)))))

Revision history for this message
leppie (leppie) wrote :

I am not so sure about strings though. I might need to fall back to make-hashtable.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 181366] Re: can't make symbol keyed hash table

On Apr 20, 2008, at 2:57 PM, leppie wrote:
> I am not so sure about strings though. I might need to fall back to
> make-hashtable.

Which I also don't have. :-)

Revision history for this message
leppie (leppie) wrote :

Hmmm, I just did the following:

Ikarus Scheme version 0.0.3+ (revision 1452, build 2008-04-20)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (define ht (make-eq-hashtable))

> (hashtable-set! ht 1 'one)

> (hashtable-set! ht 2 'two)

> (hashtable-set! ht 1 'oneone)

> (hashtable-keys ht)
#(1 2)

> (hashtable-set! ht #\c 'two)

> (hashtable-set! ht "hello" 'two)

> (hashtable-keys ht)
#(1 2 #\c "hello")

> (hashtable-set! ht "hello" 'twotwo)

> (hashtable-set! ht #\c 'twof)

> (hashtable-keys ht)
#(1 2 #\c "hello" "hello")

It appears your eq-hashtable is closer to eqv, in fact on IronScheme I dont make that distinction either :)

Revision history for this message
leppie (leppie) wrote :

I still dont understand this craziness between eq? and eqv? and all the implementation-dependent behaviour that makes them distinct. IMO the distinction should be much clearer.

Anyways, make-eq-hashtable and make-eqv-hashtable should probably be one and the same thing on Ikarus (as it behaves like I expect an eqv-hashtable to behave).

Cheers

leppie

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

On Apr 23, 2008, at 11:48 AM, leppie wrote:
> I still dont understand this craziness between eq? and eqv? and all
> the
> implementation-dependent behaviour that makes them distinct. IMO the
> distinction should be much clearer.
>
> Anyways, make-eq-hashtable and make-eqv-hashtable should probably
> be one
> and the same thing on Ikarus (as it behaves like I expect an eqv-
> hashtable to behave).

In Ikarus, they would only differ in non-fixnum numbers (bignums,
ratnums,
flonums, etc.) where eq? and eqv? differ. For everything else, they
behave the same. That's why I did not feel it was so urgent to add them
to Ikarus.

Revision history for this message
Ramana Kumar (xrchz) wrote :

I would like to be able to use make-hashtable and equal-hash to use a hashtable for memoizing a function (the key would be the argument list). Unfortunately it seems make-hashtable is not yet implemented - so here's a request. (Or suggestions for a better key for memoization? I mean I could use a different non-structured key for each individual function, but what about in general?)

Revision history for this message
Ramana Kumar (xrchz) wrote :

I would also like hashtables for other things... so this is a request to increase the priority of the implementation of make-hashtable.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Added in rev 1642.

Changed in ikarus:
status: Confirmed → Fix Committed
Revision history for this message
Ramana Kumar (xrchz) wrote :

what did you add?
Ikarus Scheme version 0.0.3+ (revision 1691, build 2008-11-23)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (equal-hash)
Unhandled exception
 Condition components:
   1. &error
   2. &who: ikarus
   3. &message: "primitive not supported yet"
   4. &message: "please file a bug report to help us prioritize our goals"
   5. &url: "https://bugs.launchpad.net/ikarus/+filebug"
   6. &irritants: (equal-hash)

Revision history for this message
Ramana Kumar (xrchz) wrote :

I would like equal-hash =)

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Sorry, the original bug report was about make-hashtable and symbol-hash, which were implemented in addition to string-hash, string-ci-hash, and make-eqv-hashtable.

There was some discussion recently about equal-hash in
  http://groups.google.com/group/ikarus-users/msg/fc35e1a7403162f4

Please do read that subthread and let me know if there's something I missed.

Aziz,,,

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

On Nov 27, 2008, at 11:52 AM, Ramana Kumar wrote:

> I would like equal-hash =)

BTW, you might want to experiment with "hash-consing" your
data structures and using eq-hashtables for memoization.
Just an idea. You probably want to check with Dan to see
what he has to say.

Aziz,,,

Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.