It is currently Fri Feb 26, 2021 8:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 12:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 434
Location: Germany
BarryG wrote:
Sicro wrote:
The apostrophe is not yet used in the PureBasic language

Yes it is, to convert literal characters to their ASCII value:
Right. I forgot, although I often use it when working with string pointers. But it is the only case where the apostrophes are used.

_________________
Image
Why OpenSource should have a license :: DarkColor-Scheme for PureBasic
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: Windows 7 x64 (VirtualBox) :: Newest PureBasic version


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 3:51 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1749
Sicro wrote:
BarryG wrote:
Sicro wrote:
The apostrophe is not yet used in the PureBasic language

Yes it is, to convert literal characters to their ASCII value:
Right. I forgot, although I often use it when working with string pointers. But it is the only case where the apostrophes are used.

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 7:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 25, 2014 5:25 pm
Posts: 434
Location: Germany
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
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.

@All: Which character as number separator would you prefer?
In the meantime, I also tend to use apostrophes.

_________________
Image
Why OpenSource should have a license :: DarkColor-Scheme for PureBasic
PureBasic-CodeArchiv-Rebirth: Git-Repository / Download – Any help is welcome!
Manjaro Xfce x64 (Main system) :: Windows 7 x64 (VirtualBox) :: Newest PureBasic version


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 8:43 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1150
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.


Characters with multiple usage:

$ 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


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 9:38 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1749
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Sun Feb 21, 2021 11:30 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3972
Location: Berlin, Germany
Something like this has been requested already more than 7 years ago:
Commas in numbers

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 1:02 am 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1749
Comma would never work because it's a procedure parameter separator.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 6:24 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3972
Location: Berlin, Germany
Tenaja wrote:
Comma would never work because it's a procedure parameter separator.

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.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 7:26 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1301
Location: right here
Little John wrote:
Something like this has been requested already more than 7 years ago:
Commas in numbers

freaks solution is both clever and stupid. :P
underscore please. I'm not waiting for it though.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 7:34 am 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3972
Location: Berlin, Germany
#NULL wrote:
underscore please. I'm not waiting for it though.

Exactly the same for me.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 5:39 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 1749
Little John wrote:
Tenaja wrote:
Comma would never work because it's a procedure parameter separator.

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.

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!

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Mon Feb 22, 2021 7:01 pm 
Offline
Addict
Addict

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3972
Location: Berlin, Germany
Tenaja wrote:
It was not, however, as unproductive than your presumptuous dig. Usually, you are a much more positive contributor than that.

Just because you don't understand what it's all about, doesn't mean that you are allowed to take that tone with me!

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Tue Feb 23, 2021 9:31 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 688
Even if I don't like number seperators,
there are some characters left: ^°´`
for separetion.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Tue Feb 23, 2021 9:35 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1301
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: Allow underscore as separator for number literals
PostPosted: Tue Feb 23, 2021 11:25 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2432
Location: Singapore
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!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye