[chuck-users] chout and cherr confuse me [BUG?]

Szilveszter Tóth silvestre.toth at gmail.com
Wed Oct 21 04:45:37 EDT 2009


Dear Kas,

I fear that this has to do with buffering (whether a stream is buffered or
not), and if buffered, buffer size makes a difference, too.

For example, in C/C++, if you want to see the output of a fprintf() call for
sure, you have to call fflush(). I don't know if it has a ChucK equivalent,
though.

Szilveszter aka Hillaby

2009/10/20 Kassen <signal.automatique at gmail.com>

> Fellow ChucKists,
>
> Consider this edit of one of the new examples, I just made this because I
> was trying to figure out the difference between chout and cherr and why the
> plain example's output had the order in which the results of the operations
> were printed reversed;
> ---------------------8<--------------------------
> // 'chout' is chuck out, pronounced "shout"
> // 'cherr' is chuck err, pronounced "Cher"
>
> // output to console on stdout
> chout <= 1 <= " foo " <= 5.5 <= IO.newline();
>
> // output to console on stderr
> cherr <= 2 <= " bar " <= 5.5 <= IO.newline();
>
> <<<"start pause">>>;
> second => now;
> <<<"end pause">>>;
>
> // output to console on stderr
> cherr <= 3 <= " bar " <= 5.5 <= IO.newline();
>
>
> // output to console on stdout
> chout <= 4 <= " foo " <= 5.5 <= IO.newline();
> -----------------------------8<--------------------------------------
>
> Now, the output this gives varies with how many times we used the various
> commands in the recent past and on what, but it stabilises to this after
> running it a few times;
>
> [chuck](VM): sporking incoming shred: 1 (*chout.ck)...
> 2 bar 5.5
> "start pause" : (string)
> 4 foo 5.5
> 1 foo 5.5
> "end pause" : (string)
> 3 bar 5.5
>
> It seems to me that chout has some sort of internal buffer and that it
> takes two chout commands to reach the actual console, instead of one, like I
> expected. It also seems like cherr has a higher priority of some sort. maybe
> cherr commands print immediately while chout ones are delayed until time is
> advanced?
>
> I'd like to know what the intended behaviour is as I'm now just guessing
> about the difference between the two. Right now I'm leaning towards
> suspecting at least a bug in chout.
>
> Yours,
> Kas.
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20091021/26d0b8bd/attachment.html>


More information about the chuck-users mailing list