guile-user
[Top][All Lists]
Advanced

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

Re: make-hash-table: Wrong type argument


From: Ludovic Courtès
Subject: Re: make-hash-table: Wrong type argument
Date: Thu, 10 Jul 2008 09:35:54 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Hi,

"Shakthi Kannan" <address@hidden> writes:

> Newbie here. I am trying to pass key/value to a procedure to add it to
> the hash-table. It fails at:
>
> "you"ERROR: In procedure hash_fn_create_handle_x:
> ERROR: Wrong type argument in position 1: "foo"

Note: If you run Guile with `--debug', you should get a nice backtrace
here.

The problem is that you pass `hash-set!' the string "foo" as its first
argument, while it expects a hash table (as returned by
`make-hash-table').

I think there is some confusion:

> (define make-dictionary
>   (lambda (name size)
>     (lambda ()
>       (define name (make-hash-table size)))))

`define' here is an "internal define", i.e., it defines a variable
that's local to the lambda where it occurs.  Furthermore, `name' is
taken literally, it's not substituted by the actual parameter passed to
`make-dictionary'.

Hope this helps,
Ludovic.





reply via email to

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