Re: [racket-users] Getting the "require" syntax arrows to work right

2015-10-24 Thread Alexis King
Aha, yes, that seems to work. I should have thought of that, but I actually 
didn’t know you can just copy all properties over with datum->syntax, haha. I 
guess I should have read the docs for that more carefully.

This does seem a little bit like cheating because now the macro-generated 
racket/base identifier is considered to be `syntax-original?`, which I guess 
may have been the problem in the first place. Does this mean that 
`syntax-original?` is less meaningful than I initially thought—just because 
it’s a “private” property doesn’t mean macros can’t generate new syntax objects 
that are considered to be “original”?

Anyway, thanks for your quick response! All seems to be well now.

> On Oct 24, 2015, at 12:29 PM, Robby Findler  
> wrote:
> 
> Maybe you need to copy over the properties too? This seems to work:
> 
> #lang racket/base
> (require (for-syntax racket/base))
> (define-syntax (import stx)
>  (syntax-case stx ()
>[(_ (a b))
> #`(require #,(datum->syntax stx
> (string->symbol (format "~a/~a"
> (syntax-e #'a) (syntax-e #'b)))
> #'b
> stx))]))
> 
> (import (racket contract))
> list/c
> 
> Robby

-- 
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] Getting the "require" syntax arrows to work right

2015-10-24 Thread Robby Findler
I'm not sure syntax-original? is really that meaningful anymore.
Another way to forge it is to use read-syntax with a string port that
has whatever you want (during a macro expansion call). And check
syntax even accepts an alternative property for those times when these
two approaches aren't convenient enough.

Robby


On Sat, Oct 24, 2015 at 2:39 PM, Alexis King  wrote:
> Aha, yes, that seems to work. I should have thought of that, but I actually 
> didn’t know you can just copy all properties over with datum->syntax, haha. I 
> guess I should have read the docs for that more carefully.
>
> This does seem a little bit like cheating because now the macro-generated 
> racket/base identifier is considered to be `syntax-original?`, which I guess 
> may have been the problem in the first place. Does this mean that 
> `syntax-original?` is less meaningful than I initially thought—just because 
> it’s a “private” property doesn’t mean macros can’t generate new syntax 
> objects that are considered to be “original”?
>
> Anyway, thanks for your quick response! All seems to be well now.
>
>> On Oct 24, 2015, at 12:29 PM, Robby Findler  
>> wrote:
>>
>> Maybe you need to copy over the properties too? This seems to work:
>>
>> #lang racket/base
>> (require (for-syntax racket/base))
>> (define-syntax (import stx)
>>  (syntax-case stx ()
>>[(_ (a b))
>> #`(require #,(datum->syntax stx
>> (string->symbol (format "~a/~a"
>> (syntax-e #'a) (syntax-e #'b)))
>> #'b
>> stx))]))
>>
>> (import (racket contract))
>> list/c
>>
>> Robby
>

-- 
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] Getting the "require" syntax arrows to work right

2015-10-24 Thread Robby Findler
Maybe you need to copy over the properties too? This seems to work:

#lang racket/base
(require (for-syntax racket/base))
(define-syntax (import stx)
  (syntax-case stx ()
[(_ (a b))
 #`(require #,(datum->syntax stx
 (string->symbol (format "~a/~a"
(syntax-e #'a) (syntax-e #'b)))
 #'b
 stx))]))

(import (racket contract))
list/c

Robby

On Sat, Oct 24, 2015 at 2:20 PM, Alexis King  wrote:
> I’ve been toying with the idea of making an R7RS implementation in Racket, 
> and one of the things I’ve implemented is the R7RS `import` form. It’s very 
> easy to implement in Racket, and it works fine as far as I can tell, but I 
> can’t figure out how to get the special binding arrows to cooperate with it 
> in DrRacket.
>
> Right now, an import form looks like this:
>
>(import (racket base))
>
> ...and the expansion is this:
>
>(require racket/base)
>
> I’ve been careful to ensure that the `racket/base` identifier in the 
> expansion has the same lexical context and source location as the (racket 
> base) syntax object in the original form. I can confirm that this works: 
> after importing (racket base), I can use all of the identifiers racket/base 
> provides in my module. However, when I hover over them, the binding arrows 
> don’t show up.
>
> What information do I need to include in my custom form so that the arrows 
> appear for bindings imported with `import`? How does DrRacket determine where 
> bindings are imported at if they’re required from another module?
>
> Thanks,
> Alexis
>
> --
> 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] Getting the "require" syntax arrows to work right

2015-10-24 Thread Alexis King
I’ve been toying with the idea of making an R7RS implementation in Racket, and 
one of the things I’ve implemented is the R7RS `import` form. It’s very easy to 
implement in Racket, and it works fine as far as I can tell, but I can’t figure 
out how to get the special binding arrows to cooperate with it in DrRacket.

Right now, an import form looks like this:

   (import (racket base))

...and the expansion is this:

   (require racket/base)

I’ve been careful to ensure that the `racket/base` identifier in the expansion 
has the same lexical context and source location as the (racket base) syntax 
object in the original form. I can confirm that this works: after importing 
(racket base), I can use all of the identifiers racket/base provides in my 
module. However, when I hover over them, the binding arrows don’t show up.

What information do I need to include in my custom form so that the arrows 
appear for bindings imported with `import`? How does DrRacket determine where 
bindings are imported at if they’re required from another module?

Thanks,
Alexis

-- 
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.