I ran into this issue recently. The right answer for me was to write a
trampolining macro. define-values is treated specially by the macro
expander and thus can't be handled easily in a local expand. The pattern I
ended up using (adapted from an old mailing list post by Ryan and a
discussion with M
Based on the documentation, I thought that the right answer would be
`(list (gensym))` but that didn't work -- hopefully someone else
knows.
Sam
On Tue, Jun 23, 2015 at 4:43 PM, Thomas Dickerson
wrote:
> I thought that might be the case, but the documentation is pretty dense (and
> self-referent
I thought that might be the case, but the documentation is pretty dense
(and self-referential), so it's not clear what the correct value for that
argument is.
Thomas Dickerson
Brown University
Department of Computer Science
115 Waterman St, 4th Floor
Providence, RI 02912
802-458-0637
On Tue, Ju
To fix your last issue, you probably want to provide a different value as
the `context-v` argument (the 2nd one) to `local-expand`.
Sam
On Tue, Jun 23, 2015 at 3:46 PM Thomas Dickerson
wrote:
> Okay - for posterity's sake, here's an updated version of Alex's code that
> supports nested Loop/Acc
Okay - for posterity's sake, here's an updated version of Alex's code that
supports nested Loop/Accum, and doesn't leave any "syntactic residue" after
expansion. This is now what I set out to accomplish with my original set of
questions:
> #lang racket/base
>
> (require racket/stxparam
>
On Tuesday, June 23, 2015 at 8:30:32 AM UTC-4, Matthew Flatt wrote:
> Providing #f as the third argument to `local-expand` means that
>
> (+ i j)
>
> is expanded only as far as exposing the primitive function-call form, also
> known as `#%plain-app`:
>
> (#%plain-app + i j)
>
> When `i` is e
Providing #f as the third argument to `local-expand` means that
(+ i j)
is expanded only as far as exposing the primitive function-call form, also
known as `#%plain-app`:
(#%plain-app + i j)
When `i` is encountered later, there's no binding in the compile-time
environment, because the intern
I seem to be missing some key ingredient here. The following really simply
test-case, using let-syntaxes, works as expected:
> (define-syntax my-def-stx
> (lambda (stx)
> (syntax-case stx (my-def-stx)
> [(my-def-stx (id ...) rhs expr)
>#'(let-syntaxes ([(id ...) rhs]) expr)])))
Probably you don't want to work with namespaces, which are intended more for
run-time reflection.
For an example of turning internal definitions into 'letrec-syntaxes+values',
try the implementation of 'racket/block'.
> On Jun 23, 2015, at 10:06 AM, Thomas Dickerson
> wrote:
>
> Update / add
Update / addendum: I was also able to fairly trivially extend Alex's code using
let-syntax to have the more hygienic behavior for where Accum is/is-not
visible, but let-syntax ends up leaving an additional layer of empty
(let-values() ...) behind.
The documentation for let-syntax makes the foll
Thanks for the effort that went into figuring that out! A couple first thoughts
on the implementation:
To first order, this is exactly what I want to be able to do (and it elegantly
avoids local-expand by reasoning about expansion order); however, as a general
pattern, it's a bit unhygienic in t
On Jun 19, 2015, at 7:44 PM, Thomas Dickerson
wrote:
> I was intending for that example to have the variables be defined outside the
> macro, but being able to create the (set! ...) forms outside should mean I
> could also hypothetically create let/define-values forms. This is why I
> origin
I was intending for that example to have the variables be defined outside the
macro, but being able to create the (set! ...) forms outside should mean I
could also hypothetically create let/define-values forms. This is why I
originally specified being able to effect generation of both prologue +
Are the x, y, and z variables meant to be defined outside the macro by the user
as in:
(let ([x “something”] [y “something else”] [z “and something else”])
(Loop ….))
?
Or should the Loop macro create a (let ([x 0] [y 0] [z 0]) ….) for you instead?
On Jun 19, 2015, at 5:58 PM, Thomas Dickerson
Sure, here's a toy example.
This code:
> (Loop 10
> (begin
> (define-values
> [dx dy dz]
> (values 0 0 0))
> ; Some calculation here
> (Accum x dx)
> (Accum y dy)
> (Accum z dz)))
>
Should desugar into this code:
> (letrec
>
On 06/19/2015 03:07 PM, Thomas Dickerson wrote:
Hi All,
I'm trying to figure out how best to implement the following pattern of macro
behavior:
Let's say we are writing Loop macro that implements a looped computation over a
specified body. I would like to then be able to
(a) introduce additio
16 matches
Mail list logo