Hello!

Consider this bit of simple code:

#+BEGIN_SRC scheme

(define (thunk)
   (lambda (x)
     x))

(thunk) ;; works ok, I guess.
(thunk "hello world!\n")  ;; runtime error

;;; <stdin>:1074:0: warning: possibly wrong number of arguments to `thunk'
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Wrong number of arguments to #<procedure thunk ()>

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
#+END_SRC

Guile will compile this program seemingly with no error.  Guile will
correctly report at runtime that procedure '(thunk "hello world!\n")'
takes no arguments, but it's lambda accepts 1 argument.  Would it be
possible to report this error at compile time?  Would that be
advantageous?

I personally can consider one time where reporting this error at
compile time would be advantageous.  Here's how I found out about this
error.  (would ya'll call this an error/bug/feature)?

#+BEGIN_SRC scheme
(use-modules
 (srfi srfi-9))

(define-record-type <lunch>
  (make-lunch food duration location)
  lunch?
  (food lunch-food)
  (duration lunch-duration)
  (location lunch-location))

(define dine-out
  (make-lunch "pizza" "30 min" "downtown"))

;; maybe this should be a syntax error instead of a runtime error?
(define (list-lunch)
     (match-lambda (($ <lunch> food duration location )
                    (list food duration location))))

;; this is the proper way to do it.
(define list-lunch
     (match-lambda (($ <lunch> food duration location )
                    (list food duration location))))
#+END_SRC

I eventually discovered what the issue was, but I had to run the code
to discover it.  

I don't know if this is a silly bug report.  If it is, sorry for the
noise.

Thanks,

Joshua

P.S.  Guile's error messages at compile time and runtime are super
well written.  Thanks!



  • bug#46014: (def... Bug reports for GUILE, GNU's Ubiquitous Extension Language
    • bug#46014:... Ricardo Wurmus
      • bug#46... Stefan Israelsson Tampe
        • bu... Bug reports for GUILE, GNU's Ubiquitous Extension Language
      • bug#46... Bug reports for GUILE, GNU's Ubiquitous Extension Language
        • bu... Ricardo Wurmus
          • ... Bug reports for GUILE, GNU's Ubiquitous Extension Language
            • ... tomas
            • ... Ricardo Wurmus
              • ... Bug reports for GUILE, GNU's Ubiquitous Extension Language
                • ... Ricardo Wurmus

Reply via email to