fun dur GetT() rises to invalid type
Hi there, I have a osc meta-instrument wich has a function to get the unit_time to advance. Something like: public class oscInstrument { // some members here // .... fun dur GetT(){ return T_}; } It compiles fine, but when used in the following manner: oscInstrument myInstrument; while(true) { //do_something //... noteDuration::myInstrument.GetT() => now } it rises the following error: invalid type 'oscInstrument' in postfix of dur expression... (must be of type 'dur') . However if I do the following: dur T; while(true) { //do_something myInstrument.GetT() => T; noteDuration::T=> now } everything works fine. Any ideas? Thanks, Eduard
it seems that the :: operator has precedence over the . operator (or they have the same precedence and are evaluated left to right), so noteDuration::myInstrument.GetT() is being interpreted as ((noteDuration::myInstrument).GetT()) Thus the compiler is trying and failing to interpret myInstrument as a dur type. it seems the desired behavior in your case is for the expression to be interpreted as (noteDuration::(myInstrument.GetT())) Parentheses should fix up the problem. this compiles fine and produces what i think is the behavior you desire: noteDuration::(myInstrument.GetT()) => now; spencer On Dec 15, 2005, at 8:42 PM, eduard wrote:
Hi there,
I have a osc meta-instrument wich has a function to get the unit_time to advance. Something like:
public class oscInstrument { // some members here // .... fun dur GetT(){ return T_}; }
It compiles fine, but when used in the following manner:
oscInstrument myInstrument; while(true) { //do_something //... noteDuration::myInstrument.GetT() => now }
it rises the following error: invalid type 'oscInstrument' in postfix of dur expression... (must be of type 'dur') .
However if I do the following:
dur T;
while(true) { //do_something myInstrument.GetT() => T; noteDuration::T=> now }
everything works fine.
Any ideas?
Thanks,
Eduard _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hi all, On Dec 15, 2005, at 8:59 PM, Spencer Salazar wrote:
it seems that the :: operator has precedence over the . operator (or they have the same precedence and are evaluated left to right), so
Yeah right on. (:: has the same precedence as .) The precedence of :: has been brought into question before: https://lists.cs.princeton.edu/pipermail/chuck/2005-February/ 000210.html Perhaps it's time to modify this. For now, we have boosted . precedence over :: (now in CVS). Thoughts? Best, Ge!
participants (3)
-
eduard
-
Ge Wang
-
Spencer Salazar