<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Hello, is there a documented problem with (send e get-time-stamp) ? After upgrading from 5.1.2 to 5.2, suddenly all mouse events have a time-stamp of 0.<br><br>Thanks<br><br>Mathieu Paradis<br><br><div><div id="SkyDrivePlaceholder"></div>> Date: Wed, 1 Feb 2012 10:11:55 -0700<br>> From: ryan@cs.utah.edu<br>> To: rac@ruediger-asche.de<br>> CC: users@racket-lang.org<br>> Subject: Re: [racket] macros in local namespaces?...<br>> <br>> On 02/01/2012 09:45 AM, Rüdiger Asche wrote:<br>> > Hi there,<br>> ><br>> > I'm trying to get a grip on macros. Here is a very simple Racket expression (1):<br>> ><br>> > (letrec [(a 2)<br>> > (b 3)<br>> > (afn (lambda (x) (+ x a)))<br>> > (bfn (lambda (x) (+ x b)))]<br>> > (afn (bfn 2)))<br>> ><br>> > Now I need a syntactic abstraction for afn and bfn. The following will do in first approximation (2):<br>> ><br>> > (define-syntax-rule (absfn varname) (lambda (x) (+ x varname)))<br>> ><br>> > (letrec [(a 2)<br>> > (b 3)<br>> > (afn (absfn a))<br>> > (bfn (absfn b))]<br>> > (afn (bfn 2)))<br>> ><br>> ><br>> > However, it will fail due to scoping rules in the following example (3):<br>> ><br>> > (define-syntax-rule (absfn varname) (lambda (x) (+ (+ x localc) varname)))<br>> ><br>> > (letrec [(a 2)<br>> > (b 3)<br>> > (localc 4)<br>> > (afn (absfn a))<br>> > (bfn (absfn b))]<br>> > (afn (bfn 2)))<br>> ><br>> > In other words, my syntactic extension absfn needs to be embedded in the namespace of the sorrounding expression (or as a "dumb" macro which simply does lexical replacement without considering scoping, but needless to say such a macro would be unhygienic).<br>> > I suspect that letrec-syntax was meant for that purpose, but I can't figure out how the parameters to define-syntax-rule would translate to those of letrec-syntax.<br>> ><br>> > Does anyone have sample code for how to get (3) above to work?<br>> ><br>> > Thanks!<br>> <br>> The easiest way is to use internal definitions instead:<br>> <br>> (let ()<br>> (define a 2)<br>> (define b 3)<br>> (define localc 4)<br>> (define-syntax-rule (absfn varname)<br>> (lambda (x) (+ (+ x localc) varname)))<br>> (define afn (absfn a))<br>> (define bfn (absfn b))<br>> (afn (bfn 2)))<br>> <br>> Another way is to use letrec-syntaxes+values, as Matthias answered.<br>> <br>> Ryan<br>> ____________________<br>> Racket Users list:<br>> http://lists.racket-lang.org/users<br></div>                                            </div></body>
</html>