emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#46014: closed ((define (thunk) (lambda (x) x)) should be a compile e


From: GNU bug Tracking System
Subject: bug#46014: closed ((define (thunk) (lambda (x) x)) should be a compile error? )
Date: Sat, 23 Jan 2021 17:24:02 +0000

Your message dated Sat, 23 Jan 2021 18:23:22 +0100
with message-id <87sg6rk1o5.fsf@elephly.net>
and subject line Re: bug#46014: (define (thunk) (lambda (x) x)) should be a 
compile error?
has caused the debbugs.gnu.org bug report #46014,
regarding (define (thunk) (lambda (x) x)) should be a compile error? 
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
46014: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=46014
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: (define (thunk) (lambda (x) x)) should be a compile error? Date: Wed, 20 Jan 2021 21:04:47 -0500
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!



--- End Message ---
--- Begin Message --- Subject: Re: bug#46014: (define (thunk) (lambda (x) x)) should be a compile error? Date: Sat, 23 Jan 2021 18:23:22 +0100 User-agent: mu4e 1.4.13; emacs 27.1
Joshua Branson <jbranso@dismail.de> writes:

> Feel free to close this bug report.  I don't believe I was able to
> demonstrate any examples of the compiler misbehaving.

Okay, closing!

-- 
Ricardo


--- End Message ---

reply via email to

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