Perhaps it's useful to compare with the let-and macro,
(define-syntax let-and (syntax-rules () ((let-and (expr) clause clauses ...) (and expr (let-and clause clauses ...))) ((let-and (name expr) clause clauses ...) (let ((name expr)) (and name (let-and clause clauses ...)))) ((let-and expr) expr)))
where you'd do
(let-and a (foo (a->foo a)) (foo->bar foo))
which means
If a is false, return false. Otherwise bind foo to (a->foo a). If foo is now false, return false. Otherwise, return (foo->bar foo).
Corresponding pike code would be
a && a->foo && a->foo->bar
so in this example, let-and isn't terribly useful, it makes more sense if you have something more komplext instead of ->foo. A more realistic use could be
(define (match pattern expr) (if (atom? pattern) (if (eq? '* pattern) (list expr) (and (eq? pattern expr) '())) (let-and ((pair? expr)) (op-matches (match (application-op pattern) (application-op expr))) (arg-matches (match (application-arg pattern) (application-arg expr))) (append op-matches arg-matches))))
/ Niels Möller (igelkottsräddare)
Previous text:
2003-09-28 11:43: Subject: zero_type();
I wished for this years ago and suggested the "squiggly pointer" operator ~> so I'm glad to see this idea revived. (The ~> syntax is rather ugly if ~ isn't vertically centered in the current font so perhaps => or ?> works better.)
Any news from the conference regarding this, or were you simply referring to our old discussions?
/ Jonas Walldén