Hailstone:~ stefanblixt$ cat test.java
public class test {
  int f(int i) {
    int c =3;
    ++c %= 6;
  }
}

Hailstone:~ stefanblixt$ javac test.java
test.java:4: unexpected type
required: variable
found   : value
    ++c %= 6;
    ^
1 error

/Stefan

On Mon, Feb 9, 2009 at 10:51 PM, Kassen <signal.automatique@gmail.com> wrote:
Stefan;

> In fact, I think you can remove the % and it still blows - a pause and then
> Bus error here.

Thanks.

I thought I'd investigate some more and even this catches fire;

int count;
3 %=> (++count);

I tried that because admittedly the intended calculation order in
these expressions is a bit vague.

I'm not sure what proper behaviour would be here; "++count" is a bit
like a function that should return "count + 1" and clearly functions
aren't mutable but it's also a lot like a integer and that clearly is
mutable.


"++count%3 => count;" is fine but is that really more readable than "3
%=> ++count;"? I'm not very happy with having to reference "count"
twice. Some might argue I should simply use two lines but this kind of
thing is such a basic operation that I'd really like to have it on one
line and in a readable form.

WWJD? (What Would Java Do?)

Kas.
_______________________________________________
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!