* Odd Behavior @ 2011-01-31 18:44 Noah Lavine 2011-01-31 19:20 ` Noah Lavine ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Noah Lavine @ 2011-01-31 18:44 UTC (permalink / raw) To: guile-devel Hello all, I ran into an error message in Guile, and I'm not sure how to track down the cause of it. I used a file called test.scm with the following contents: #!guile !# (define (codegen) #`(let ((message "hello, world!\n")) (display message))) (define-syntax test (lambda (x) (syntax-case x () (_ (codegen))))) (test) Then I opened guile and did (load "test.scm"), and got this: ;;; compiling test.scm ;;; WARNING: compilation of test.scm failed: ;;; key wrong-type-arg, throw_args (#f "Wrong type to apply: ~S" (#f) (#f)) hello, world! As far as I can tell, this means that Guile tried to compile test.scm, failed, and then interpreted it correctly. Is that right? If so, is there a way to get more information about where the wrong-type-arg error was thrown? I'd also love to know any way to get more information about errors that happen during macroexpansion in general. I've been having quite a bit of trouble figuring out what is going wrong at different points in peg.scm, while I'm trying to convert it to syntax-case. Thanks, Noah ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd Behavior 2011-01-31 18:44 Odd Behavior Noah Lavine @ 2011-01-31 19:20 ` Noah Lavine 2011-01-31 19:36 ` Noah Lavine 2011-01-31 19:41 ` Andy Wingo 2011-01-31 20:12 ` Andy Wingo 2 siblings, 1 reply; 6+ messages in thread From: Noah Lavine @ 2011-01-31 19:20 UTC (permalink / raw) To: guile-devel Hello again, I tried finding the error by running compile-file, but I got the following Guile session: scheme@(guile-user)> (compile-file "test.scm") ice-9/boot-9.scm:119:21: Wrong type to apply: #f Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user)> ,bt Nothing to debug. boot-9.scm:119 is in the definition of custom-throw-handler, which is part of the implementation of catch. Noah On Mon, Jan 31, 2011 at 1:44 PM, Noah Lavine <noah.b.lavine@gmail.com> wrote: > Hello all, > > I ran into an error message in Guile, and I'm not sure how to track > down the cause of it. I used a file called test.scm with the following > contents: > > #!guile > !# > > (define (codegen) > #`(let ((message "hello, world!\n")) > (display message))) > > (define-syntax test > (lambda (x) > (syntax-case x () > (_ (codegen))))) > > (test) > > Then I opened guile and did (load "test.scm"), and got this: > > ;;; compiling test.scm > ;;; WARNING: compilation of test.scm failed: > ;;; key wrong-type-arg, throw_args (#f "Wrong type to apply: ~S" (#f) (#f)) > hello, world! > > As far as I can tell, this means that Guile tried to compile test.scm, > failed, and then interpreted it correctly. Is that right? If so, is > there a way to get more information about where the wrong-type-arg > error was thrown? > > I'd also love to know any way to get more information about errors > that happen during macroexpansion in general. I've been having quite a > bit of trouble figuring out what is going wrong at different points in > peg.scm, while I'm trying to convert it to syntax-case. > > Thanks, > Noah > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd Behavior 2011-01-31 19:20 ` Noah Lavine @ 2011-01-31 19:36 ` Noah Lavine 0 siblings, 0 replies; 6+ messages in thread From: Noah Lavine @ 2011-01-31 19:36 UTC (permalink / raw) To: guile-devel Oh, sorry. I solved that problem (it needed an eval-when). That might also suggest some solutions to peg.scm oddness. I'd still be interested in any tips on debugging macros, though. Thanks, Noah On Mon, Jan 31, 2011 at 2:20 PM, Noah Lavine <noah.b.lavine@gmail.com> wrote: > Hello again, > > I tried finding the error by running compile-file, but I got the > following Guile session: > > scheme@(guile-user)> (compile-file "test.scm") > ice-9/boot-9.scm:119:21: Wrong type to apply: #f > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user)> ,bt > Nothing to debug. > > boot-9.scm:119 is in the definition of custom-throw-handler, which is > part of the implementation of catch. > > Noah > > On Mon, Jan 31, 2011 at 1:44 PM, Noah Lavine <noah.b.lavine@gmail.com> wrote: >> Hello all, >> >> I ran into an error message in Guile, and I'm not sure how to track >> down the cause of it. I used a file called test.scm with the following >> contents: >> >> #!guile >> !# >> >> (define (codegen) >> #`(let ((message "hello, world!\n")) >> (display message))) >> >> (define-syntax test >> (lambda (x) >> (syntax-case x () >> (_ (codegen))))) >> >> (test) >> >> Then I opened guile and did (load "test.scm"), and got this: >> >> ;;; compiling test.scm >> ;;; WARNING: compilation of test.scm failed: >> ;;; key wrong-type-arg, throw_args (#f "Wrong type to apply: ~S" (#f) (#f)) >> hello, world! >> >> As far as I can tell, this means that Guile tried to compile test.scm, >> failed, and then interpreted it correctly. Is that right? If so, is >> there a way to get more information about where the wrong-type-arg >> error was thrown? >> >> I'd also love to know any way to get more information about errors >> that happen during macroexpansion in general. I've been having quite a >> bit of trouble figuring out what is going wrong at different points in >> peg.scm, while I'm trying to convert it to syntax-case. >> >> Thanks, >> Noah >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd Behavior 2011-01-31 18:44 Odd Behavior Noah Lavine 2011-01-31 19:20 ` Noah Lavine @ 2011-01-31 19:41 ` Andy Wingo 2011-01-31 20:12 ` Andy Wingo 2 siblings, 0 replies; 6+ messages in thread From: Andy Wingo @ 2011-01-31 19:41 UTC (permalink / raw) To: Noah Lavine; +Cc: guile-devel On Mon 31 Jan 2011 19:44, Noah Lavine <noah.b.lavine@gmail.com> writes: > (define (codegen) > #`(let ((message "hello, world!\n")) > (display message))) > > (define-syntax test > (lambda (x) > (syntax-case x () > (_ (codegen))))) > > (test) > > Guile tried to compile test.scm, failed, and then interpreted it > correctly. Is that right? Yep; as mentioned in the NEWS entry, "** Functions needed by macros at expand-time need to be present at expand-time." I'm sure you know that already, and your real question: > is there a way to get more information about where the wrong-type-arg > error was thrown? There are several ways this could be improved: * The exception should be about an unbound variable, not about applying #f. I'll see what I can do there. * The exception could be printed with an appropriate printer. See http://thread.gmane.org/gmane.lisp.guile.devel/11066/focus=11158. * You should see the source location of the error and the containing forms. Probably that thread is the best bet for making a start at this. Regards, Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd Behavior 2011-01-31 18:44 Odd Behavior Noah Lavine 2011-01-31 19:20 ` Noah Lavine 2011-01-31 19:41 ` Andy Wingo @ 2011-01-31 20:12 ` Andy Wingo 2011-01-31 20:09 ` Noah Lavine 2 siblings, 1 reply; 6+ messages in thread From: Andy Wingo @ 2011-01-31 20:12 UTC (permalink / raw) To: Noah Lavine; +Cc: guile-devel On Mon 31 Jan 2011 19:44, Noah Lavine <noah.b.lavine@gmail.com> writes: > ;;; compiling test.scm > ;;; WARNING: compilation of test.scm failed: > ;;; key wrong-type-arg, throw_args (#f "Wrong type to apply: ~S" (#f) (#f)) > hello, world! Now it does: scheme@(guile-user)> (load "/tmp/test.scm") ;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-autocompile argument to disable. ;;; compiling /tmp/test.scm ;;; WARNING: compilation of /tmp/test.scm failed: ;;; key unbound-variable, throw_args (#f "Unbound variable: ~S" (codegen) #f) hello, world! Still ugly, but better. Thanks for the example. A -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd Behavior 2011-01-31 20:12 ` Andy Wingo @ 2011-01-31 20:09 ` Noah Lavine 0 siblings, 0 replies; 6+ messages in thread From: Noah Lavine @ 2011-01-31 20:09 UTC (permalink / raw) To: Andy Wingo; +Cc: guile-devel Wow, great! On Mon, Jan 31, 2011 at 3:12 PM, Andy Wingo <wingo@pobox.com> wrote: > On Mon 31 Jan 2011 19:44, Noah Lavine <noah.b.lavine@gmail.com> writes: > >> ;;; compiling test.scm >> ;;; WARNING: compilation of test.scm failed: >> ;;; key wrong-type-arg, throw_args (#f "Wrong type to apply: ~S" (#f) (#f)) >> hello, world! > > Now it does: > > scheme@(guile-user)> (load "/tmp/test.scm") > ;;; note: autocompilation is enabled, set GUILE_AUTO_COMPILE=0 > ;;; or pass the --no-autocompile argument to disable. > ;;; compiling /tmp/test.scm > ;;; WARNING: compilation of /tmp/test.scm failed: > ;;; key unbound-variable, throw_args (#f "Unbound variable: ~S" (codegen) #f) > hello, world! > > Still ugly, but better. Thanks for the example. > > A > -- > http://wingolog.org/ > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-01-31 20:12 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-01-31 18:44 Odd Behavior Noah Lavine 2011-01-31 19:20 ` Noah Lavine 2011-01-31 19:36 ` Noah Lavine 2011-01-31 19:41 ` Andy Wingo 2011-01-31 20:12 ` Andy Wingo 2011-01-31 20:09 ` Noah Lavine
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).