My team is writing code for RobotC, a language with C-like syntax. It is mainly used as an introductory to programming in robotics. It has the base C stuff: if statements, for and while loops, functions and it even has structs, arrays and pointers, but they aren't used often. The main difference is that it's interperted, has multithreading, isn't free, and you can only compile one file at a time.
We wanted to make a motor move. To do this, you would usually write.
motor[motorA] = 50;
motor
is an array provided by RobotC that contains all the values it will set the motors to. motorA
is an enum for the wire port.
50 is the power level.
My team mate accidentally (or maybe purposely) wrote this instead
motor(motorA) = 50;
I was about to correct him, when surprisingly, it compiled and ran fine!
I know Java and a little bit of normal C, and this just doesn't make sense to me. You can't set the value of a function return...can you?
Could someone please explain why this works?