[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] retrieving a structure's symbol name
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] retrieving a structure's symbol name |
Date: |
Wed, 24 Jul 2019 16:01:02 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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
signature.asc
Description: PGP signature