Re: [racket-users] Is there any way I can use the terse forms of quasiquote with at-exp?

2017-03-11 Thread Matthew Flatt
You could use

 , @~a{}

with a space between `,` and `@`.


Since that's sometimes too ugly, though, `@` has special handling of
comma that effectively swaps the order of the `@` and `,`. So, you
could use

  @,~a{}

to get the effect of

  ,@~a{}

without `,` combining `@`.


Note that if you just wanted to unquote `~a`, then you'd have to use
vertical bars to prevent `@,` from acting like `,@`:

  @|,~a|{}



Although

  @pregexp{\d\.\d}

s much nicer than

  #px"\\d\\.\\d"

beware that the former will compile the regexp every time the
expression is evaluated. Maybe we can eventually fix that. Meanwhile,
be sure to lift the expression to a module-level definition.


At Sat, 11 Mar 2017 15:31:54 +, Stephen De Gabrielle wrote:
> Hi,
> 
> Is there any way I can use the terse forms of quasiquote with at-exp?
> 
> I want to use @expressions{} inside a quasi quoted list, but the unquote
> comma captures the at-sign at ,@a~{}
> 
> I'm trying to achieve the following with the at-exp
> 
> ;working example
> #lang at-exp racket
> (require racket/random)
> (define (path)
>   (random-ref '["stream""brook" "path" "ravine" "forest" "fence" "stone
> wall"]))
> 
> (~a "beyond the " (path) ", ")
> @~a{beyond the @(path), }
> 
> 
> (random-ref
>  `(
>,(~a "beyond the " (path) ", ")
>   ;,@~a{beyond the @(path) })
>,(~a "along the " (path) ", ")
>   ;,@~a{beyond the @(path) })
>))
> 
> My reason is I find at-expressions more readable.
> 
> Kind regards,
> 
> Stephen
> 
> PS: Ive been very excited by at-exp since I read
> http://www.greghendershott.com/2015/08/at-expressions.html
> I despise double escaping, because I always make a mistake, so this made me
> very happy:
> 
> @pregexp{\d\.\d}  ; #px"\\d\\.\\d"
> 
> -- 
> 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] Is there any way I can use the terse forms of quasiquote with at-exp?

2017-03-11 Thread Stephen De Gabrielle
Hi,

Is there any way I can use the terse forms of quasiquote with at-exp?

I want to use @expressions{} inside a quasi quoted list, but the unquote
comma captures the at-sign at ,@a~{}

I'm trying to achieve the following with the at-exp

;working example
#lang at-exp racket
(require racket/random)
(define (path)
  (random-ref '["stream""brook" "path" "ravine" "forest" "fence" "stone
wall"]))

(~a "beyond the " (path) ", ")
@~a{beyond the @(path), }


(random-ref
 `(
   ,(~a "beyond the " (path) ", ")
  ;,@~a{beyond the @(path) })
   ,(~a "along the " (path) ", ")
  ;,@~a{beyond the @(path) })
   ))

My reason is I find at-expressions more readable.

Kind regards,

Stephen

PS: Ive been very excited by at-exp since I read
http://www.greghendershott.com/2015/08/at-expressions.html
I despise double escaping, because I always make a mistake, so this made me
very happy:

@pregexp{\d\.\d}  ; #px"\\d\\.\\d"

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