unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: William Morgan <wmorgan@masanjin.net>
Subject: vports from c questions
Date: Fri, 10 Jan 2003 15:31:50 -0500	[thread overview]
Message-ID: <20030110203150.GA17757@masanjin.net> (raw)
In-Reply-To: <m3wuldki0h.fsf@laruns.ossau.uklinux.net>

Dear Guile gurus,

I am now at the point in my application where I would like Guile to be
able to read from and write to a vport under my control. There is no
scm_c_make_soft_port, so what I'm doing is the following (for an
output-only port):

SCM vec = scm_c_make_vector(5, SCM_BOOL_F);
scm_vector_set_x(vec, scm_int2num(0), scm_c_make_gsubr("write a char",
		 1, 0, 0, (SCM (*)())handle_write_char);
scm_vector_set_x(vec, scm_int2num(1), scm_c_make_gsubr("write a string",
		 1, 0, 0, (SCM (*)())handle_write_string);
 
However, in the case of multiple vports, each of which references
my handle_write_char and handle_write_string functions, these two
functions have no way of telling which port is calling them, and thus
where in my application to send the output.

Questions:

1) Is there a nice way of specifying some kind of closure, from the C
   side, such that I can provide additional arguments to my
   handle_write_* functions? (I can think of two ways, one involving a
   scm_eval_string("(lambda (char) (...") in the above code, and one one
   involving a table of function pointers---but neither of these seems
   pretty.)

2) If not #1, do people see this as an API issue?

3) If #2, any suggestions on what you'd like the API to be if I were to
   submit a patch?

Thank you,

-- 
William <wmorgan@masanjin.net>


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


      reply	other threads:[~2003-01-10 20:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-30  1:31 wrong-type-arg in scm_display_backtrace William Morgan
2002-12-31 23:42 ` Neil Jerram
2003-01-05  3:57   ` William Morgan
2003-01-06 19:06     ` Neil Jerram
2003-01-07  5:42       ` William Morgan
2003-01-08 20:21         ` Neil Jerram
2003-01-08 22:38           ` William Morgan
2003-01-09 23:42             ` Neil Jerram
2003-01-10 20:31               ` William Morgan [this message]

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=20030110203150.GA17757@masanjin.net \
    --to=wmorgan@masanjin.net \
    /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).