Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DIM - AS - VARIABLE TYPE likely bug
#9
(05-03-2024, 02:00 PM)bartok Wrote:
(05-03-2024, 12:59 PM)bplus Wrote:
Quote:but we incur into a "Name already in use" error if we write:

DIM A AS INTEGER
DIM A AS STRING

ah, there is no suffix for qb64 to tell the differenece between the 2 a's

this lets you define everything as a type unless you explicitly say something different
DefInt A-Z
Dim A As String

I have understood. 
IMO, QB could have been programmed in a way in which the suffix of the varible "A" definied with "DIM A AS INTEGER" was "%", as it is in the case of "DIM A%", considered that in both the ways we define exactly the same variabile. But QB is conceived so that we can have:
DIM A%
DIM A!
DIM A$
DIM A&
etc,
but we cannot have
DIM A AS INTEGER
DIM A AS SINGLE
DIM A AS STRING
DIM A AS LONG
etc.


The only reason I found for this, is that if we use "AS" instead of the suffixes, then in the code is possible to use variable name without having to add the suffix each time and, in order to be able to do that, only one "A" must be allowed.

But finally, even if at first this could seem a simplification, actually I prefer to use suffixes for 2 reasons:
1. We could have variables that actually are exactly the same thing and therefore should have the same name. For example a coordinate X, that it is integer(%) or single(!) depending if we are on a view port coordinate or in physical screen coordinate. So, using (AS) it will be compulsory to use different variable name, but I don't find anything clearer than the possibility of using X% and X!;

2. I find that presence of the suffixes actually makes the code more readable.

So, I think is preferable to DIM variables and arrays with suffixes, avoiding the use of AS.

yes having suffix makes clear what type and wont let you forget

but me, i hate to type, specially those keys that require the use of shift thats 3 keys for a% and the last 2 have to be aligned in time, oh so much more work (specially if your shift key is broken) ;-))
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
DIM - AS - VARIABLE TYPE likely bug - by bartok - 05-03-2024, 06:59 AM
RE: DIM - AS - VARIABLE TYPE likely bug - by bplus - 05-03-2024, 02:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,227 12-19-2025, 12:51 PM
Last Post: Heimdall
  Sub not Reconizing Dim as String pmackay 18 1,476 10-16-2025, 03:32 PM
Last Post: pmackay
  for performance, what's the best variable type to use for boolean _TRUE & _FALSE ? madscijr 12 1,256 09-29-2025, 02:59 PM
Last Post: dakra137
  Loading from file into _MEM? and LEN a TYPE... Unseen Machine 9 976 08-03-2025, 02:55 AM
Last Post: SMcNeill
  Either I'm doing MID$( wrong or it has a bug TDarcos 4 813 04-13-2025, 11:14 PM
Last Post: TDarcos

Forum Jump:


Users browsing this thread: 1 Guest(s)