Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Leif Andersen
Yeah, I would guess that too. Anyway, it doesn't seem to do all
phases. So I just shift the phase down every time I see a
begin-for-syntax.

Thanks for your help.

~Leif Andersen


On Wed, Dec 16, 2015 at 10:52 PM, Stephen Chang  wrote:
> I'm not sure. I would guess that it corresponds to the label phase?
>
> On Wed, Dec 16, 2015 at 10:37 PM, Leif Andersen  wrote:
>> Ah, okay, thanks. One question, I notice that you can pass in #f to
>> #:phase, I presume that is similar to for-label, can I use that to
>> indicate I would like it to match on all phases?
>>
>> ~Leif Andersen
>>
>>
>> On Wed, Dec 16, 2015 at 10:02 PM, Stephen Chang  wrote:
>>> There's a #:phase option available when specifying literals:
>>>
>>> http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29
>>>
>>> On Wed, Dec 16, 2015 at 9:55 PM, Leif Andersen  
>>> wrote:
 Okay, that makes sense, thanks.

 So out of curiosity, when doing a `syntax-parse`, is there any way I
 can pass in phase level 1 quote as a literal?

 ~Leif Andersen


 On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
  wrote:
> That depends on what you're trying to do, but probably not. Going under a
> `quote-syntax` doesn't change things, it's just that those identifiers are
> usually used in a macro somewhere else. But it would depend on your
> application.
>
> Note the handling of submodules, though, in particular the call to
> `syntax-shift-phase-level`.
>
> Sam
>
> On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  
> wrote:
>>
>> Ah, cool. Thanks.
>>
>> Does that also mean that if I see a `syntax` form inside of a
>> `begin-for-syntax` it goes back to phase 0?
>>
>> Thanks.
>>
>> ~Leif Andersen
>>
>>
>> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>>  wrote:
>> > The identifiers are the same, but only when comparing their phase-1
>> > bindings. When doing traversal of syntax objects, you need to keep 
>> > track
>> > of
>> > the phase that identifiers are meaningful at.
>> >
>> > Here's a version of your paste comparing at the right phase:
>> > http://pasterack.org/pastes/95574
>> >
>> > Here's some quite complex code that walks fully-expanded syntax, and (I
>> > think) handles phases right as of yesterday:
>> >
>> > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
>> >  .
>> > See the `current-phase` parameter.
>> >
>> > Sam
>> >
>> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> I am finding that when I have a syntax object:
>> >>
>> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it 
>> >> becomes:
>> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
>> >> expansion will not be free-identifier=? to the one if I were to type
>> >> it out by hand:
>> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
>> >>
>> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
>> >> me:
>> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
>> >> expands into is free-identifier=? to the one that I am using.)
>> >>
>> >> I am calling expand (or expand-syntax) directly, and not really using
>> >> any phase levels outside of whatever `expand` may use.
>> >>
>> >> Here is my code: http://pasterack.org/pastes/78711
>> >>
>> >> #lang racket
>> >>
>> >> (define x (expand #'(begin-for-syntax
>> >>   (define-values (x) '5
>> >> (define y (expand #'(begin-for-syntax
>> >>   (define-values (x) 5
>> >>
>> >> (define (ident=? stx)
>> >>   (syntax-case stx ()
>> >> [(_ (_ (_) (var _)))
>> >>  (free-identifier=? #'var #'quote)]))
>> >>
>> >> (syntax->datum x)
>> >> (syntax->datum y)
>> >> (ident=? x)
>> >> (ident=? y)
>> >>
>> >> Is this expected behavior? If so, can you give me some intuition as to
>> >> why?
>> >>
>> >> Thank you.
>> >>
>> >> ~Leif Andersen
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Racket Users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to racket-users+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, 

Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Stephen Chang
I'm not sure. I would guess that it corresponds to the label phase?

On Wed, Dec 16, 2015 at 10:37 PM, Leif Andersen  wrote:
> Ah, okay, thanks. One question, I notice that you can pass in #f to
> #:phase, I presume that is similar to for-label, can I use that to
> indicate I would like it to match on all phases?
>
> ~Leif Andersen
>
>
> On Wed, Dec 16, 2015 at 10:02 PM, Stephen Chang  wrote:
>> There's a #:phase option available when specifying literals:
>>
>> http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29
>>
>> On Wed, Dec 16, 2015 at 9:55 PM, Leif Andersen  wrote:
>>> Okay, that makes sense, thanks.
>>>
>>> So out of curiosity, when doing a `syntax-parse`, is there any way I
>>> can pass in phase level 1 quote as a literal?
>>>
>>> ~Leif Andersen
>>>
>>>
>>> On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
>>>  wrote:
 That depends on what you're trying to do, but probably not. Going under a
 `quote-syntax` doesn't change things, it's just that those identifiers are
 usually used in a macro somewhere else. But it would depend on your
 application.

 Note the handling of submodules, though, in particular the call to
 `syntax-shift-phase-level`.

 Sam

 On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  
 wrote:
>
> Ah, cool. Thanks.
>
> Does that also mean that if I see a `syntax` form inside of a
> `begin-for-syntax` it goes back to phase 0?
>
> Thanks.
>
> ~Leif Andersen
>
>
> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>  wrote:
> > The identifiers are the same, but only when comparing their phase-1
> > bindings. When doing traversal of syntax objects, you need to keep track
> > of
> > the phase that identifiers are meaningful at.
> >
> > Here's a version of your paste comparing at the right phase:
> > http://pasterack.org/pastes/95574
> >
> > Here's some quite complex code that walks fully-expanded syntax, and (I
> > think) handles phases right as of yesterday:
> >
> > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
> >  .
> > See the `current-phase` parameter.
> >
> > Sam
> >
> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
> > wrote:
> >>
> >> Hello,
> >>
> >> I am finding that when I have a syntax object:
> >>
> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
> >> expansion will not be free-identifier=? to the one if I were to type
> >> it out by hand:
> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
> >>
> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
> >> me:
> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
> >> expands into is free-identifier=? to the one that I am using.)
> >>
> >> I am calling expand (or expand-syntax) directly, and not really using
> >> any phase levels outside of whatever `expand` may use.
> >>
> >> Here is my code: http://pasterack.org/pastes/78711
> >>
> >> #lang racket
> >>
> >> (define x (expand #'(begin-for-syntax
> >>   (define-values (x) '5
> >> (define y (expand #'(begin-for-syntax
> >>   (define-values (x) 5
> >>
> >> (define (ident=? stx)
> >>   (syntax-case stx ()
> >> [(_ (_ (_) (var _)))
> >>  (free-identifier=? #'var #'quote)]))
> >>
> >> (syntax->datum x)
> >> (syntax->datum y)
> >> (ident=? x)
> >> (ident=? y)
> >>
> >> Is this expected behavior? If so, can you give me some intuition as to
> >> why?
> >>
> >> Thank you.
> >>
> >> ~Leif Andersen
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups
> >> "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> >> an
> >> email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message bec

Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Leif Andersen
Ah, okay, thanks. One question, I notice that you can pass in #f to
#:phase, I presume that is similar to for-label, can I use that to
indicate I would like it to match on all phases?

~Leif Andersen


On Wed, Dec 16, 2015 at 10:02 PM, Stephen Chang  wrote:
> There's a #:phase option available when specifying literals:
>
> http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29
>
> On Wed, Dec 16, 2015 at 9:55 PM, Leif Andersen  wrote:
>> Okay, that makes sense, thanks.
>>
>> So out of curiosity, when doing a `syntax-parse`, is there any way I
>> can pass in phase level 1 quote as a literal?
>>
>> ~Leif Andersen
>>
>>
>> On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
>>  wrote:
>>> That depends on what you're trying to do, but probably not. Going under a
>>> `quote-syntax` doesn't change things, it's just that those identifiers are
>>> usually used in a macro somewhere else. But it would depend on your
>>> application.
>>>
>>> Note the handling of submodules, though, in particular the call to
>>> `syntax-shift-phase-level`.
>>>
>>> Sam
>>>
>>> On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  wrote:

 Ah, cool. Thanks.

 Does that also mean that if I see a `syntax` form inside of a
 `begin-for-syntax` it goes back to phase 0?

 Thanks.

 ~Leif Andersen


 On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
  wrote:
 > The identifiers are the same, but only when comparing their phase-1
 > bindings. When doing traversal of syntax objects, you need to keep track
 > of
 > the phase that identifiers are meaningful at.
 >
 > Here's a version of your paste comparing at the right phase:
 > http://pasterack.org/pastes/95574
 >
 > Here's some quite complex code that walks fully-expanded syntax, and (I
 > think) handles phases right as of yesterday:
 >
 > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
 >  .
 > See the `current-phase` parameter.
 >
 > Sam
 >
 > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
 > wrote:
 >>
 >> Hello,
 >>
 >> I am finding that when I have a syntax object:
 >>
 >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
 >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
 >> expansion will not be free-identifier=? to the one if I were to type
 >> it out by hand:
 >> #'(begin-for-syntax (define-values (x) '5), and expand that.
 >>
 >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
 >> me:
 >> #'(begin (define-values (x) 5) it works as expected. (The quote it
 >> expands into is free-identifier=? to the one that I am using.)
 >>
 >> I am calling expand (or expand-syntax) directly, and not really using
 >> any phase levels outside of whatever `expand` may use.
 >>
 >> Here is my code: http://pasterack.org/pastes/78711
 >>
 >> #lang racket
 >>
 >> (define x (expand #'(begin-for-syntax
 >>   (define-values (x) '5
 >> (define y (expand #'(begin-for-syntax
 >>   (define-values (x) 5
 >>
 >> (define (ident=? stx)
 >>   (syntax-case stx ()
 >> [(_ (_ (_) (var _)))
 >>  (free-identifier=? #'var #'quote)]))
 >>
 >> (syntax->datum x)
 >> (syntax->datum y)
 >> (ident=? x)
 >> (ident=? y)
 >>
 >> Is this expected behavior? If so, can you give me some intuition as to
 >> why?
 >>
 >> Thank you.
 >>
 >> ~Leif Andersen
 >>
 >> --
 >> You received this message because you are subscribed to the Google
 >> Groups
 >> "Racket Users" group.
 >> To unsubscribe from this group and stop receiving emails from it, send
 >> an
 >> email to racket-users+unsubscr...@googlegroups.com.
 >> For more options, visit https://groups.google.com/d/optout.

 --
 You received this message because you are subscribed to the Google Groups
 "Racket Users" group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Stephen Chang
There's a #:phase option available when specifying literals:

http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29

On Wed, Dec 16, 2015 at 9:55 PM, Leif Andersen  wrote:
> Okay, that makes sense, thanks.
>
> So out of curiosity, when doing a `syntax-parse`, is there any way I
> can pass in phase level 1 quote as a literal?
>
> ~Leif Andersen
>
>
> On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
>  wrote:
>> That depends on what you're trying to do, but probably not. Going under a
>> `quote-syntax` doesn't change things, it's just that those identifiers are
>> usually used in a macro somewhere else. But it would depend on your
>> application.
>>
>> Note the handling of submodules, though, in particular the call to
>> `syntax-shift-phase-level`.
>>
>> Sam
>>
>> On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  wrote:
>>>
>>> Ah, cool. Thanks.
>>>
>>> Does that also mean that if I see a `syntax` form inside of a
>>> `begin-for-syntax` it goes back to phase 0?
>>>
>>> Thanks.
>>>
>>> ~Leif Andersen
>>>
>>>
>>> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>>>  wrote:
>>> > The identifiers are the same, but only when comparing their phase-1
>>> > bindings. When doing traversal of syntax objects, you need to keep track
>>> > of
>>> > the phase that identifiers are meaningful at.
>>> >
>>> > Here's a version of your paste comparing at the right phase:
>>> > http://pasterack.org/pastes/95574
>>> >
>>> > Here's some quite complex code that walks fully-expanded syntax, and (I
>>> > think) handles phases right as of yesterday:
>>> >
>>> > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt 
>>> > .
>>> > See the `current-phase` parameter.
>>> >
>>> > Sam
>>> >
>>> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
>>> > wrote:
>>> >>
>>> >> Hello,
>>> >>
>>> >> I am finding that when I have a syntax object:
>>> >>
>>> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
>>> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
>>> >> expansion will not be free-identifier=? to the one if I were to type
>>> >> it out by hand:
>>> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
>>> >>
>>> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
>>> >> me:
>>> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
>>> >> expands into is free-identifier=? to the one that I am using.)
>>> >>
>>> >> I am calling expand (or expand-syntax) directly, and not really using
>>> >> any phase levels outside of whatever `expand` may use.
>>> >>
>>> >> Here is my code: http://pasterack.org/pastes/78711
>>> >>
>>> >> #lang racket
>>> >>
>>> >> (define x (expand #'(begin-for-syntax
>>> >>   (define-values (x) '5
>>> >> (define y (expand #'(begin-for-syntax
>>> >>   (define-values (x) 5
>>> >>
>>> >> (define (ident=? stx)
>>> >>   (syntax-case stx ()
>>> >> [(_ (_ (_) (var _)))
>>> >>  (free-identifier=? #'var #'quote)]))
>>> >>
>>> >> (syntax->datum x)
>>> >> (syntax->datum y)
>>> >> (ident=? x)
>>> >> (ident=? y)
>>> >>
>>> >> Is this expected behavior? If so, can you give me some intuition as to
>>> >> why?
>>> >>
>>> >> Thank you.
>>> >>
>>> >> ~Leif Andersen
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> >> Groups
>>> >> "Racket Users" group.
>>> >> To unsubscribe from this group and stop receiving emails from it, send
>>> >> an
>>> >> email to racket-users+unsubscr...@googlegroups.com.
>>> >> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Leif Andersen
Okay, that makes sense, thanks.

So out of curiosity, when doing a `syntax-parse`, is there any way I
can pass in phase level 1 quote as a literal?

~Leif Andersen


On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
 wrote:
> That depends on what you're trying to do, but probably not. Going under a
> `quote-syntax` doesn't change things, it's just that those identifiers are
> usually used in a macro somewhere else. But it would depend on your
> application.
>
> Note the handling of submodules, though, in particular the call to
> `syntax-shift-phase-level`.
>
> Sam
>
> On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  wrote:
>>
>> Ah, cool. Thanks.
>>
>> Does that also mean that if I see a `syntax` form inside of a
>> `begin-for-syntax` it goes back to phase 0?
>>
>> Thanks.
>>
>> ~Leif Andersen
>>
>>
>> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>>  wrote:
>> > The identifiers are the same, but only when comparing their phase-1
>> > bindings. When doing traversal of syntax objects, you need to keep track
>> > of
>> > the phase that identifiers are meaningful at.
>> >
>> > Here's a version of your paste comparing at the right phase:
>> > http://pasterack.org/pastes/95574
>> >
>> > Here's some quite complex code that walks fully-expanded syntax, and (I
>> > think) handles phases right as of yesterday:
>> >
>> > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt .
>> > See the `current-phase` parameter.
>> >
>> > Sam
>> >
>> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> I am finding that when I have a syntax object:
>> >>
>> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
>> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
>> >> expansion will not be free-identifier=? to the one if I were to type
>> >> it out by hand:
>> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
>> >>
>> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
>> >> me:
>> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
>> >> expands into is free-identifier=? to the one that I am using.)
>> >>
>> >> I am calling expand (or expand-syntax) directly, and not really using
>> >> any phase levels outside of whatever `expand` may use.
>> >>
>> >> Here is my code: http://pasterack.org/pastes/78711
>> >>
>> >> #lang racket
>> >>
>> >> (define x (expand #'(begin-for-syntax
>> >>   (define-values (x) '5
>> >> (define y (expand #'(begin-for-syntax
>> >>   (define-values (x) 5
>> >>
>> >> (define (ident=? stx)
>> >>   (syntax-case stx ()
>> >> [(_ (_ (_) (var _)))
>> >>  (free-identifier=? #'var #'quote)]))
>> >>
>> >> (syntax->datum x)
>> >> (syntax->datum y)
>> >> (ident=? x)
>> >> (ident=? y)
>> >>
>> >> Is this expected behavior? If so, can you give me some intuition as to
>> >> why?
>> >>
>> >> Thank you.
>> >>
>> >> ~Leif Andersen
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Racket Users" group.
>> >> To unsubscribe from this group and stop receiving emails from it, send
>> >> an
>> >> email to racket-users+unsubscr...@googlegroups.com.
>> >> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Sam Tobin-Hochstadt
That depends on what you're trying to do, but probably not. Going under a
`quote-syntax` doesn't change things, it's just that those identifiers are
usually used in a macro somewhere else. But it would depend on your
application.

Note the handling of submodules, though, in particular the call to
`syntax-shift-phase-level`.

Sam

On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen  wrote:

> Ah, cool. Thanks.
>
> Does that also mean that if I see a `syntax` form inside of a
> `begin-for-syntax` it goes back to phase 0?
>
> Thanks.
>
> ~Leif Andersen
>
>
> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>  wrote:
> > The identifiers are the same, but only when comparing their phase-1
> > bindings. When doing traversal of syntax objects, you need to keep track
> of
> > the phase that identifiers are meaningful at.
> >
> > Here's a version of your paste comparing at the right phase:
> > http://pasterack.org/pastes/95574
> >
> > Here's some quite complex code that walks fully-expanded syntax, and (I
> > think) handles phases right as of yesterday:
> >
> https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
> .
> > See the `current-phase` parameter.
> >
> > Sam
> >
> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen 
> wrote:
> >>
> >> Hello,
> >>
> >> I am finding that when I have a syntax object:
> >>
> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
> >> expansion will not be free-identifier=? to the one if I were to type
> >> it out by hand:
> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
> >>
> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
> me:
> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
> >> expands into is free-identifier=? to the one that I am using.)
> >>
> >> I am calling expand (or expand-syntax) directly, and not really using
> >> any phase levels outside of whatever `expand` may use.
> >>
> >> Here is my code: http://pasterack.org/pastes/78711
> >>
> >> #lang racket
> >>
> >> (define x (expand #'(begin-for-syntax
> >>   (define-values (x) '5
> >> (define y (expand #'(begin-for-syntax
> >>   (define-values (x) 5
> >>
> >> (define (ident=? stx)
> >>   (syntax-case stx ()
> >> [(_ (_ (_) (var _)))
> >>  (free-identifier=? #'var #'quote)]))
> >>
> >> (syntax->datum x)
> >> (syntax->datum y)
> >> (ident=? x)
> >> (ident=? y)
> >>
> >> Is this expected behavior? If so, can you give me some intuition as to
> >> why?
> >>
> >> Thank you.
> >>
> >> ~Leif Andersen
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Leif Andersen
Ah, cool. Thanks.

Does that also mean that if I see a `syntax` form inside of a
`begin-for-syntax` it goes back to phase 0?

Thanks.

~Leif Andersen


On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
 wrote:
> The identifiers are the same, but only when comparing their phase-1
> bindings. When doing traversal of syntax objects, you need to keep track of
> the phase that identifiers are meaningful at.
>
> Here's a version of your paste comparing at the right phase:
> http://pasterack.org/pastes/95574
>
> Here's some quite complex code that walks fully-expanded syntax, and (I
> think) handles phases right as of yesterday:
> https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt .
> See the `current-phase` parameter.
>
> Sam
>
> On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen  wrote:
>>
>> Hello,
>>
>> I am finding that when I have a syntax object:
>>
>> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
>> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
>> expansion will not be free-identifier=? to the one if I were to type
>> it out by hand:
>> #'(begin-for-syntax (define-values (x) '5), and expand that.
>>
>> If however, I have a `begin` rather than a `begin-for-syntax`, giving me:
>> #'(begin (define-values (x) 5) it works as expected. (The quote it
>> expands into is free-identifier=? to the one that I am using.)
>>
>> I am calling expand (or expand-syntax) directly, and not really using
>> any phase levels outside of whatever `expand` may use.
>>
>> Here is my code: http://pasterack.org/pastes/78711
>>
>> #lang racket
>>
>> (define x (expand #'(begin-for-syntax
>>   (define-values (x) '5
>> (define y (expand #'(begin-for-syntax
>>   (define-values (x) 5
>>
>> (define (ident=? stx)
>>   (syntax-case stx ()
>> [(_ (_ (_) (var _)))
>>  (free-identifier=? #'var #'quote)]))
>>
>> (syntax->datum x)
>> (syntax->datum y)
>> (ident=? x)
>> (ident=? y)
>>
>> Is this expected behavior? If so, can you give me some intuition as to
>> why?
>>
>> Thank you.
>>
>> ~Leif Andersen
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Sam Tobin-Hochstadt
The identifiers are the same, but only when comparing their phase-1
bindings. When doing traversal of syntax objects, you need to keep track of
the phase that identifiers are meaningful at.

Here's a version of your paste comparing at the right phase:
http://pasterack.org/pastes/95574

Here's some quite complex code that walks fully-expanded syntax, and (I
think) handles phases right as of yesterday:
https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt .
See the `current-phase` parameter.

Sam

On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen  wrote:

> Hello,
>
> I am finding that when I have a syntax object:
>
> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
> expansion will not be free-identifier=? to the one if I were to type
> it out by hand:
> #'(begin-for-syntax (define-values (x) '5), and expand that.
>
> If however, I have a `begin` rather than a `begin-for-syntax`, giving me:
> #'(begin (define-values (x) 5) it works as expected. (The quote it
> expands into is free-identifier=? to the one that I am using.)
>
> I am calling expand (or expand-syntax) directly, and not really using
> any phase levels outside of whatever `expand` may use.
>
> Here is my code: http://pasterack.org/pastes/78711
>
> #lang racket
>
> (define x (expand #'(begin-for-syntax
>   (define-values (x) '5
> (define y (expand #'(begin-for-syntax
>   (define-values (x) 5
>
> (define (ident=? stx)
>   (syntax-case stx ()
> [(_ (_ (_) (var _)))
>  (free-identifier=? #'var #'quote)]))
>
> (syntax->datum x)
> (syntax->datum y)
> (ident=? x)
> (ident=? y)
>
> Is this expected behavior? If so, can you give me some intuition as to why?
>
> Thank you.
>
> ~Leif Andersen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Leif Andersen
Hello,

I am finding that when I have a syntax object:

#'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
#'(begin-for-syntax (define-values (x) '5). However, the quote in that
expansion will not be free-identifier=? to the one if I were to type
it out by hand:
#'(begin-for-syntax (define-values (x) '5), and expand that.

If however, I have a `begin` rather than a `begin-for-syntax`, giving me:
#'(begin (define-values (x) 5) it works as expected. (The quote it
expands into is free-identifier=? to the one that I am using.)

I am calling expand (or expand-syntax) directly, and not really using
any phase levels outside of whatever `expand` may use.

Here is my code: http://pasterack.org/pastes/78711

#lang racket

(define x (expand #'(begin-for-syntax
  (define-values (x) '5
(define y (expand #'(begin-for-syntax
  (define-values (x) 5

(define (ident=? stx)
  (syntax-case stx ()
[(_ (_ (_) (var _)))
 (free-identifier=? #'var #'quote)]))

(syntax->datum x)
(syntax->datum y)
(ident=? x)
(ident=? y)

Is this expected behavior? If so, can you give me some intuition as to why?

Thank you.

~Leif Andersen

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.