Arrows and syntax parameters

Tim Brown <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
Folks,

I have a simple anaphoric macro, `awhen`, defined as:

-----------------------------------------------------------------------
#lang racket
(require racket/stxparam)

(define-syntax-parameter it
  (λ (stx) (raise-syntax-error #f "use of “it” outside anaphor" stx)))

(define-syntax (awhen stx)
  (syntax-case stx ()
    [(_awhen test body0 body ...)
     #'(let ((t test))
         (syntax-parameterize ([it (syntax-id-rules () [_ t])])
           (when t body0 body ...)))]))

(awhen 32
       (displayln it) ;; [W]
       (awhen 42
              (displayln it))) ;; [X]
-----------------------------------------------------------------------

When I hover over `awhen` in DrRacket, an arrow comes from that
(define-syntax (awhen ...) ...) line, and ends at the instance of
`awhen` I’m over-hovering. The other `awhen` glows green.

When I hover over `it` [W] in DrRacket, an arrow comes from that
(define-syntax-parameter it ...) line, and ends at the instance of `it`
I’m bothering. The other `it` glows green.

I want to tweak the arrows so that when I hover over the first `it` at
[W] I get an arrow pointing wither from 32 (the test) or its `awhen`.

And vice-versa when I hover over an `awhen`.

So I try:
-----------------------------------------------------------------------
(define-syntax (a2when stx)
  (syntax-case stx ()
    [(_a2when test body0 body ...)
     (syntax-property
      #'(let ((t test))
          (syntax-parameterize ([it (syntax-id-rules () [_ t])])
            (when t body0 body ...)))
      'sub-range-binders
      (list
       (vector
        ;; 2 is the length of the identifier "it", 6 of "a2when"
        (syntax-local-introduce #'it) 0 2 0.5 0.5
        (syntax-local-introduce #'_a2when) 0 6 0.5 0.5)))]))

(a2when 32 ;; [P]
        (displayln it) ;; [Y]
        (a2when 42 ;; [Q]
                (displayln it))) ;; [Z]
-----------------------------------------------------------------------

Which has done wonders for my arrows in the past!
But... hovering over either `awhen2` makes all the `awhen2` glow; and
sends arrows out to both `it`, as well as the `it` at [W] and [X]
(I’ve concatenated both code snippets in my source).

I hover over `it` at [Y], and I get all my `it` glowing (and I mean
ALL of them); and arrows into the `it` from the syntax parameter and
BOTH `awhen2`.


Is it possible to get DrRacket to put arrows between [P]->[Y] and
[Q]->[Z] ?


Thanks,

Tim

-- 
Tim Brown CEng MBCS <[email protected]>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                City Computing Limited · www.cityc.co.uk
      City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
                T:+44 20 8770 2110 · F:+44 20 8770 2130
────────────────────────────────────────────────────────────────────────
City Computing Limited registered in London No:1767817.
Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
VAT No: GB 918 4680 96

-- 
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.