On Wed, Jul 24, 2019 at 03:49:13PM +0200, Marco Maggi wrote:
> Ciao,
> 
>   I know  that it is  dirty, but is it  possible to retrieve  the symbol
> name of  a structure  from the  block object?  If  I create  a structure
> with:
> 
>    (define (make-it)
>      (##sys#make-structure 'spiffy))
> 
>    (define O
>      (make-it))
> 
> can  I extract  "spiffy"  from the  structure object  bound  to "O"?   I
> searched "library.scm" in CHICKEN's 5.1.0 source without success.

You can access slot 0 to get it:

(##sys#slot (##sys#make-structure 'foo) 0) => foo

There's no official way to get at it.  But, if you are on CHICKEN 5.1
the define-record-type type name will contain it:

#;3> (define-record-type foo (make-foo) foo?) 
#;4> foo   
foo

And it will be namespaced with the module if it is defined in a module.
But beware, we might change the representation of record types to be
objects instead of symbols at some point so we can add introspection
to records.

Cheers,
Peter

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to