[futurebasic] Re: [FB] Odd Parameter Syntax

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2009 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Fri, 20 Mar 2009 07:28:34 -0700
On Mar 19, 2009, at 8:49 PM, Max Taylor wrote:
>>
>> In FBtoC, '=' is a synonym for '#' when either appears in front of  
>> a function argument. They both mean "evaluate the argument as an  
>> expression and pass its value, even if the called function's  
>> declaration would otherwise require the address of a variable to be  
>> obtained and passed".

One situation where this occurs is passing pointers ( say to a record  
structure )  to functions. Within the called function that receives  
the pointer, it might call another function that also requires a  
pointer to that same record structure. This second call would use a  
'#' before the record structure name to pass it "as is". Without the  
'#' an attempt would be made to generate the address to the record but  
this would be wrong because it already contains a pointer to the record.



local fn ProcessIt ( aRecPtr as ^someRec )
end fn


local fn test ( theRecPtr as ^someRec )

fn ProcessIt( #someRec ) // receiver wants pointer to record, so pass  
as is since it is already a pointer.

end fn

dim as someRec   myRec

fn test ( @myRec )



Brian S