[futurebasic] Re: [FB] Function vs Function()

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2012 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Wed, 2 May 2012 09:50:20 +1200
Bernie wrote:

> rc wrote:
> 
>> I've noticed that when calling no-param C function names for FB Locals that  while there will be no complaint, nothing will work unless...() is included?
>> 
>> Local Fn FoosBall
>> Beep, whatever
>> End Fn
>> 
>> BeginCCode
>> FoosBall; // No result. Yet no complaint 
>> EndC
>> 
>> BeginCCode
>> FoosBall(); // Works, function is called or found.
>> EndC
>> 
>> So the rule when calling a void C function name (no params) is to always add the ()?
> 
> Correct.
> FoosBall(); calls the function. FoosBall; declares it.

No. The naked symbol FoosBall here is an expression, whose value is the address of the FoosBall() function note the parentheses. 

A peculiarity of C is that a statement may consist of an expression. This is valid C code but has no observable effect:
BeginCCode
1234;
5 * 6;
printf;
EndC

Robert P.