<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<span class="Apple-style-span"
style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span
class="Apple-style-span"
style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 13px;">Hello
<div><br>
</div>
<div>I am having a problem with the following macro:</div>
<div><br>
</div>
<div>
<div>(define-syntax lambda-r</div>
<div> (syntax-rules ()</div>
<div> ((_ args exp ...)</div>
<div> (lambda args</div>
<div> (call-with-current-<wbr>continuation</div>
<div> (lambda (return)</div>
<div> exp ... ))))))</div>
<div><br>
</div>
<div>it's meant to define a lambda-r form, which wraps a lambda in
call/cc, so I can use a "return-like" operator.</div>
<div><br>
</div>
<div>The following is an example of using lambda-r:</div>
<div><br>
</div>
<div><br>
</div>
<div>(define test-return</div>
<div> (lambda-r ()</div>
<div> (let ((input (read)))</div>
<div> (if (number? input)</div>
<div> (if (> input 0)</div>
<div> (begin </div>
<div> (display "positive")</div>
<div> (return input)) ;;
if input is > 0 this should escape out of the procedure</div>
<div> (display "negative or zero"))</div>
<div> (display "not a number"))</div>
<div> (display "no return") ;; if
input is > 0 this shouldn't get displayed</div>
<div> )))</div>
<div><br>
</div>
<div>I get the following error when I run the previous example (and
enter a positive integer):</div>
<div><br>
=> reference to undefined identifier: return</div>
<div><br>
</div>
<div>The puzzling thing is that if I run the macro expansion (as shown
by the Macro Stepper), it works !</div>
<div>Here is the macro expansion:</div>
<div><br>
</div>
<div>(define test-return</div>
<div> (lambda ()</div>
<div> (call-with-current-<wbr>continuation</div>
<div> (lambda (return)</div>
<div> (let ((input (read)))</div>
<div> (if (number? input)</div>
<div> (if (> input 0)</div>
<div> (begin (display "positive") (return input))</div>
<div> (display "negative or zero"))</div>
<div> (display "not a number"))</div>
<div> (display "no return"))))))</div>
</div>
<div><br>
<br>
</div>
<div>What I am missing ?</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<font color="#888888">
<div>M</div>
</font></span></span>
</body>
</html>