[racket] specifying strings without escaping backslash

From: Greg Hendershott (greghendershott at gmail.com)
Date: Wed Dec 4 22:19:32 EST 2013

>> If you don't mind using `#lang at-exp racket`, I think you could write
>>
>>     @~a{C:\Users\Harry\SANSKRIT\GRETIL ALL\adyappu.htm}
>
> Or better here: @values{C:\Users\Harry\SANSKRIT\GRETIL ALL\adyappu.htm} to
> avoid the superfluous ~a operation.

Definitely superfluous in this example.

I have @~a{} in muscle memory because it's handy for a variety of
purposes, including as an alternative to format/printf.

    #lang at-exp racket

    (define x 1)
    (define y 10)

    (format "x is ~a, y is ~a, and x + y is ~a" x y (+ x y))
    ;; or
    @~a{x is @x, y is @y, and x + y is @(+ x y)}

    ;; both => "x is 1, y is 10, and x + y is 11"

It's not so much that it's less typing. In fact it's a bit awkward to
type, what with the shifting and upper-left-corner gymnastics.`

Instead it's not having to juggle `~a`s on the left and values on the
right. Harder to write in the first place and harder to
change/maintain later.

As a bonus it's especially nice when you can avoid escaping characters
like quotation marks:

    (format "\"x\" is ~a, \"y\" is ~a, and \"x + y\" is ~a" x y (+ x y))
    ;; vs.
    @~a{"x" is @x, "y" is @y, and "x + y" is @(+ x y)}


p.s. I believe http://www.mail-archive.com/users@racket-lang.org/msg07162.html
predates `~a` being added to Racket. So you don't need to define an
alias for `string-append` unless you find ~a ugly or unless even just
2 chars is 1 too many. :)

Posted on the users mailing list.