If it doesn't absolutely have to be a hash, you can definitely
make dict-ref and dict-iterate-key etc. work differently.

-Philip

On Fri, Jun 30, 2017 at 12:15 PM, Matthew Butterick <m...@mbtype.com> wrote:

>
> > On Jun 30, 2017, at 10:07 AM, Robby Findler <ro...@eecs.northwestern.edu>
> wrote:
> >
> > Maybe you could make the impersonator (it would be a chaperone, really
> > in what I'm suggesting) signal an error if it gets one of the private
> > keys and then hand out only the hashes with the impersonator around
> > it, keeping the "raw" one around for code that is allowed to access
> > the private keys?
>
> I still want the private keys to be directly accessible. Maybe this is the
> best bet, where I include a #f/#f entry in the table, and then I can use
> #:when to do the filtering easily:
>
> (define ih (impersonate-hash (make-hash (list (cons #f #f)))
>                              (λ (h k) (values k (λ (h k v) v)))
>                              (λ (h k v) (values k v))
>                              (λ (h k) k)
>                              (λ (h k) (and (eq? k 'foo) k))))
> (hash-set! ih 'foo 42)
> (hash-set! ih 'bar 21)
> (hash-set! ih 'zam 7)
> (for/list ([(k v) (in-hash ih)]
>      #:when k)
>      (cons k v)) ; '((foo . 42))
> (hash-ref ih 'foo) ; 42
> (hash-ref ih 'bar) ; 21
> (hash-ref ih 'zam) ; 7
>
> --
> 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.

Reply via email to