From: Marius Vollmer <marius.vollmer@uni-dortmund.de>
Subject: Re: The relationship between SCM and scm_t_bits.
Date: Tue, 04 May 2004 15:53:23 +0200 [thread overview]
Message-ID: <lju0ywfgdo.fsf@troy.dt.e-technik.uni-dortmund.de> (raw)
In-Reply-To: <lj7jvth7o3.fsf@troy.dt.e-technik.uni-dortmund.de> (Marius Vollmer's message of "Mon, 03 May 2004 17:06:20 +0200")
Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:
> Hi,
>
> I just got confused about our two 'fundamental' types, SCM and
> scm_t_bits.
[More random thoughts follow...]
Right now, the documented distinction between scm_t_bits and SCM is
that...
A variable of type `SCM' is guaranteed to hold a valid Scheme
object. A variable of type `scm_t_bits', on the other hand, may
hold a representation of a `SCM' value as a C integral type, but may
also hold any C value, even if it does not correspond to a valid
Scheme object.
This is a useful distinction, no doubt. However, it creates the
situation where user variables have a different type as the cell slots
in the heap.
Now, the distinction between scm_t_bits and SCM is only then practical
when converting between them has zero cost. SCM_PACK and SCM_UNPACK
can really only be casts that reinterpret the bits. If this would not
be the case, we would have to remove the distinction to get
performance back.
Thus, scm_t_bits and SCM can be pretty much identical and we can allow
the casting of pointers to them, too.
Better yet, we provide some markup that does the casting for the user.
That is, I now propose to _add_ SCM_CELL_OBJECT_LOC and to _keep_
SCM_CELL_WORD_LOC. That way, we take over responsibility for getting
the casting right.
Still, I'd want to change the type of fields in the heap from
scm_t_bits to SCM, just so that pointers to SCM are guaranteed to work
across the heap and user variables. Pointers to scm_t_bits might
still fail on strange platforms and we might then consider removing
SCM_CELL_WORD_LOC on those platforms.
Of course, this whole tedious ponderings can be avoided, as Paul
points out, by just disallowing pointers to SCM or to scm_t_bits
entirely. But we would need a very good reason for this: using
pointers the way delete_some does is completely reasonable right now.
One reason to disallow pointers would be that a precise garbage
collector that moves objects around can not easily deal with random
pointers into the middle of objects. However, that's only a
theoretical reason, I don't see getting there any time soon, if at
all.
So, unless a very good reason comes up, I want to allow pointers to
SCM.
> For example, consider a list that is pointed to by a global variable
> and some fairly standard way of dealing with singly-linked lists in C:
>
> SCM head;
>
> void
> delete_some ()
> {
> SCM *node_ptr = &head;
> if (should_delete (*node_ptr))
> *node_ptr = SCM_CDR (*node_ptr);
> else
> node_ptr = SCM_CDRLOC (*node_ptr);
> }
[There should be a loop in that function of course. ]
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2004-05-04 13:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-03 15:06 The relationship between SCM and scm_t_bits Marius Vollmer
2004-05-03 16:10 ` Marius Vollmer
2004-05-03 16:21 ` Paul Jarc
2004-05-04 13:53 ` Marius Vollmer [this message]
2004-05-04 17:16 ` Paul Jarc
2004-05-04 17:49 ` Marius Vollmer
2004-05-04 18:35 ` Paul Jarc
2004-05-05 10:00 ` Marius Vollmer
2004-05-05 14:58 ` Paul Jarc
2004-05-10 13:42 ` Marius Vollmer
2004-05-15 7:31 ` Dirk Herrmann
2004-05-17 18:09 ` Marius Vollmer
2004-05-15 15:00 ` Dirk Herrmann
2004-05-15 16:42 ` Dirk Herrmann
2004-05-17 19:22 ` Marius Vollmer
2004-05-17 20:17 ` Paul Jarc
2004-05-21 19:37 ` Dirk Herrmann
2004-05-21 20:30 ` Paul Jarc
2004-05-22 6:48 ` Dirk Herrmann
2004-05-23 15:03 ` Paul Jarc
2004-08-09 21:09 ` Marius Vollmer
2004-08-20 19:17 ` Dirk Herrmann
2004-08-21 16:16 ` Marius Vollmer
2004-10-03 9:09 ` Dirk Herrmann
2004-10-04 14:12 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lju0ywfgdo.fsf@troy.dt.e-technik.uni-dortmund.de \
--to=marius.vollmer@uni-dortmund.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).