As far as I've been able to see, there are 2 ways to declare a variable ( leave aside Redim , or additionnal keywords like Shared, or variable/type versus type/variable order ) . Those are :
- Dim As SomeType someVariable , or
- As SomeType someVariable , only for fields sitting inside UserDefined Type
Let me know if I missed something here. Ok, suppose I'm right. It can lead to such a series :
Dim As Double testProbability = 0
Dim As Long nextPtrTableUpperBound = 1
Dim As Any Ptr nextPtrTABLE(1 To nextPtrTableUpperBound)
Dim As Long nextPtrOccurenceCountTABLE(1 To nextPtrTableUpperBound)
Dim As Long totalOccurenceCountFromTABLE = 0
Dim As Long totalAmountOfCoupleGenerated = totalizer \ 2
I suggest that one could make it a block like below :
Code: Select all
Dim As ''Dim Block start
Double testProbability = 0
Long nextPtrTableUpperBound = 1
Any Ptr nextPtrTABLE(1 To nextPtrTableUpperBound)
Long nextPtrOccurenceCountTABLE(1 To nextPtrTableUpperBound)
Long totalOccurenceCountFromTABLE = 0
Long totalAmountOfCoupleGenerated = totalizer \ 2
End Dim ''Dim Block end
I can list this series of advantages :
1/ In general , less typing and readability increased .
2/ In particular :
_ _ Possibility to comment the start of the block , example : 'global variables
_ _ Possibility to Copy/Paste easier if we wish to put this in a UDT (As Block?), or even in functions arguments
_ _ With an IDE like FBEdit, arises further possibility to Fold/Unfold the block
(and in others IDE folded block content is displayed in a yellow tip box when flying over, wich is very convenient)
_ _ Greater compatibility with C syntax with no sacrifying basic specificity
1/ It would break Scope rule of so called variable Block Visibility. . .
However, this is not inherent to blocks in an absolute maneer. A block could also be disconnected to any Scope behaviour if proved useful.
2/ It will ask for filtering nesting Block ability wich has no sense in this context
It's not a big problem to loose 1ms of syntactic check up for that, when you avoid so many compilation warnings and errors due to difficulty to write clean code.
However things would have to be put into the balance.
About DATA, I've been conviced that a Data Block/End Block would also be salvation when viewing this nice example code : viewtopic.php?f=3&p=208361#p208358
Thanx for giving attention.
(By advance, sorry if this issue had already been discussed. From my side view, it remains a recurrent concern.)