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

Re: safe eval



Quoting "wil at home":
> int r = fprintf (stderr, "foo");
> fprintf() should return the number of bytes written or negative if it
> failed.
> I got 3 which is right.  Admittedly, who knows where does stderr go in
> Windows.
> I wonder how MzScheme arrived at the error (I could look at the source, I
> know, but it looks like way beyond me.)

MzScheme manipulates stderr to implement non-blocking output (at least,
non-blocking from MzScheme's point of view, so that it can run other
threads). In particular, MzScheme uses fileno() and _get_osfhandle() to
get the low-level file handle; probably, in this case, stderr is a
dummy FILE*, and there's no handle, or something like that.

> I am pretty confused about scheme_eval_string() and
> scheme_eval_string_all().
> The docs says that for the latter if the "all" flag is not 0 then the string
> will be read and evaluated until the end of the string.  Isn't that supposed
> to be the case anyway?

scheme_eval_string() reads one expression from the string, ignores the
rest of the string, and evaluates the expression.

scheme_eval_string_all() (when the second argument is non-zero), reads
an expression from the string, evaluates it, reads another expression
from the string, evaluates it, etc.

When scheme_eval_string_all()'s second argument is 0, it acts just like
scheme_eval_string().

Matthew