Dave O Well-Known Member Licensed User Longtime User May 7, 2013 #1 Just tried the new 2.7 beta, which has a lot of features I'm really looking forward to. On compile of an existing app, I noticed that the log warned that some variables had no type for this code: Code: Copy Sub drawLineOnPanel(x1, y1, x2, y2 As Int) Turns out that this syntax, while valid during a DIM statement, isn't for a sub. It's supposed to be more explicit: Code: Copy Sub drawLineOnPanel(x1 As Int, y1 As Int, x2 As Int, y2 As Int) I assume it worked in earlier versions because B4A is easygoing about types and does automatic casting. Would it be possible/useful for the first syntax shown above to work? Would make DIM and SUB consistent, and seems to be more readable. Thoughts?
Just tried the new 2.7 beta, which has a lot of features I'm really looking forward to. On compile of an existing app, I noticed that the log warned that some variables had no type for this code: Code: Copy Sub drawLineOnPanel(x1, y1, x2, y2 As Int) Turns out that this syntax, while valid during a DIM statement, isn't for a sub. It's supposed to be more explicit: Code: Copy Sub drawLineOnPanel(x1 As Int, y1 As Int, x2 As Int, y2 As Int) I assume it worked in earlier versions because B4A is easygoing about types and does automatic casting. Would it be possible/useful for the first syntax shown above to work? Would make DIM and SUB consistent, and seems to be more readable. Thoughts?
Erel B4X founder Staff member Licensed User Longtime User May 7, 2013 #2 The "shorthand" syntax is only valid for Dim and Type declarations. I agree that it is confusing. This is why the warning is important. It cannot be changed at this stage as it will break existing code. Upvote 0
The "shorthand" syntax is only valid for Dim and Type declarations. I agree that it is confusing. This is why the warning is important. It cannot be changed at this stage as it will break existing code.
Dave O Well-Known Member Licensed User Longtime User May 7, 2013 #3 Love the warnings so far. I've recompiled a few apps and found some orphan variables and several cases of undeclared variables. Nothing that caused actual problems (that I know of), but it feels good to clean 'em up anyway. Upvote 0
Love the warnings so far. I've recompiled a few apps and found some orphan variables and several cases of undeclared variables. Nothing that caused actual problems (that I know of), but it feels good to clean 'em up anyway.