Talk:Petit Computer 3/@comment-14600979-20140627175136/@comment-173.72.38.64-20140628005036

There are two different ways the system could work, even given Discordstew's example is valid. It could be that whenever the function name is assigned to, the function immediately returns that value. Or, it could be that the function name works as just another local variable until  is encountered, then the value of that local variable is used as the return value of the function. This would allow the function name itself to be used as a 'working variable' in storing intermediate steps of a long calculation. In either case, if the system encounters  before the function name is assigned to, there needs to be some policy for that: probably, either an error, or the default value for the return type of the function (0 for numerical functions, the empty string for string functions).

As for local variables, the most sensible thing would be the keyword  followed by a list of variable names.

DEF ProductIsNeg A,B LOCAL X X = A*B IF (X < 0) THEN ProductIsNeg=TRUE ELSE ProductIsNeg=FALSE END DEF

Then, the value X will not be affected by calls to. For example, the code

X=50 IF ProductIsNeg(2,3) THEN PRINT "This should never happen" PRINT X

will show 50. Without X being declared as local, the code would show 6 (presumably).

But, that's just speculation. As I have said before, I don't have a lot of hope that SmileBasic V3 will conform to expectations.