Re: [racket-users] Re: find-expr: find a corresponding expression in the definition window

2020-08-31 Thread Robby Findler
That's a nice idea! The code that calls current-print can check to see if
the function accepts a specific keyword parameter and, if it does, supply
it with a srcloc.

Robby


On Mon, Aug 31, 2020 at 2:38 PM Greg Hendershott 
wrote:

> I might be misunderstanding and the following isn't some fully-thought-out
> proposal, but:
>
> IIUC both #%module-begin and read-eval-print-loop use current-print.
>
> What if current-print accepted a new, optional srcloc parameter?
>
> And the default #%module-begin were changed to supply this?
>
> That way, a print handler for a plain-text tool^1 could use the srcloc to
> create some sort of "link", as well as Racket GUI tools like DrRacket using
> it to create some fancier UI.
>
> ^1: This includes TUI tools like emacs, as well as GUI tools like vscode
> using a text serialization format like JSON.
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/6e1d2180-288d-4789-88fc-2980aaf03650o%40googlegroups.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdOPY-GwNOE87Wa5C6hEx8Q9bPARWUdD29RVSmg8oXJMucQ%40mail.gmail.com.


[racket-users] Re: find-expr: find a corresponding expression in the definition window

2020-08-31 Thread Greg Hendershott
I might be misunderstanding and the following isn't some fully-thought-out 
proposal, but:

IIUC both #%module-begin and read-eval-print-loop use current-print.

What if current-print accepted a new, optional srcloc parameter?

And the default #%module-begin were changed to supply this?

That way, a print handler for a plain-text tool^1 could use the srcloc to 
create some sort of "link", as well as Racket GUI tools like DrRacket using 
it to create some fancier UI.

^1: This includes TUI tools like emacs, as well as GUI tools like vscode 
using a text serialization format like JSON.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6e1d2180-288d-4789-88fc-2980aaf03650o%40googlegroups.com.


Re: [racket-users] abstraction suggestion?

2020-08-31 Thread Philip McGrath
In addition (or instead, if this is good enough and less painful), you
could use a compile-time helper function like:

(define-for-syntax (make-mb+ti namespaces-stx
   lang-print-names-stx)
  (define-syntax-class to-run
#:attributes (parsed)
#:literals (TEST)
(pattern (TEST e r ...)
 #:with parsed
 #`(test-output 'e (list 'r ...) #,namespaces-stx))
(pattern e
 #:with parsed
 #`(show-output 'e #,namespaces-stx #,lang-print-names-stx)))
  (values (syntax-parser
#:track-literals
[(_ :to-run ...)
 #'(#%printing-module-begin parsed ...)])
  (syntax-parser
#:track-literals
[(_ . :to-run)
 #'(#%top-interaction . parsed)])))

-Philip


On Mon, Aug 31, 2020 at 1:39 PM Shriram Krishnamurthi 
wrote:

> Oooh, that's pretty clever! A bit painful, but clever!
>
> On Mon, Aug 31, 2020 at 1:32 PM Philip McGrath 
> wrote:
>
>> There might be a better way, but I'd probably make a language for writing
>> this kind of module, in the spirit of `#lang syntax/module-reader`, where
>> its `#%module-begin` would expect the module body to be `> THAT CHANGES>`, similar to the way that the body of `(module reader
>> syntax/module-reader my-language-implementation-module)` is a module name.
>>
>> -Philip
>>
>>
>> On Mon, Aug 31, 2020 at 1:24 PM Hendrik Boom 
>> wrote:
>>
>>> On Mon, Aug 31, 2020 at 10:06:42AM -0700, Shriram Krishnamurthi wrote:
>>> > I'm having some trouble abstracting over this code. Any suggestions?
>>> >
>>> > I have numerous files that follow this boilerplate:
>>> >
>>> > #lang racket
>>> >
>>> > (require )
>>> >
>>> > (provide (rename-out [mod-begin #%module-begin]
>>> >  [ti#%top-interaction]))
>>> >
>>> > (define-values (namespaces lang-print-names)
>>> >   )
>>> >
>>> > (define-syntax (multi-runner stx)
>>> >   (syntax-case stx (TEST)
>>> > [(_ (TEST e r ...))
>>> >  #`(test-output 'e (list 'r ...) namespaces)]
>>> > [(_ e)
>>> >  #`(show-output 'e namespaces lang-print-names)]))
>>> >
>>> > (define-syntax mod-begin
>>> >   (λ (stx)
>>> > (syntax-case stx ()
>>> >   [(_ b ...)
>>> >#'(#%printing-module-begin (multi-runner b) ...)])))
>>> >
>>> > (define-syntax ti
>>> >   (λ (stx)
>>> > (syntax-case stx ()
>>> >   ([_ . e]
>>> >#'(#%top-interaction . (multi-runner e))
>>> >
>>> > I've abstract most of the details into `test-output` and `show-output`
>>> into
>>> > . I would ideally like to move as much of what's left as
>>> > possible into the same file.
>>> >
>>> > The key problem is that the MB and TI depend on `multi-runner`, which
>>> in
>>> > turn depends on `namespaces`, which is a name at run time. As long as
>>> > everything is in the same module, no problem. But when I start to move
>>> the
>>> > boilerplate out…
>>> >
>>> > Concrete suggestions welcome — I've tried several different things
>>> (various
>>> > forms of abstraction, syntax parameters, etc.) without luck.
>>>
>>> Maybe a macro or two?  Perhaps a nonhygienic one?
>>>
>>> -- hendrik
>>>
>>> >
>>> > Thanks,
>>> > Shriram
>>> >
>>> > --
>>> > 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.
>>> > To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/362f807e-3561-4be6-8b4d-937776fea36bn%40googlegroups.com
>>> .
>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/20200831172435.6f6oweyhxjux4g5j%40topoi.pooq.com
>>> .
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Racket Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/racket-users/AH_MtfTEmyw/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/010001744593f3c3-1bc786d7-6d32-4e00-ab62-7d3ad7a42359-00%40email.amazonses.com
>> 
>> .
>>
>

-- 
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.
To view this discussion on the web visit 

Re: [racket-users] abstraction suggestion?

2020-08-31 Thread Philip McGrath
There might be a better way, but I'd probably make a language for writing
this kind of module, in the spirit of `#lang syntax/module-reader`, where
its `#%module-begin` would expect the module body to be ``, similar to the way that the body of `(module reader
syntax/module-reader my-language-implementation-module)` is a module name.

-Philip


On Mon, Aug 31, 2020 at 1:24 PM Hendrik Boom  wrote:

> On Mon, Aug 31, 2020 at 10:06:42AM -0700, Shriram Krishnamurthi wrote:
> > I'm having some trouble abstracting over this code. Any suggestions?
> >
> > I have numerous files that follow this boilerplate:
> >
> > #lang racket
> >
> > (require )
> >
> > (provide (rename-out [mod-begin #%module-begin]
> >  [ti#%top-interaction]))
> >
> > (define-values (namespaces lang-print-names)
> >   )
> >
> > (define-syntax (multi-runner stx)
> >   (syntax-case stx (TEST)
> > [(_ (TEST e r ...))
> >  #`(test-output 'e (list 'r ...) namespaces)]
> > [(_ e)
> >  #`(show-output 'e namespaces lang-print-names)]))
> >
> > (define-syntax mod-begin
> >   (λ (stx)
> > (syntax-case stx ()
> >   [(_ b ...)
> >#'(#%printing-module-begin (multi-runner b) ...)])))
> >
> > (define-syntax ti
> >   (λ (stx)
> > (syntax-case stx ()
> >   ([_ . e]
> >#'(#%top-interaction . (multi-runner e))
> >
> > I've abstract most of the details into `test-output` and `show-output`
> into
> > . I would ideally like to move as much of what's left as
> > possible into the same file.
> >
> > The key problem is that the MB and TI depend on `multi-runner`, which in
> > turn depends on `namespaces`, which is a name at run time. As long as
> > everything is in the same module, no problem. But when I start to move
> the
> > boilerplate out…
> >
> > Concrete suggestions welcome — I've tried several different things
> (various
> > forms of abstraction, syntax parameters, etc.) without luck.
>
> Maybe a macro or two?  Perhaps a nonhygienic one?
>
> -- hendrik
>
> >
> > Thanks,
> > Shriram
> >
> > --
> > 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.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/362f807e-3561-4be6-8b4d-937776fea36bn%40googlegroups.com
> .
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200831172435.6f6oweyhxjux4g5j%40topoi.pooq.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/010001744593f3c3-1bc786d7-6d32-4e00-ab62-7d3ad7a42359-00%40email.amazonses.com.


Re: [racket-users] abstraction suggestion?

2020-08-31 Thread Hendrik Boom
On Mon, Aug 31, 2020 at 10:06:42AM -0700, Shriram Krishnamurthi wrote:
> I'm having some trouble abstracting over this code. Any suggestions?
> 
> I have numerous files that follow this boilerplate:
> 
> #lang racket
> 
> (require )
> 
> (provide (rename-out [mod-begin #%module-begin]
>  [ti#%top-interaction]))
> 
> (define-values (namespaces lang-print-names)
>   )
> 
> (define-syntax (multi-runner stx)
>   (syntax-case stx (TEST)
> [(_ (TEST e r ...))
>  #`(test-output 'e (list 'r ...) namespaces)]
> [(_ e)
>  #`(show-output 'e namespaces lang-print-names)]))
> 
> (define-syntax mod-begin
>   (λ (stx)
> (syntax-case stx ()
>   [(_ b ...)
>#'(#%printing-module-begin (multi-runner b) ...)])))
> 
> (define-syntax ti
>   (λ (stx)
> (syntax-case stx ()
>   ([_ . e]
>#'(#%top-interaction . (multi-runner e))
> 
> I've abstract most of the details into `test-output` and `show-output` into 
> . I would ideally like to move as much of what's left as 
> possible into the same file. 
> 
> The key problem is that the MB and TI depend on `multi-runner`, which in 
> turn depends on `namespaces`, which is a name at run time. As long as 
> everything is in the same module, no problem. But when I start to move the 
> boilerplate out…
> 
> Concrete suggestions welcome — I've tried several different things (various 
> forms of abstraction, syntax parameters, etc.) without luck.

Maybe a macro or two?  Perhaps a nonhygienic one?

-- hendrik

> 
> Thanks,
> Shriram
> 
> -- 
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/362f807e-3561-4be6-8b4d-937776fea36bn%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200831172435.6f6oweyhxjux4g5j%40topoi.pooq.com.


[racket-users] abstraction suggestion?

2020-08-31 Thread Shriram Krishnamurthi
I'm having some trouble abstracting over this code. Any suggestions?

I have numerous files that follow this boilerplate:

#lang racket

(require )

(provide (rename-out [mod-begin #%module-begin]
 [ti#%top-interaction]))

(define-values (namespaces lang-print-names)
  )

(define-syntax (multi-runner stx)
  (syntax-case stx (TEST)
[(_ (TEST e r ...))
 #`(test-output 'e (list 'r ...) namespaces)]
[(_ e)
 #`(show-output 'e namespaces lang-print-names)]))

(define-syntax mod-begin
  (λ (stx)
(syntax-case stx ()
  [(_ b ...)
   #'(#%printing-module-begin (multi-runner b) ...)])))

(define-syntax ti
  (λ (stx)
(syntax-case stx ()
  ([_ . e]
   #'(#%top-interaction . (multi-runner e))

I've abstract most of the details into `test-output` and `show-output` into 
. I would ideally like to move as much of what's left as 
possible into the same file. 

The key problem is that the MB and TI depend on `multi-runner`, which in 
turn depends on `namespaces`, which is a name at run time. As long as 
everything is in the same module, no problem. But when I start to move the 
boilerplate out…

Concrete suggestions welcome — I've tried several different things (various 
forms of abstraction, syntax parameters, etc.) without luck.

Thanks,
Shriram

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/362f807e-3561-4be6-8b4d-937776fea36bn%40googlegroups.com.