Get it while it's hot! int count; 3 %=> count++; //or 3 %=> ++count; Whether such constructions should be used at all is of course debatable and we do have this; ++count%3 => count; ....which does work but the above examples shouldn't lead to VM-collapses, which they do. Yours, Kas.
In fact, I think you can remove the % and it still blows - a pause and then
Bus error here.
/Stefan
On Sun, Feb 8, 2009 at 3:38 AM, Kassen
Get it while it's hot!
int count;
3 %=> count++; //or 3 %=> ++count;
Whether such constructions should be used at all is of course debatable and we do have this;
++count%3 => count;
....which does work but the above examples shouldn't lead to VM-collapses, which they do.
Yours, 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!
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.
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
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!
WWJD? (What Would Java Do?)
Oh boy...
This is what we're trying to do, right?
int count;
3 % (++count) => count;
This makes sense. Of course, the answer to the question WWJD is
really "throw an error telling us why it makes no sense" rather "crash
outright." ;-)
But that's why we love this list.
-Mike
On Tue, Feb 10, 2009 at 4:41 AM, Kassen
Stefan;
required: variable found : value
Hmmmm, yes, I suppose that's true.
Kas.
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Mike;
WWJD? (What Would Java Do?)
Oh boy...
Admittedly that could have been seen as being in moderately bad taste but sometimes such things are too good to pass up on for me.... ;¬)
This is what we're trying to do, right?
int count; 3 % (++count) => count;
Basically what I'm trying to do is this; //let's march; ++step%4 => step; to generate; 0,1,2,3,0,1,2,3,0,1,2.....
This makes sense.
To me constructs like that are quite essential in -for example- generating a clock with a counter for a repeating beat, yes.
Of course, the answer to the question WWJD is really "throw an error telling us why it makes no sense" rather "crash outright." ;-)
But that's why we love this list.
Java just has more people testing it (at least right now, clearly this must be remidied in time). Yours, Kas.
participants (3)
-
Kassen
-
mike clemow
-
Stefan Blixt