chicken-users
[Top][All Lists]
Advanced

[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 21:09:16 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jul 24, 2019 at 07:22:45PM +0200, Marco Maggi wrote:
> Mh.   If I  understand correctly  this is  to avoid  collisions for  the
> record printers,  and stuff like that.

It is to avoid collisions for all accessors and predicates.  If I define
a record type X of 2 slots in module A, and in module B, I define a record
type also called X of 1 slot, then "X?" would return #t for both records.
And if I want to access the second slot of the record in module A, but
pass in an X of module B (which has only one slot), this will cause an
unsafe memory access.  That's because we can't safely check first if the
record is of the correct type.

>   If I define my  own record-type
> constructor, and I want to  use the built-in record printers facilities:
> is  CHICKEN expecting  me  to qualify  the name  with  the module?   The
> symbols I want to use are expected to be unique...

No, you can use unqualified symbols.  We still do that in core itself too,
for SRFI-4 vectors and for ports and so on.  But this is really low-level
stuff, and there's usually a better way.  What exactly are you trying to
accomplish?

Cheers,
Peter

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]