Right. I forgot, although I often use it when working with string pointers. But it is the only case where the apostrophes are used.BarryG wrote:Yes it is, to convert literal characters to their ASCII value:Sicro wrote:The apostrophe is not yet used in the PureBasic language
Allow underscore as separator for number literals
Re: Allow underscore as separator for number literals
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Allow underscore as separator for number literals
Whether they are used elsewhere is moot. Numbers are used in identifiers, yet you can also use them in literal constants too. The separator would be treated the same, but would not be allowed as the leading character.Sicro wrote:Right. I forgot, although I often use it when working with string pointers. But it is the only case where the apostrophes are used.BarryG wrote:Yes it is, to convert literal characters to their ASCII value:Sicro wrote:The apostrophe is not yet used in the PureBasic language
Re: Allow underscore as separator for number literals
I think it always makes sense to look where a character is already used in the syntax to avoid making parsing the code unnecessarily more complicated or to avoid confusion when reading the code.Tenaja wrote:Whether they are used elsewhere is moot. Numbers are used in identifiers, yet you can also use them in literal constants too. The separator would be treated the same, but would not be allowed as the leading character
@All: Which character as number separator would you prefer?
In the meantime, I also tend to use apostrophes.
Why OpenSource should have a license :: PB-CodeArchiv-Rebirth :: Pleasant-Dark (syntax color scheme) :: RegEx-Engine (compiles RegExes to NFA/DFA)
Manjaro Xfce x64 (Main system) :: Windows 10 Home (VirtualBox) :: Newest PureBasic version
Re: Allow underscore as separator for number literals
Characters with multiple usage:Sicro wrote:I think it always makes sense to look where a character is already used in the syntax to avoid making parsing the code unnecessarily more complicated or to avoid confusion when reading the code.
$ String identifier
$ Hexadecimal literal
% Modulo operator
% Binary literal
~ Bitwise NOT operator
~ Escaped string literal
# Constant
# Separator in macros
The above characters are used several times without problems (ok, the hash sign as separator in macros I find suboptimal, but it' s the way it is).
The single quotation mark as a separator in numeric literals would not lead to any conflicts and in my humble opinion it would be better to read than with an underscore.
sorry for my bad english
Re: Allow underscore as separator for number literals
Josh, you skipped all of the numbers and letters that can make numbers as well as identifiers.
Sure, it makes sense to revaluate double use, but this is actually a perfect use case. I've used compilers that have done it.
Sure, it makes sense to revaluate double use, but this is actually a perfect use case. I've used compilers that have done it.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Allow underscore as separator for number literals
Something like this has been requested already more than 7 years ago:
Commas in numbers
Commas in numbers
Re: Allow underscore as separator for number literals
Comma would never work because it's a procedure parameter separator.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Allow underscore as separator for number literals
If you read the whole thread, then you'll see that there was not only discussed about commas. It's also not necessary to repeat that old descussion again now.Tenaja wrote:Comma would never work because it's a procedure parameter separator.
Re: Allow underscore as separator for number literals
freaks solution is both clever and stupid.Little John wrote:Something like this has been requested already more than 7 years ago:
Commas in numbers
underscore please. I'm not waiting for it though.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Allow underscore as separator for number literals
Exactly the same for me.#NULL wrote:underscore please. I'm not waiting for it though.
Re: Allow underscore as separator for number literals
I have read this whole thread, as well as the one from 2013, which I also commented in. If we were required to refrain from duplication, we would have to delete this whole thread!Little John wrote:If you read the whole thread, then you'll see that there was not only discussed about commas. It's also not necessary to repeat that old descussion again now.Tenaja wrote:Comma would never work because it's a procedure parameter separator.
Statements of agreement, such as the one I made that you shunned, are merely comments. It was not, however, as unproductive than your presumptuous dig. Usually, you are a much more positive contributor than that.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Allow underscore as separator for number literals
Just because you don't understand what it's all about, doesn't mean that you are allowed to take that tone with me!Tenaja wrote:It was not, however, as unproductive than your presumptuous dig. Usually, you are a much more positive contributor than that.
Re: Allow underscore as separator for number literals
Even if I don't like number seperators,
there are some characters left: ^°´`
for separetion.
there are some characters left: ^°´`
for separetion.
Re: Allow underscore as separator for number literals
I don't think there's any point to this request anyway, because when you copy source codes from somewhere else (C++, StackOverflow, etc) then the separators aren't going to be there anyway. Are you going to manually change every number from the copied code?
So, -1 from me.
So, -1 from me.
Re: Allow underscore as separator for number literals
A prefix should be implemented to indicate such formatting, similar to the tilde (~) for escaping strings. Best to keep literals and formatting separate.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel