What happens when you execute:
true => lisaLeft.record;
is that you assign “"the value of true to the object property
lisaLeft.record, but because of the way the chuck operator is overloaded, this
is converted to:
lisaLeft.record(true);
However if you do something like
<<<listLeft.record>>>;
or <<<startRecording>>>;
where “startRecording” has the value of the function you defined, then
you’ll get the address of the function object itself. So, I imagine then if you
simply execute
startRecording;
nothing should happen – its the same as executing
24;
- the parser just throws it away. If the function you defined had
arguments, then executing
startRecording;
would give you a compilation error because it expected arguments and didn’t
get any.
-- Rich
Sent: Friday, September 19, 2014 5:21 PM
Subject: [chuck-users] Forgetting parenthesis in function calls
yields noerror
Hello list!
I just spent a little time scratching my head over these little
functions:
fun void startRecording() {
<<< "Record! ", index
>>>;
true => lisaLeft.record;
true => lisaRight.record;
}
fun void toggle() {
!active => active;
paintActive();
if (active) {
startRecording;
}
}
Everything seemed to be in order, I added a lot of print statements, and
could for the life of me figure out why the startRecording function wasn't
executed from toggle(). There was no error message, everything seemed to be in
order. Then I peered more closely and saw that I had forgotten to put
parenthesis in the function call:
startRecording();
After that everything started working. My question is: shouldn't a function
name all by itself result in an error of some kind?
Cheers,
Stefan Blixt
--
Release me, insect, or I will destroy the Cosmos!
_______________________________________________
chuck-users mailing
list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users