realbasic-nug
[Top] [All Lists]

Re: Merits of nested DIM (WAS re: [ANN] RB Code Reports version 1.3)

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Merits of nested DIM (WAS re: [ANN] RB Code Reports version 1.3)
From: Tim Jones <tjmac at tolisgroup dot com>
Date: Mon, 30 Apr 2007 19:17:43 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <NAEEKPONICFANBGONHNIAEBOEBAA dot tim at telios dot com>
On Apr 30, 2007, at 7:10 PM, Tim Hare wrote:

> Andy Dent wrote
>>
>> Quoting Thom McGrath <lists at thezaz dot com>:
>>
>>> Just curious, why is this considered a warning? Is there some  
>>> kind of
>>> overhead that I missed, or is it just messy code.
>>
>>> On Apr 30, 2007, at 4:48 PM, Brendan Murphy wrote:
>>>
>>>> and the second is to check for misplaced
>>>> DIM statements (DIMs imbedded within blocks of code)
>>
>> Now that it is available (I moved up from 5.5 a few months ago), I
>> quite frequently use it to guarantee scope of variables.
>
> Note, however, that there is overhead associated with DIM in that it
> initializes the variable; it isn't purely a scope thing.  Dimming a  
> variable
> inside a loop will add overhead to the loop and should be treated  
> in the
> same way as other loop invariants - move them outside the loop.

But ... Brendan's check is for ANY block of code.  I very oftne place  
DIM's inside of If - Then blocks as they are not needed if the If  
goes one way rather than another.  This is a very valid use and does  
not incur the issue you mention of DIMing within a loop.

Tim
--
Tim Jones
tjmac at tolisgroup dot com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>