declaring argument types in a sub

Dave O

Well-Known Member
Licensed User
Longtime User
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:


B4X:
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:

B4X:
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?
 

Dave O

Well-Known Member
Licensed User
Longtime User
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
Top