[racket] Please help with syntax

From: Roman Klochkov (kalimehtar at mail.ru)
Date: Sat Jun 28 03:59:19 EDT 2014

 Thank you!


Sat, 28 Jun 2014 09:41:38 +0200 от "Jos Koot" <jos.koot at gmail.com>:
>#lang racket
> 
>(define-syntax (set!-values* stx)
> (syntax-case stx ()
>  ((_ (var ...) values-expr)
>   (with-syntax (((local-var ...) (generate-temporaries #'(var ...))))
>  #'(let-values (((local-var ...) values-expr))
>     (set!* var local-var) ...)))))
> 
>(define-syntax (set!* stx)
> (syntax-case stx ()
>  ((_ var val) (free-identifier=? #'var #'_) #'foid)
>  ((_ var val) #'(set! var val))))
> 
>(define foid (void))
> 
>(define-values (a b c) (values 1 2 3))
>(set!-values* (_ _ c) (values 4 5 6))
>(list a b c)
>
>Jos
>
>
>________________________________
>
>From: users [mailto:users-bounces at racket-lang.org] On Behalf Of
>Roman Klochkov
>Sent: sábado, 28 de junio de 2014 8:43
>To: Racket Users List
>Subject: [racket] Please help with syntax
>
>
>I need to define syntax set!-values*, that will ignore _ in value
>place.
>
>Such as
>(define a #f)
>(set!-values* (_ _ a) (values 1 2 3)) ; should set a to 3.
>
>But I have two problems:
>1. _ don't want to pattern match in syntax case. If I make it
>literal, I can't match "anything else".
>2. How to omit extra values. It seems that in any case I have to
>assign them to something...
>
>Can you help me? I hope, that my problem in fact not hard, but I
>have not enough experience to solve it.
>
>-- 
>Roman Klochkov 
>
>


-- 
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140628/c8e5d41a/attachment.html>

Posted on the users mailing list.