From: <tomas@tuxteam.de>
To: 46014@debbugs.gnu.org
Subject: bug#46014: (define (thunk) (lambda (x) x)) should be a compile error?
Date: Fri, 22 Jan 2021 17:29:18 +0100 [thread overview]
Message-ID: <20210122162918.GA27617@tuxteam.de> (raw)
In-Reply-To: <87o8hhyqo3.fsf@dismail.de>
[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2021-01-22 16:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210122162918.GA27617@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=46014@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).