guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

vports from c questions


From: William Morgan
Subject: vports from c questions
Date: Fri, 10 Jan 2003 15:31:50 -0500
User-agent: Mutt/1.4i

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 <address@hidden>




reply via email to

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