[AccessD] Function vs Sub

jwcolby jwcolby at colbyconsulting.com
Tue Feb 24 08:09:54 CST 2009


Yes, but "return anything" has an overhead implication.  At the machine code level, a function has a 
storage location somewhere that is set to something when the function returns.  The code has to 
explicitly set the value of the function return location to something.  So MAYBE that "return value 
location" is being manipulated, even though when that "something" is "returned" to the caller, it is 
not being placed into a set of ears.

If you explicitly set the return value of the function inside of the function then it definitely 
WILL manipulate that return value location.  As an example, you might cause a function to return an 
error code, even though in some cases the caller never checks for errors.

To be honest though, computers are so fast that worrying about that overhead doesn't make it onto my 
radar.

John W. Colby
www.ColbyConsulting.com


Stuart McLachlan wrote:
> Now we are getting philosophical :-)
> 
> "If a tree falls in a forest and no one is around to hear it, does it make a sound?" 
> 
> Answer??
> "Sound is vibration, transmitted to our senses through the mechanism of the ear, and 
> recognized as sound only at our nerve centers. The falling of the tree or any other 
> disturbance will produce vibration of the air. If there be no ears to hear, there will be no 
> sound."  
> 
> x= myFunction() demonstrably returns an Empty Variant
> 
> does "Call myFunction()"  *return* anything? If so, where to?
> 
> Cheers,
> Stuart (aka Bishop Berkely)
> 
> 
>> Well, it will always return "something", if for nothing else an empty
>> Variant ... though that is supposed to be slightly less than Nothing -
>> which hardly is anything - so right you are: No value. 
>>
>> /gustav
>>
>>>>> stuart at lexacorp.com.pg 24-02-2009 11:02 >>>
>> Good point.   I often use an Autoexec macro which calls a Startup() 
>> function which doesn't return a value.  
>>
>> Stuart
>>
>> On 24 Feb 2009 at 10:45, Gustav Brock wrote:
>>
>>> The only reason I see to not write a sub when a return value is not
>>> needed, is if the (sub)function will be used in a macro as these can't
>>> call subfunctions. 
>>>
>>> /gustav
>>
>>
>> -- 
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
> 
> 



More information about the AccessD mailing list