Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri May 26, 2017 1:57 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 9:52 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
In matters such as upper vs. lower case RB is rather flexible. Almost anything will work (in contrast, for example, to VB).

The same is ALMOST true in RB of whether you put a space (or not) to the left or right (or not) of a parentheses symbol.

Thus ALL of the following work in RB (which doesn't really care which of you use):

Dim Day(07)As String
Day(1)="Sunday"
Day (2)="Monday"
Day( 3 )="Tuesday"
Day(4 )="Wednesday"
Day(5) ="Thursday"
Day (6) = "Friday"
Day ( 7 ) ="Saturday"

MsgBox Day(1)
MsgBox Day ( 2)
MsgBox Day(3 )
MsgBox Day( 4 )
MsgBox Day ( 5)
MsgBox Day ( 6)
MsgBox Day (7 )

Dim Month ( 12 ) As String
Month(1) = "January"
// etc.

Actually, since in the preceding example you can put a space or not in four possible positions (i.e., before the first parenthesis, after the first parenthesis, before the second parenthesis, after the second parnhesis), there are 2 x 2 x 2 x 2 or 16 possible ways of putting or not putting a space, ALL of which RB allows.

That's great. Some people complain that RB is not more restrictive in its requirements, but there is something to be said for letting the programmer decide on the practice he or she prefers.

I do have a minor complaint, however. I am one of the people who prefer lots of "white space" for readability. Thus my preference would be, for example, "Dim Day ( 7 ) As String" rather than, say, "Dim Day(7)As String". RB lets me do have that option ALMOST ALL the time, but (for some reason of its own) NOT ALL the time. There is one (and only one) exception that I know of.

In particular, RB does NOT allow "white space" when it comes to the parentheses you use when you define a property. "Day(7)" with no spaces is allowable, but "Day (7 )" with spaces is not,

Three questions: (1) Why is Real Software inconsistent in its requirements in that one (and only one) situation? (2) Does the documentation mention that inconsistency? (3) Is there any hope of persuading Real Software of removing the inconsistency and of allowing programmers to have the same choice they have everywhere else concerning parentheses and spaces?

Yes, I did spend a lot of time figuring out that RB in that single situation did NOT allow what I was allowed EVERYWHERE ELSE. (Curiously enough, I was allowed the space when making a Dim statement; see above).

Barry Traver


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 9:58 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
I can honestly say I've never dealt with this, as I tend to only use spaces within events/methods. Since I'm only looking at a single line at a time while viewing properties, I've never had an issue with readability. But if that's important to you, I'd suggest filing a feedback, then putting the link here so others can join on if it's important to them. :)

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 10:54 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Not sure I understand what you are saying...

dim a(7 ) as string ' space after 7
dim b( 7) as string ' space befor 7
dim c( 7 ) as string ' space before and after
dim d(7) as string ' no space


all these work just fine. Extra whitespace should never be a problem, lack of whitespace should only be a problem if it is required to delimit keywords or expressions

And even if RS allows it... you should get in the practice of putting whitespace BEFORE certain keywords like "AS"

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 12:19 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
I can't reproduce this either. This code compiles and works:
dim a (7) as string
dim b ( 9 ) as string
dim c ( 12 ) as string
a ( 0 ) = "hi"

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 1:57 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
He's talking about adding a property to the window or a module. Add Property doesn't allow extra whitespace. I presume it's because the parsing routines used are not as robust as the compiler's (this is interpreted by the IDE, DIM statements are processed by the compiler). In Add Property, it allows you to put "propertyname AS xxx" in the property name field, and the IDE will parse out the type. I'm guessing that the extra white space is confusing the IDE's parser.


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 3:33 pm 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Ah, I missed that, and it's true, extra spaces are not allowed when defining a property.

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Wed May 22, 2013 5:27 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
Declaring class/window properties isn't the only area in which REALstudio/Xojo has inconsistencies with parentheses. The other cases I know of are the AddHandler and AddressOf methods.

For example, this is valid:

AddHandler MyObject.MyEvent, AddressOf MyEventHandler


but these are not:

'Spaces or no spaces, it doesn't matter
AddHandler MyObject.MyEvent, AddressOf(MyEventHandler)
AddHandler(MyObject.MyEvent, AddressOf MyEventHandler)
AddHandler(MyObject.MyEvent, AddressOf(MyEventHandler))


This annoys me because I like unspaced, nested parentheses.

Dim Day(7) As String
AddHandler(MyObject.MyEvent, AddressOf(MyEventHandler))

looks neat and clean to me;
Dim Day( 7 ) As String
AddHandler MyObject.MyEvent, AddressOf MyEventHandler

Just looks weird to me.

_________________
Boredom Software


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Thu May 23, 2013 1:42 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
DaveS wrote:
Not sure I understand what you are saying...

dim a(7 ) as string ' space after 7
dim b( 7) as string ' space before 7
dim c( 7 ) as string ' space before and after
dim d(7) as string ' no space


all these work just fine. Extra whitespace should never be a problem, lack of whitespace should only be a problem if it is required to delimit keywords or expressions

And even if RS allows it... you should get in the practice of putting whitespace BEFORE certain keywords like "AS"


I'm with you 100%, I think, on the matter of "white space." My regular practice is to put "white space" (i.e., a blank space) before BASIC keywords. I also regularly put a blank space after commas as well as before and after parentheses. When mathematical symbols indicate operations (e.g., addition or subtraction) rather than sign (positive or negative), I put a blank space before and after the math symbol,and so on. For me at least, the "white space" promotes readability.

You say, "Extra whitespace should never be a problem." I agree there as well. Extra whitespace SHOULD never be a problem and ordinarily it is NOT a problem, BUT there is ONE EXCEPTION and that is when you define an array as a PROPERTY.

This does NOT work when you declare an array as a property:

Month (-1) As String

RB does not like (and will not accept) the blank space before the left parenthesis. The blank space has to be removed for RB to be happy. Curiously, a blank space before the left parenthesis in a DIMension statement IS acceptable to RB:

DIM Month ( -1 ) As String

Incidentally, it's not a question of putting or not putting a space before or after a number like 7 (which is also an interesting topic), but specifically the question of putting or not putting a space before or after a parenthesis symbol. Ordinarily RB doesn't care with the ONE EXCEPTION I mentioned.

Barry Traver


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Thu May 23, 2013 1:49 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
ktekinay wrote:
I can't reproduce this either. This code compiles and works:
dim a (7) as string
dim b ( 9 ) as string
dim c ( 12 ) as string
a ( 0 ) = "hi"


That's my point. I'm happy that all your examples compile and work. What I'm not happy about is that putting a blank space in front of the left parenthesis makes RB unhappy.

Barry Traver


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Thu May 23, 2013 2:03 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
timhare wrote:
He's talking about adding a property to the window or a module. Add Property doesn't allow extra whitespace. I presume it's because the parsing routines used are not as robust as the compiler's (this is interpreted by the IDE, DIM statements are processed by the compiler). In Add Property, it allows you to put "propertyname AS xxx" in the property name field, and the IDE will parse out the type. I'm guessing that the extra white space is confusing the IDE's parser.


You got it! I do question whether something that simple should be confusing to the IDE's parser and I'm not sure that a single blank space is "EXTRA white space," but that represents, I guess, my own perspective or preference (or bias?).

Barry Traver


Top
 Profile  
 
 Post subject: Re: Parentheses and Optional Spaces Before and After Them
PostPosted: Thu May 23, 2013 3:43 pm 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
charonn0 wrote:
Declaring class/window properties isn't the only area in which REALstudio/Xojo has inconsistencies with parentheses. The other cases I know of are the AddHandler and AddressOf methods.

AddHandler and AddressOf are language keywords, not methods. So they don't use parenthesis. Think of them more like the Call keyword, which also does not allow parenthesis.

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group