From: Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com>
To: Matt Wette <mwette@alumni.caltech.edu>
Cc: guile-user@gnu.org
Subject: Re: syncase code issue 1.8.8 -> 2.0.11
Date: Thu, 18 Sep 2014 12:20:05 +0200 [thread overview]
Message-ID: <87k351ut62.fsf@taylan.uni.cx> (raw)
In-Reply-To: <2097C007-9993-4AA1-A5F7-209A7DADD6CE@alumni.caltech.edu> (Matt Wette's message of "Wed, 17 Sep 2014 18:18:05 -0700")
Matt Wette <mwette@alumni.caltech.edu> writes:
> Hi Folks,
>
> Anyone interested in looking at my syntax-case code? I wrote this
> several years ago under 1.8.8. Now moving to 2.0.11: not working :(.
>
> Matt
Hi Matt,
I see your code is doing things like
(format #t "~a\n" (define mt (make-tokiz "abc=def")))
The argument to `format' there is necessarily an "expression" in the
grammar of Scheme. Definitions like (define ...) are not a valid type
of expression in Scheme.
The only places you can use definitions are
- the top-level of a program/library
- the *beginning* of a "code body" like the body of a `lambda', the body
of a `let', etc. can have a sequence of definitions; the first
non-definition expression terminates that sequence
- when you have a (begin ...) form in a position where a definition
would otherwise be allowed, then the body of this begin may also start
with a series of definitions; again, the first non-definition
expression terminates this sequence
The following are examples of well-formed code:
(define (foo)
(define (helper1)
...)
(define (helper2)
...)
(do-something-with (helper1))
(do-something-with (helper2)))
(let (...)
(define (helper1)
...)
...
(do-something-with (helper1)))
(let (...)
(begin
(define (helper1)
...)
(define (helper2)
...)
(do-something-with (helper1)))
(do-something-with (helper2)))
The following are not well-formed:
(define (foo)
(do-something)
(define (helper1)
...)
(do-something-with (helper1)))
;; Because the helper1 definition is in the middle of the foo lambda
;; body, with a preceding non-definition expression.
(let (...)
(do-something)
(begin
(define (helper1)
...)
(do-something-with (helper1)))
(do-something)
;; Because the whole `begin' is in the middle of a let body, so the
;; begin may have no definitions at all. The begin is "in an expression
;; context".
Hope that helps.
Taylan
next prev parent reply other threads:[~2014-09-18 10:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 1:18 syncase code issue 1.8.8 -> 2.0.11 Matt Wette
2014-09-18 7:49 ` Panicz Maciej Godek
2014-09-18 10:20 ` Taylan Ulrich Bayirli/Kammer [this message]
2014-09-18 12:35 ` Matt Wette
-- strict thread matches above, loose matches on Subject: below --
2014-09-18 14:08 mwette
2014-09-19 3:54 ` Matt Wette
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=87k351ut62.fsf@taylan.uni.cx \
--to=taylanbayirli@gmail.com \
--cc=guile-user@gnu.org \
--cc=mwette@alumni.caltech.edu \
/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).