I just implemented that here: https://github.com/AlexKnauth/colon-kw <https://github.com/AlexKnauth/colon-kw>
Although it will give you a read error for things like :123 or other things where the part after the colon isn't a symbol. > On Oct 14, 2015, at 8:32 AM, Robby Findler <[email protected]> > wrote: > > That's what I meant to be saying. And yes: stupid me to forget about > readtables! > > Robby > > > On Wed, Oct 14, 2015 at 7:31 AM, Alex Knauth <[email protected]> wrote: >> Should we make this into a meta-language? >> >> #lang colon-kw racket >> (define (a:b a :b c) (+ a c)) >> (a:b -1 :b -5) >> >> That way it would not be a change to racket and it wouldn't break >> everything, but those who want it can have it. >> >> >>> On Oct 14, 2015, at 7:51 AM, Jay McCarthy <[email protected]> wrote: >>> >>> It is simpler than a reader parameter: >>> >>> #lang racket/base >>> >>> (define read-colon-keyword >>> (case-lambda >>> [(ch port) >>> (string->keyword (symbol->string (read/recursive port)))] >>> [(ch port src line col pos) >>> (datum->syntax #f (read-colon-keyword ch port) >>> (list src line col pos))])) >>> >>> (define (make-colon-keyword-readtable) >>> (make-readtable (current-readtable) >>> #\: >>> 'non-terminating-macro >>> read-colon-keyword)) >>> >>> (module+ test >>> (require rackunit) >>> (define (reads in out) >>> (check-equal? (read (open-input-string in)) out)) >>> (parameterize ([current-readtable (make-colon-keyword-readtable)]) >>> (reads "a:b" 'a:b) >>> (reads ":a" '#:a) >>> (reads "#:a" '#:a))) >>> >>> On Wed, Oct 14, 2015 at 7:40 AM, Robby Findler >>> <[email protected]> wrote: >>>> It would not be too hard, I believe, to add a parameter to the reader >>>> so that symbols starting with colons read the same as keywords, and >>>> then to build a language like s-exp and at-exp that would let you use >>>> that notation in a fairly seamless and interop-friendly way. Even >>>> getting syntax coloring shouldn't be too hard. >>>> >>>> >>>> Robby >>>> >>>> >>>> On Wed, Oct 14, 2015 at 12:12 AM, Neil Van Dyke <[email protected]> >>>> wrote: >>>>> I think that Racket 6.3 would be a great time to make `:abc` read the same >>>>> as `#:abc`. >>>>> >>>>> For those of us who are pained deeply by `#:abc`, being able to use `:abc` >>>>> would be a big aesthetic improvement for Racket. >>>>> >>>>> Neil V. >>>>> -- You received this message because you are subscribed to the Google Groups "Racket Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/C59F1C4F-D98F-49A3-BFD7-A7B77ECA6A9E%40knauth.org. For more options, visit https://groups.google.com/d/optout.
