One hopefully helpful piece of information is that _all_ values in Racket
are structs. So this predicate is telling you that this kind of value is
revealing its inherent "structness" to you or not.

In this case, the struct isn't transparent so it isn't revealing it. (Just
like cons pairs don't reveal their structs, neither do rational numbers or
procedures, etc.)

Hopefully this helps the docs make more sense.

Robby

On Sat, Dec 9, 2017 at 2:27 PM David Storrs <david.sto...@gmail.com> wrote:

> (struct fruit (name color))
>
> -> (struct? (fruit 'apple 'red))
> #f
>
> This surprised me.  I'm trying to wrap my head around the docs for
> struct? and struct-info? and not having a lot of success.  Is there a
> way to simply say "is this a struct of some sort?"
>
> Context:
>
> I'm playing around with structs that contain information about structs
> and I'd like to be able to validate the information that's going in:
>
> (struct field-info (field-name predicate getter setter required?
> default on-update)
>   #:guard (lambda  (field-name predicate getter setter required?
> default on-update type)
>             (define/contract (init-field-info field-name predicate
> getter setter required? default on-update)
>               (-> symbol?                   ; field name
>                   (-> any/c   boolean?)     ; predicate
>                   (-> struct? any/c)        ; getter
>                   (-> struct? struct?)      ; setter
>                   boolean?                  ; required
>                   (or/c (not/c procedure?)  ; default
>                           (-> struct? any/c))
>                   (-> struct? any/c any)    ; on-update
>                   any ; unchecked return value
>                   )
>               (when (and required? (not-equal? default
> 'no-default-specified-by-field-info))
>                     (raise-arguments-error 'init-field-info
>                                        "Cannot specify a default for a
> required field"
>                                        "default" default))
>               (values field-name predicate getter setter required?
> default on-update))
>             ;
>             (init-field-info field-name predicate getter setter
> required? default on-update)))
>
> --
> 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