On Fri, Jan 22, 2021 at 09:47:24AM -0500, jbranso--- via Bug reports for GUILE, 
GNU's Ubiquitous Extension Language wrote:
> Ricardo Wurmus <rek...@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: signature.asc
Description: Digital signature

  • 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
    • bug#46014:... Bug reports for GUILE, GNU's Ubiquitous Extension Language

Reply via email to