Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:47 30 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Option Request

Author Message
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:35am 28 Nov 2014
Copy link to clipboard 
Print this post

Hi

I was playing with some older code and discovered a problem with the variable
names as some of the different types of variables have the same name
Then after reading the change log properly

" To prevent a common type of programming error variables with the same name but different types are no longer supported. ie, var = 123 : var$ = "abc" will now cause an error"

So the question is would to be possible to make this an option ie on by default and off by setting an OPTION Variabletype off or some thing similar

Anybody else with any thoughts around this ?

Regards
Jman
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 11:09am 28 Nov 2014
Copy link to clipboard 
Print this post

John
I don't care if this is an option or not but I would never knowingly use variables the way you describe. If there is a need to associate variables by name then I would use a descriptive appendage or similar.
Example:
var.one
var.two
Bob
 
G8JCF

Guru

Joined: 15/05/2014
Location: United Kingdom
Posts: 676
Posted: 11:44am 28 Nov 2014
Copy link to clipboard 
Print this post

In a previous post about this subject, http://www.thebackshed.com/forum/forum_posts.asp?TID=7078&PN =3&TPN=5

  robert.rozee said  
5. i really hate the new requirements that variable names be unique, ie A and A$ are mutually exclusive names. i really really think that this should be a configurable option the same as "OPTION EXPLICIT" that defaults to being off. amongst other things, it may break existing code.


and

  Geoff said  

This is amazing, previously I got a lot of stick because this was allowed!

It was a bad practice and I believe that the critics had a good point. Also the change was necessary to allow variables to optionally not use a type suffix.

It will break a few programs (it broke one of mine) but the change was necessary. And before anyone asks, I don't want to make it yet another option - there are too many already.


Peter
The only Konstant is Change
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 01:52pm 28 Nov 2014
Copy link to clipboard 
Print this post

Thanks Peter

I missed that one but I do agree with Robert

Regards
Jman
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 02:01pm 28 Nov 2014
Copy link to clipboard 
Print this post

Sorry to pester you, and this is a slight digression from topic, but why is having A and A$ NOT being allowed a problem?

Is it more just that it breaks existing code, and you have to port the code to the new version of MMBASIC?
Smoke makes things work. When the smoke gets out, it stops!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 03:35pm 28 Nov 2014
Copy link to clipboard 
Print this post

If a variable name does not describe what it is used for then the name is wrong.
Having a number and a string version of the same variable is just silly.
It would save so much debugging time when that is not allowed that it will make up the little problem of changing existing code.
A simple search and replace will do the change in a few seconds.
.
Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 03:48pm 28 Nov 2014
Copy link to clipboard 
Print this post

OK, I can see the logic in that now. Thanks.
Smoke makes things work. When the smoke gets out, it stops!
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 04:07pm 28 Nov 2014
Copy link to clipboard 
Print this post

  TZAdvantage said   If a variable name does not describe what it is used for then the name is wrong.
.



Oh Dear this going to be can of worms so this the last post about this for me.

So if we had the hours of the day in a string say hours$ but now we wanted this
as an integer to do some math on then calling the variable hours is silly
really !!!

Jman
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 07:29am 29 Nov 2014
Copy link to clipboard 
Print this post

HoursText$
Hours

Problem solved.

Microblocks. Build with logic.
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 08:07am 29 Nov 2014
Copy link to clipboard 
Print this post

Hour$
Hours

Even simpler.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 08:38am 29 Nov 2014
Copy link to clipboard 
Print this post

Dylan; I'm with you on that one - however I see any 'well fuelled eyes' missing the odd '$' and 'S' typo among a big listing!!

For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024