lilypond-user
[Top][All Lists]
Advanced

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

Re: Explain error


From: Aaron Hill
Subject: Re: Explain error
Date: Fri, 08 Nov 2019 19:44:43 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-11-08 7:12 pm, Freeman Gilmore wrote:
\version "2.19.83"
#((define h (make-hash-table 114))
(display h)
(hashq-set! h 3 "val3")
(display (hashq-ref h 3)))

Wrong type to apply: #<unspecified>

Could someone explain why I get this error?

"(define h (make-hash-table 114))" returns (or evaluates to) #<unspecified> which is not a procedure. (#<unspecified> is a special value in Scheme, which you can test for with the "unspecified?" predicate.)

It helps to remember that "(proc 1 2 3)" is shorthand for "(apply proc '(1 2 3))". Your original expression, therefore, is functionally equivalent to this:

;;;;
(apply (define h (make-hash-table 114))
  (list (display h)
        (hashq-set! h 3 "val3")
        (display (hashq-ref h 3))))
;;;;

The solution is to use "begin":

%%%%
\version "2.19.83"
#(begin
  (define h (make-hash-table 114))
  (display h)
  (hashq-set! h 3 "val3")
  (display (hashq-ref h 3)))
%%%%


-- Aaron Hill



reply via email to

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