Aha... I agree that's a bit weird. Perhaps lines like these:

y => int z;

are seen as an initialization of z, where y can be taken from the outer scope, and not treated the same as

int z;
y=> z;

/Stefan

On Wed, Apr 22, 2009 at 10:19 PM, Hans Aberg <haberg@math.su.se> wrote:
On 22 Apr 2009, at 21:01, Stefan Blixt wrote:

Compilers can't always be expected to understand every kind of error, and that error message isn't the worst I've seen :) Still, if the opportunity os there to change it to something better, now harm done. The situation can be translated to this:

int x;
1 => x[1];

which gives the same subscript error message. Hans's code is otherwise without problems - ChucK allows (like many other languages) to reuse a variable identifier in a new block, so x can be redeclared as an int in the inner while loop, overshadowing the outer x which is an array.

The problem is really that 'chuck' accepts

  x[msg.which] => int x;
Then when a line after that is added

  x[msg.which] => int x0;
it complains about this line, giving that cryptic message, despite the fact that it is correct.

When the first line is accepted, that gives the impression that this name overloading is legal, though it differs from C++. Thus I started to use it.

Chuck needs to make up its mind: is this name overloading legal or not. If it is not, it should always be rejected.


 Hans


_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



--
Release me, insect, or I will destroy the Cosmos!