[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: macro like "my" in Perl

From: Ken Anderson
Subject: Re: macro like "my" in Perl
Date: Tue, 02 Jul 2002 11:34:53 -0400

At 10:45 AM 6/26/2002, Lynn Winebarger wrote:
On Wednesday 26 June 2002 08:15, Ken Anderson wrote:
> In Jscheme, not guile, i recently redefined (define) so that groups of
> internal defines are turned into let* or letrec as appropriate, so you can
> write code without additional indenting:

How do you handle
(let ()
   (define (even? x) (if (= x 0) #t (not (odd? (- x 1)))))
   (define foo (even? 7))
   (define (odd? x) (if (= x 1) #t (not (even? (- x 1))))))
Rather than let, say define.
(define (?)

This would be converted into
  (letrec ((even? (lambda (x) (if (= x 0) #t (not (odd? (- x 1)))))))
    (let* ((foo (even? 7)))
      (letrec ((odd? (lambda (x)
                       (if (= x 1) #t (not (even? (- x 1)))))))))))

Procedures that refer to each other should be declared in a group, as is usually done with letrec.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]