unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* marking SCM values in client data of port structure
@ 2006-03-11  7:47 Marco Maggi
  2006-03-11  9:42 ` Neil Jerram
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Maggi @ 2006-03-11  7:47 UTC (permalink / raw)


Ciao,

   from inspection of 'scm_markstream()' and
'scm_gc_mark_dependencies()' in I guess that: the mark
function of a port driver is invoked again and again
until it returns SCM_BOOL_F; in the sequence of
invocations it must return the next SCM value until
all of the values stored in the client data (stream
field of scm_t_port) have been returned once.

  So it is the business of the mark function to implement
an iterator over all the SCM values, keeping the iterator
state in the client data structure itself.

  But, it is my understanding that the mark function is
invoked with a single parameter, which: the first time
is the value in the 'stream' field and subsequent times
is the SCM value of the previous invocation.

  So: is it mandatory to organise SCM values in the
client data in a list and write the mark function to
return the cons cells? That is the at the first invocation
of the mark function we return the first cell and at
subsequent invocations we return the cdr?

--
Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: marking SCM values in client data of port structure
  2006-03-11  7:47 Marco Maggi
@ 2006-03-11  9:42 ` Neil Jerram
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Jerram @ 2006-03-11  9:42 UTC (permalink / raw)
  Cc: guile-user

"Marco Maggi" <marco.maggi-ipsu@poste.it> writes:

>   So: is it mandatory to organise SCM values in the
> client data in a list and write the mark function to
> return the cons cells? That is the at the first invocation
> of the mark function we return the first cell and at
> subsequent invocations we return the cdr?

No.  If your client structure has n SCM slots, e.g.

struct client_data {
  int a;
  SCM b;
  char *c;
  SCM d;
  SCM e;
  float f[4];
  ...
}

your mark function just needs to call scm_gc_mark for each SCM:

client_mark (...)
{
  /* get client data pointer, then ... */
  scm_gc_mark (data->b);
  scm_gc_mark (data->d);
  scm_gc_mark (data->e);
  return SCM_BOOL_F;
}

If any of these SCMs is a compound object, scm_gc_mark will do the
recursion itself.

Did you try the documentation on this?  That should be easier than
trying to work it out from the code!  The relevant node is called
"Garbage Collecting Smobs".

      Neil



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: marking SCM values in client data of port structure
@ 2006-03-12  5:57 Marco Maggi
  0 siblings, 0 replies; 3+ messages in thread
From: Marco Maggi @ 2006-03-12  5:57 UTC (permalink / raw)


> Did you try the documentation on this?

Cough... now that I've read it, it is clear. Thank you.




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-12  5:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-12  5:57 marking SCM values in client data of port structure Marco Maggi
  -- strict thread matches above, loose matches on Subject: below --
2006-03-11  7:47 Marco Maggi
2006-03-11  9:42 ` Neil Jerram

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).