realbasic-nug
[Top] [All Lists]

Re: An interesting DIM gotcha

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: An interesting DIM gotcha
From: William Squires <wsquires at satx dot rr dot com>
Date: Thu, 31 Aug 2006 21:09:00 -0500
Cc:
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20060831194607 dot 5982B148D114 at lists dot realsoftware dot com> <561EA6E5-1D61-458A-8763-DDBE70F10A00 at animeigo dot com>
Which is exactly why I stay away from using the "New" syntax in DIM statements! I explicitly New my (reference) variables instead.

On Aug 31, 2006, at 5:57 PM, Robert Woodhead wrote:

Quick quiz, campers.  What does the following statement do?

  DIM reg1,reg2,reg3 as new regEx

If you said "create three regEx objects", BZZZT! Wrong! It creates one regEx object, and points all three variables at it!

Checking the manual, there is no mention of this minefield (which of course, blew my foot off today). Checking the feedback, I find:

http://www.realsoftware.com/feedback/viewreport.php?reportid=iyhptsui

wherein another amputee, some years back, complained of being maimed, and was told it's the proper behavior. Note the request for documentation, which was also ignored.

Well, it may be "proper" (though I would argue that 99.44% of the time, the intent of the programmer is going to be to create 3 objects), but it's not expected. And worse, it's a bitch to figure out what is actually going on.

I personally would lobby that the above construction be a compile error - the argument being that it's ambiguous.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

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

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


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