On Tue, 12 Apr 2016 11:17:31 -0500,
Héctor Mc wrote:
> 
> Thanks,
> 
> This start because I need a syntax like the next:
> 
> (define u (make-s user (nom ape sexo))
> (set-s u ((nom "nom" ) (ape "ape")))
> (get-s u 'nom)
> u ; --> '((nom "nom") (ape "ape") (sexo ""))
> 
> And I start using lists but I can't hidden. From there I changed to a struct 
> but now I get this problem.
> 
> set-usuario-key!: unbound identifier in module in: set-usuario-key!
> 
> How I can solve that?

Structs are not collections of key-value pairs, so there are no
accessors that can take the name of a field and access it.

They will, however, have accessors for individual fields, like
`set-usuario-nom!`. Those should work fine.

If you do want to have such a function, I would write it something like
this:

    (define (set-usuario-key! usuario key val)
      (cond [(equal? key 'nom) (set-usuario-nom! usuario val)]
            ...))

Or, if you really want key-value pairs, use hashes. Possibly wrapped in
a struct, to get the hiding you want.

Vincent

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