Disallow use of '$' when it isn't part of a variable name

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Demivec
Addict
Addict
Posts: 4261
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Disallow use of '$' when it isn't part of a variable name

Post by Demivec »

I noticed that it is possible to use '$' as the 'type' specification with various keywords.

Code: Select all

Procedure$ test()
  ProcedureReturn "second"
EndProcedure

Define$ a

a = "first"

Debug a
Debug test()
Even though '$' and '.s' are the same type it seems strange that they can be used interchangeably in these instances. This is due in part to the fact that '$' would normally be a required part of a variable name but isn't in these instances.

It would make more sense to disallow the use of '$' in these instances to declare the type when it is not directly associated with a variable name.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Disallow use of '$' when it isn't part of a variable nam

Post by IdeasVacuum »

.... I think it would make sense to discontinue the use of $ completely. Using .s is more consistent.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Disallow use of '$' when it isn't part of a variable nam

Post by ts-soft »

IdeasVacuum wrote:.... I think it would make sense to discontinue the use of $ completely. Using .s is more consistent.
+ 1
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Disallow use of '$' when it isn't part of a variable nam

Post by luis »

IdeasVacuum wrote:.... I think it would make sense to discontinue the use of $ completely. Using .s is more consistent.
I disagree. I use $ everywhere for example and I like it over .s because I can see immediately where I'm using a string without using the usual notations or prefixes. It's so different from the other types (all numbers in the end) that's a plus for me any time I look through my code. I use it even in lists and maps names for the same reason.

Change it now would be criminal anyway. Simply don't use it and hate me when you read some of my code.


I don't have any problem with the original request though (even if it seem coherent to me... and maybe other people is using that form), as long I can still use $ in variables names.
Last edited by luis on Tue Nov 06, 2012 1:13 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Disallow use of '$' when it isn't part of a variable nam

Post by MachineCode »

Luis is right. There are two data types: numeric and string. There has to be a quick way to see which is which when reading code.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Disallow use of '$' when it isn't part of a variable nam

Post by Fred »

Don't worry, it's not going to change :)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Disallow use of '$' when it isn't part of a variable nam

Post by IdeasVacuum »

There has to be a quick way to see which is which when reading code.
Are you seriously suggesting that you can't see ".s" amongst ".i", ".d", ".f" ? I think there is sufficient difference between those letters to differentiate :mrgreen: In any event, it is good practice to prefix your vars with the type letter - if you don't, then it's actually the numerical values that could cause confusion, given MyVar.i, MyVar.d and MyVar.f. With a prefix, there is no doubt about type later in the code when the type specifier is dropped: sMyVar, iMyVar, dMyVar, fMyVar.

Hey ho, each to his own, I just see MyVar$ as ugly - it's not clear if it's a new var or a predefined one.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Disallow use of '$' when it isn't part of a variable nam

Post by MachineCode »

IdeasVacuum wrote:Are you seriously suggesting that you can't see ".s" amongst ".i", ".d", ".f" ?
No, I mean after the initial declaration. You only need to have "value.s" once, and then refer to it as "value" everywhere after. So if you read code later in a procedure that says "value", it doesn't indicate if it's a string or numeric. But as you said, you can prefix it with "s" for "sValue" to indicate... or do as I prefer, and append "$" at the end for "value$".
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Golfy
User
User
Posts: 97
Joined: Wed Mar 21, 2012 6:10 pm

Re: Disallow use of '$' when it isn't part of a variable nam

Post by Golfy »

MachineCode wrote:
IdeasVacuum wrote:Are you seriously suggesting that you can't see ".s" amongst ".i", ".d", ".f" ?
No, I mean after the initial declaration. You only need to have "value.s" once, and then refer to it as "value" everywhere after. So if you read code later in a procedure that says "value", it doesn't indicate if it's a string or numeric. But as you said, you can prefix it with "s" for "sValue" to indicate... or do as I prefer, and append "$" at the end for "value$".
+1
and any basic language should have $ for string, else it would be Pascal, dot.Net, C, C#... :mrgreen:
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Disallow use of '$' when it isn't part of a variable nam

Post by skywalk »

I also prefer the '$' in my string variable names.
And I'd like to go a step further...
Enable simultaneous use of Ascii and Unicode Strings!

Code: Select all

Define.s myAscii$    = "1byte/char"
Define.s myUnicode$$ = "2bytes/char"
If I want to use Unicode strings in a listviewgadget or stringgadget, but not in my entire app, I am forced to compile with Unicode and do lots of Unicode to Ascii conversions with the majority of my code. Or can I compile in Ascii and somehow pass Unicode formed memory to the listviewgadgets or stringgadgets?

Apologize if this is off topic?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Disallow use of '$' when it isn't part of a variable nam

Post by Guimauve »

Hello everyone,

When the syntax of a programming language that allows something we do not like, it is our responsibility to discipline themselves and write code in a way that seems right.
Personally this is the list of element I don't like in PureBasic because I consider them as an extremely bad practices :
  • The use of "$" for string variable and constants definition
    The use of "With/EndWith" on structures and interfaces
    The use of ":" to put many instructions on the same line
    The use of "Global" variables, arrays, linked lists and maps (I use them only when I really have no alternative, it's extremely rare !)
    The use of "EnableExplicit"
So I don't use them but when I take a code given by someone in the forum and I see the elements from the black list, I take time to completely review the code in question.

Best regards
Guimauve
Dear Optimist, Pessimist,
and Realist,

While you guys were
busy arguing about the
glass of water, I DRANK IT !

Sincerely,
the Opportunist
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Disallow use of '$' when it isn't part of a variable nam

Post by netmaestro »

I like it just as it is.
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Disallow use of '$' when it isn't part of a variable nam

Post by rsts »

Fred wrote:Don't worry, it's not going to change :)
Thank you.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Disallow use of '$' when it isn't part of a variable nam

Post by Guimauve »

netmaestro wrote:I like it just as it is.
As I do ! Because the only important thing is the final compiled programs.

Best regards
Guimauve
Dear Optimist, Pessimist,
and Realist,

While you guys were
busy arguing about the
glass of water, I DRANK IT !

Sincerely,
the Opportunist
User avatar
Regenduft
Enthusiast
Enthusiast
Posts: 121
Joined: Mon Mar 02, 2009 9:20 pm
Location: Germany

Re: Disallow use of '$' when it isn't part of a variable nam

Post by Regenduft »

Disallow use of '$' when it isn't part of a variable name
Why should such things be disallowed, if it is simply possible to just not use it (like I also do)? :? I guess there are no circumstances where this will lead to a hard to find bug, but it gives PureBasic some sweet flavor for some people.
(But it would be nice, if this possibility would be mentioned in PureBasics documentation!)

Concerning the '$' in variable names: Same goes here, if you don't like it, then just don't use it! I would get a step futher and allow '$' as the part of a procedure names, if it's returning a Strings! But I guess this is not going to come. (This would trigger much to many flame wars... :wink:)
Post Reply