[chuck-users] time and truth (bug?)

Kassen signal.automatique at gmail.com
Thu Jul 24 15:00:00 EDT 2008


2008/7/24 Stephen Sinclair <radarsat1 at gmail.com>:

> Agreed.  The && operator does an implicit cast to boolean values, so
> it should work, since it shouldn't actually be comparing int and time,
> but comparing two booleans which have been derived from int and time.
> I'd say its a bug.
>
>
Yes, that's how I look at it as well.

Behind the scenes, BTW, it turns out "true" is treated as a integer (we
don't have booleans at all), at least according to the error messages but
that doesn't matter much. Stefan is right that we can't go casting anything
into anything, but we're not; we are evaluating the value for being
non-zero, which is different and in fact has been shown to work already for
single clauses.

I ran into it, BTW, stuffing a command (storing now, which itself returns
"now" of type "time") into the condition of a "if" clause to make sure it
only ran if the first check was valid yet regardless of the third and last
condition. You can wonder whether that's good practice but I was four or
five tabs deep already and this (would have) saved an extra one. With the
improvement to if-clause parsing of two or so versions ago this has become
more important since using multiple clauses is more powerful now.... but I
can definitely see how this was previously overlooked.

I'll add it to the Wiki as a bug, if Ge disagrees we can remove it again but
right now I say "bug".

Yours,
Kas.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080724/8b699126/attachment.htm>


More information about the chuck-users mailing list