[chuck-users] Problem with mixed float int lists

Kassen signal.automatique at gmail.com
Wed Dec 9 18:18:09 EST 2009


So isn't this what you want?
Hmmm, this is a tricky case, I see what you mean now. You are talking about
callig overloaded functions using anonymous arrays, as a example of
determining the type of these arrays, right? I see no real harm in your plan
but mainly I think that this sounds quite dangerous as a practice and should
probably be considered bad-ish form anyway. I don't have a strong opinion on
this, right now.

I thought you were talking about assigning a anonymous array to a named one
at instantiation, like this;

[1, 1.1, 1.2] @=> float foo[]; //this won't fly

That's one case where I think it's perfectly clear what is meant and that
the "1"(int) can safely be cast to float, as it can here;

1 => float bar; //this is fine

This may be as bit of a exception because here we can determine very clearly
what was meant, like we can when returning arrays from functions, but those
are also the cases where I get annoyed by my own typos most. In the general
case it does seem a bit odd indeed, though at least the behaviour is
consistent and predictable.

As a side note; some time ago I complained about the lack of anonymous
arrays of length zero. Like this;

[1,2] @=> int fine;
[1] @=> int still_fine;
[] @=> int fails;

It turns out that we actually can. but need to do it like this;

new int[0];

This can be handy when returning from functions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20091210/2db7a69a/attachment.html>

More information about the chuck-users mailing list