[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?
From: |
tomas |
Subject: |
bug#46014: (define (thunk) (lambda (x) x)) should be a compile error? |
Date: |
Fri, 22 Jan 2021 17:29:18 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Jan 22, 2021 at 09:47:24AM -0500, jbranso--- via Bug reports for GUILE,
GNU's Ubiquitous Extension Language wrote:
> Ricardo Wurmus <rekado@elephly.net> writes:
>
> > Hi Joshua,
> >
> >> When I look at
> >>
> >> #+BEGIN_SRC scheme
> >> (define (thunk)
> >> (lambda (x)
> >> x))
> >> #+END_SRC
> >
> > […]
> >
> >> My thought is, this is clearly a mistake. This person needs to change
> >> the above code.
> >
> > How is this clearly a mistake? The definition of “thunk” above is
> > perfectly fine and also common.
>
> Thanks again for responding. I'm still learning scheme, and it's cool
> that this email chain has helped clarify some things. :)
>
> Ahh. I see now that the proper way to call thunk is to do this:
> ((thunk) "the")
> $1 = "the"
>
> I had assumed that every time one called thunk, it would result in a
> runtime error. I did not realize that there was a way to properly call
> thunk. Wow. Scheme is truly impressive.
>
> Interestingly, I had wrongly assumed that
>
> #+BEGIN_SRC scheme
> (thunk "test\n") ;; I assumed program execution would stop here
> (display "Hello World\n")
> #+END_SRC
>
> program execution would stop at (thunk "test\n"). But it actually
> caries on with execution of the program:
What happens is an "exception". It can be handled (then it's up
to the exception handler to end the program or do something else).
> #+BEGIN_SRC scheme
> <stdin>:5: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.
> Hello World
> #+END_SRC
This is the REPL's exception handler talking to you. It's there to help
you debug the problem.
Were it a standalone program, it would have terminated right away.
(note that I'm not the most appropriate person to explain such things,
I can barely wrap my head around them :-)
Cheers
[1] https://www.gnu.org/software/guile/docs/master/guile.html/Exceptions.html
- tomás
signature.asc
Description: Digital signature
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Joshua Branson, 2021/01/20
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Ricardo Wurmus, 2021/01/21
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Stefan Israelsson Tampe, 2021/01/21
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Joshua Branson, 2021/01/21
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Ricardo Wurmus, 2021/01/21
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Joshua Branson, 2021/01/22
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?,
tomas <=
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Ricardo Wurmus, 2021/01/23
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Joshua Branson, 2021/01/23
- bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?, Ricardo Wurmus, 2021/01/23
bug#46014: closing the bug report...hopefully, Joshua Branson, 2021/01/23