[chuck-users] Problem with mixed float int lists
Hans Aberg
haberg at math.su.se
Wed Dec 9 18:35:56 EST 2009
On 10 Dec 2009, at 00:18, Kassen wrote:
>> 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?
Yes, that is it how it appeared in my program. I post a note about it
here soon.
> 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.
Yes, one must think carefully as to not have bad rules - the risk is
that some unexpected functions may be called.
> 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
Yes, and that is the first rule I want for arguments as well.
> 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.
For consistency, [] should work as you suggest - that is how it is in
Haskell, for example.
It would be the normal thing.
Hans
More information about the chuck-users
mailing list