chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] lambda's in a hash table


From: Claude Marinier
Subject: Re: [Chicken-users] lambda's in a hash table
Date: Sat, 5 Apr 2014 13:45:48 -0400 (EDT)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)



On Sat, 5 Apr 2014, Thomas Chust wrote:
On 2014-04-05 01:54, Claude Marinier wrote:
[...]
I would like to have the compiler do some of this for me. I probably
cannot write a literal hash table but I expected to be able to write a
literal association list. I have tried this but it does not work.
[...]
(define a-list
 `(
    (dot  . ,(lambda () (display "dot\n")))
    (dash . ,(lambda () (display "dash\n")))
  ))
[...]

Hello,

what you have written down here is not a literal list, but a
quasiquotation, which is just syntactic sugar that expands to an
expression dynamically constructing a list.

Nevertheless, the program you posted works just fine as it is. The only
problem I can see with it is that nothing visible happens because

[...]
(let ((func-dot (hash-table-ref dict 'dot))
      (func-dash (hash-table-ref dict 'dash)))
  func-dot
  func-dash)
[...]

doesn't call the two procedures. To actually run the procedures, you
would have to write something like

(let ((func-dot (hash-table-ref dict 'dot))
      (func-dash (hash-table-ref dict 'dash)))
 (func-dot)
 (func-dash))

That works. Thank you.

I was so close. I think I lost track of the many variations I tried. :-(

--
Claude Marinier




reply via email to

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