Thanks I didn’t know about prop:match-expander.
Now the rename transformer seems to work but it’s not working as a
match-expander:
(define-match-expander+rename-transformer my-list
#:match-expander
(lambda (stx)
(syntax-parse stx
[(my-list expr:expr ...) ; doesn't work
#'(l
You want to use the prop:match-expander and prop:procedure properties for a
struct you bind for syntax. That way the match-expander has its piece and the
procedure provides the syntax transformer.
-Ian
- Original Message -
From: Alexander D. Knauth
To: racket users list
Sent: Sun, 20 Ju
Hi,
I have introduced modules and "conventions".
Identifiers in a pattern that begins with sym must match symbols
Identifiers in a pattern that begins with r or s must match numbers.
Identifiers in a pattern that begins with m or n must match exact integers.
The conventions are hard coded, so a
2013/12/29 Alexander D. Knauth :
> I was seeing if it would work with nested patterns and quasiquoted patterns
> and it didn't, so I had to change the rewrite function and use (vector?
> (syntax-e pat)) to check for a vector written like `#(,a:num ,b:num ,c:num).
>
> like this:
>
> (define (rewrit
2013/12/29 Alexander D. Knauth :
> I'm not really sure why this works either, but try this:
>
> (define-syntax (:match stx)
> (syntax-case stx ()
>[(:match val-expr [pat . more] ...)
> (with-syntax ([(new-pat ...) (for/list ([pat-stx (in-list (syntax->list
> #'(pat ...)))])
>
I was seeing if it would work with nested patterns and quasiquoted
patterns and it didn't, so I had to change the rewrite function and
use (vector? (syntax-e pat)) to check for a vector written like
`#(,a:num ,b:num ,c:num).
like this:
(define (rewrite pat)
(cond [(identifier? pat) (
I'm not really sure why this works either, but try this:
(define-syntax (:match stx)
(syntax-case stx ()
[(:match val-expr [pat . more] ...)
(with-syntax ([(new-pat ...) (for/list ([pat-stx (in-list (syntax-
>list #'(pat ...)))])
(datum->syntax pat-stx
Hi Alexander,
I extended your example to allow other patterns than symbols inside :pat.
> (match '(42 x) [(:pat (list n:num s:sym)) (list n s)])
(list 42 x)
This works fine. I now want to "hide" the :pat, that is I want to write:
(:match '(42 x) [(list n:num s:sym) (list n s)]
I just wrote a match-expander that does something like that:
(check-equal? (match 1 [(my-pat n:num) n]) 1)
(check-equal? (match 'x [(my-pat n:num) n] [_ 2]) 2)
like this:
#lang racket
(require rackunit)
(require (for-syntax
(only-in lang/htdp-intermediate-lambda
st
I'm not sure why this works and that doesn't, but try passing n as an
argument to the match expander:
#lang racket
(require rackunit)
(define-match-expander num:
(λ(stx)
(syntax-case stx ()
[(num: n)
#'(? number? n)])))
(check-equal? (match 1 [(num: n) n]) 1)
(check-equal? (ma
On 25 Jan 2013 18:27, "Matthew Flatt" wrote:
> So, I think the bug was the same one that shows up with `raco exe' and
> `match' in v5.3.1, and that bug has been fixed for the upcoming
> release.
Hurrah for just too late big reporting!
As an aside, would you expect 'raco --cgc' to work whether ra
At Fri, 25 Jan 2013 19:56:55 +, Tim Brown wrote:
> As an aside, would you expect 'raco --cgc' to work whether raco is CGC or
> 3M?
Yes, `--cgc' and `--3m' both with `raco ctool' independent of which
variant of Racket is running `raco' (but the default matches the
variant of Racket running `rac
I tried again with v5.3.1, instead of the current development version,
and this time I get the error that you see.
So, I think the bug was the same one that shows up with `raco exe' and
`match' in v5.3.1, and that bug has been fixed for the upcoming
release.
Racket Users li
I looked a bit further down the page to "3m embedding".
That requires the code you're suggesting. So there's no
confusion, I'm trying to embed the CGC version of racket
into my C program.
I also found a "racocgc" in my installation (previously I was
using the 3m version with a --cgc switch). I tr
At Fri, 25 Jan 2013 17:13:59 +, Tim Brown wrote:
> On 25/01/13 17:04, Matthew Flatt wrote:
> > I wasn't able to replicate the error that you get, but I notice that
> > your C code doesn't cooperate with the GC.
>
> I'm following the recipe in "1.5.1 CGC Embedding" in
> http://docs.racket-lang.
On 25/01/13 17:04, Matthew Flatt wrote:
I wasn't able to replicate the error that you get, but I notice that
your C code doesn't cooperate with the GC.
I'm following the recipe in "1.5.1 CGC Embedding" in
http://docs.racket-lang.org/inside/overview.html?q=embedding#%28part._embedding%29
I use
I wasn't able to replicate the error that you get, but I notice that
your C code doesn't cooperate with the GC.
Does it change anything if, in trampoline_main(), you add
MZ_GC_DECL_REG(1);
MZ_GC_VAR_IN_REG(0, e);
MZ_GC_REG();
at the start and
MZ_GC_UNREG();
before returning?
At
On Wed, Jan 23, 2013 at 7:10 AM, Tim Brown wrote:
>
> I am trying to embed racket into a C program, and have a module which uses
> "define-match-expander" (in conjunction with match).
>
> The attached scripts seem to show an inconsistency between a module
> that has been declared with declare_modu
18 matches
Mail list logo