unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-user@gnu.org
Subject: Re: make-hash-table: Wrong type argument
Date: Thu, 10 Jul 2008 09:35:54 +0200	[thread overview]
Message-ID: <871w228a3p.fsf@gnu.org> (raw)
In-Reply-To: d16b1c80807090134i70e23fd5x2f64abe05dbdf864@mail.gmail.com

Hi,

"Shakthi Kannan" <shakthimaan@gmail.com> 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	other threads:[~2008-07-10  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09  8:34 make-hash-table: Wrong type argument Shakthi Kannan
2008-07-10  7:35 ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871w228a3p.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).