unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?
@ 2021-01-21  2:04 jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  2021-01-21 13:56 ` Ricardo Wurmus
  2021-01-23 15:07 ` bug#46014: closing the bug report...hopefully jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
  0 siblings, 2 replies; 12+ messages in thread
From: jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-01-21  2:04 UTC (permalink / raw)
  To: 46014

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!





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-01-23 17:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  2:04 bug#46014: (define (thunk) (lambda (x) x)) should be a compile error? jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-01-21 13:56 ` Ricardo Wurmus
2021-01-21 18:16   ` Stefan Israelsson Tampe
2021-01-21 20:11     ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-01-21 20:09   ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-01-21 22:27     ` Ricardo Wurmus
2021-01-22 14:47       ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-01-22 16:29         ` tomas
2021-01-23 15:02         ` Ricardo Wurmus
2021-01-23 15:17           ` jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language
2021-01-23 17:23             ` Ricardo Wurmus
2021-01-23 15:07 ` bug#46014: closing the bug report...hopefully jbranso--- via Bug reports for GUILE, GNU's Ubiquitous Extension Language

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).