> On Mar 19, 2018, at 11:37 AM, David Storrs <david.sto...@gmail.com> wrote:
> 
> This does not work:

> (define user (hash 'name  "bob" 'job (hash 'type 'dev 'id 112)))
> (match user
>   [(hash-table ('name name) ('job (hash-table 'type type 'id id)))
>    (displayln name)
>    (displayln type)
>    (displayln id)])
> ; id49: unbound identifier;
> ;  also, no #%top syntax transformer is bound
> ;   in: id49
> ; [,bt for context]

Jos Koot already found the problem, but why is this error message so horrible? 
This seems like a bug in match.

According to the Docs, `hash-table` patterns look like one of these, where ooo 
means a program-level ellipsis:

(hash-table (pat pat) ...)
(hash-table (pat pat) ...+ ooo)

The pattern (hash-table 'type type 'id id) doesn't follow one of those forms, 
but it match seems to parse it anyway.

The reason is that there is a secret undocumented, unspecified form of the 
`hash-table` pattern:

(hash-table p ...)
where p is either (pat pat) or id. If it's an id, then it matches a key-value 
pair.

So according to this secret feature, the pattern means something completely 
different that you never meant it to mean.

For extra weirdness:

#lang racket
(define user (hash 'type 'dev 'id 112))
(match user
  [(hash-table 'type x 'id y)
   (displayln x)])

;quote16: unbound identifier;
; also, no #%top syntax transformer is bound in: quote16

This secret feature of `hash-table` patterns is wreaking havoc on everything.

Alex Knauth

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

Reply via email to