Re: How to use display_stack function
> "John L. Stein" writes
>
> STk_add_new_primitive("display-stack", tc_subr_1, display__stack);
>
> in
>
> PRIMITIVE STk_init_stack(void)
>
> and
>
> static PRIMITIVE display__stack(SCM s)
> {
> if (NSTACKP(s)) STk_err("display-stack: bad stack", s);
> display_stack(s, "blu", 1);
> return (STACK(s)->len) ? Truth: Ntruth;
> }
>
>
> But it bombs. I know the problem is with "blu" in display_stack(s, "blu", 1);
> in the function just above. It is supposed to be the port. Could someone tell
> me how to write the function so that it can use ports. Or is there an examples.
The second argument of display_stack must be a Scheme port. You can obtain the
current standard outputport with the C function STk_current_output_port which
implement the "current-output-port" STk primitive.
display_stack(s, STk_current_output_port(), 1);
or even
STk_add_new_primitive("display-stack", tc_subr_1_or_2, display__stack);
static PRIMITIVE display__stack(SCM s, SCM port)
{
SCM p;
p = (port == UNBOUND) ? STk_current_output_port(): port;
if (!OPORT(p)) Err("display-stack: bad-port", p);
if (NSTACKP(s)) STk_err("display-stack: bad stack", s);
display_stack(s, p, 1);
return (STACK(s)->len) ? Truth: Ntruth;
}
to take an optionnal output port pareameter, which defaults to the current
standard output.
Hope it helps
-- Erick
Received on Wed Oct 09 1996 - 16:55:07 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 21 2014 - 19:38:59 CEST