Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #1778 > unrolled thread

commas

Started bybob <bob@coolfone.comze.com>
First post2012-06-12 07:09 -0700
Last post2012-07-30 23:00 +0100
Articles 20 on this page of 24 — 14 participants

Back to article view | Back to comp.programming


Contents

  commas bob <bob@coolfone.comze.com> - 2012-06-12 07:09 -0700
    Re: commas Robert Wessel <robertwessel2@yahoo.com> - 2012-06-12 09:16 -0500
      Re: commas BGB <cr88192@hotmail.com> - 2012-06-12 09:53 -0500
      Re: commas "BartC" <bc@freeuk.com> - 2012-06-12 16:33 +0100
    Re: commas Paul Herber <paul@pherber.com> - 2012-06-12 15:37 +0100
      Re: commas Rui Maciel <rui.maciel@gmail.com> - 2012-06-12 16:14 +0100
    Re: commas "BartC" <bc@freeuk.com> - 2012-06-12 16:37 +0100
      Re: commas Rui Maciel <rui.maciel@gmail.com> - 2012-06-12 17:10 +0100
    Re: commas Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-12 09:32 -0700
      Re: commas Ben Pfaff <blp@cs.stanford.edu> - 2012-06-12 09:54 -0700
      Re: commas "BartC" <bc@freeuk.com> - 2012-06-12 18:05 +0100
        Re: commas Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-12 11:51 -0700
          Re: commas "BartC" <bc@freeuk.com> - 2012-06-12 20:36 +0100
            Re: commas Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-12 16:28 -0700
    Re: commas Thad Smith <ThadSmith@acm.org> - 2012-06-17 22:38 -0600
      Re: commas Robert Wessel <robertwessel2@yahoo.com> - 2012-06-18 00:02 -0500
        Re: commas blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2012-07-06 19:01 +0000
    Re: commas Jongware <jongware@no-spam.plz> - 2012-07-30 15:53 +0200
      Re: commas "BartC" <bc@freeuk.com> - 2012-07-30 15:50 +0100
        Re: commas "BartC" <bc@freeuk.com> - 2012-08-01 01:56 +0100
          Re: commas Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-08-01 03:31 +0100
      Re: commas rossum <rossum48@coldmail.com> - 2012-07-30 19:57 +0100
      Re: commas Fritz Wuehler <fritz@spamexpire-201207.rodent.frell.theremailer.net> - 2012-07-30 22:14 +0200
        Re: commas Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-07-30 23:00 +0100

Page 1 of 2  [1] 2  Next page →


#1778 — commas

Frombob <bob@coolfone.comze.com>
Date2012-06-12 07:09 -0700
Subjectcommas
Message-ID<f0d3d247-8eac-4ce0-bb61-296a58ea2035@googlegroups.com>
Are there any languages where you can actually use commas in the numbers?

So, instead of having to write:

int x = 5000000;

You could write:

int x = 5,000,000;

I think this could improve clarity a lot.

Is there really a good reason no one has done this?

[toc] | [next] | [standalone]


#1779

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-06-12 09:16 -0500
Message-ID<gjjet7t3jsftl11sqf1l7kqm13n70oeepq@4ax.com>
In reply to#1778
On Tue, 12 Jun 2012 07:09:19 -0700 (PDT), bob <bob@coolfone.comze.com>
wrote:

>Are there any languages where you can actually use commas in the numbers?
>
>So, instead of having to write:
>
>int x = 5000000;
>
>You could write:
>
>int x = 5,000,000;
>
>I think this could improve clarity a lot.
>
>Is there really a good reason no one has done this?


While commas specifically are probably a bad idea, since they're used
as other sorts of separators in most languages, there are languages
that allow that sort of thing.  Ada and Perl, for example, let you
write numeric literals with underscores for separation (so
"5_000_000").

Handy occasionally, but unless you're writing numbers in binary,
constants that large are not all that frequent, so it's usually a
modest issue.

[toc] | [prev] | [next] | [standalone]


#1781

FromBGB <cr88192@hotmail.com>
Date2012-06-12 09:53 -0500
Message-ID<jr7l87$huj$1@news.albasani.net>
In reply to#1779
On 6/12/2012 9:16 AM, Robert Wessel wrote:
> On Tue, 12 Jun 2012 07:09:19 -0700 (PDT), bob<bob@coolfone.comze.com>
> wrote:
>
>> Are there any languages where you can actually use commas in the numbers?
>>
>> So, instead of having to write:
>>
>> int x = 5000000;
>>
>> You could write:
>>
>> int x = 5,000,000;
>>
>> I think this could improve clarity a lot.
>>
>> Is there really a good reason no one has done this?
>
>
> While commas specifically are probably a bad idea, since they're used
> as other sorts of separators in most languages, there are languages
> that allow that sort of thing.  Ada and Perl, for example, let you
> write numeric literals with underscores for separation (so
> "5_000_000").
>
> Handy occasionally, but unless you're writing numbers in binary,
> constants that large are not all that frequent, so it's usually a
> modest issue.

yeah, my scripting language (BGBScript) also does this (uses '_' as a 
spacer for numbers).

[toc] | [prev] | [next] | [standalone]


#1783

From"BartC" <bc@freeuk.com>
Date2012-06-12 16:33 +0100
Message-ID<jr7ngm$57a$1@dont-email.me>
In reply to#1779

"Robert Wessel" <robertwessel2@yahoo.com> wrote in message 
news:gjjet7t3jsftl11sqf1l7kqm13n70oeepq@4ax.com...
> On Tue, 12 Jun 2012 07:09:19 -0700 (PDT), bob <bob@coolfone.comze.com>
> wrote:
>
>>Are there any languages where you can actually use commas in the numbers?
>>
>>So, instead of having to write:
>>
>>int x = 5000000;
>>
>>You could write:
>>
>>int x = 5,000,000;
>>
>>I think this could improve clarity a lot.
>>
>>Is there really a good reason no one has done this?
>
>
> While commas specifically are probably a bad idea, since they're used
> as other sorts of separators in most languages, there are languages
> that allow that sort of thing.  Ada and Perl, for example, let you
> write numeric literals with underscores for separation (so
> "5_000_000").
>
> Handy occasionally, but unless you're writing numbers in binary,
> constants that large are not all that frequent, so it's usually a
> modest issue.

I use 'big' numbers frequently enough (benchmarking loops, testing compilers 
with numbers near the limits, big number libraries etc.) that it's something 
I would use frequently. And the numbers don't need to be that big: 10000 and 
100000 can easily be mixed; 10_000 and 100_000 much less so.

Also sometimes you want digits grouped in a certain way, to reflect use 
(especially hex and binary) or to highlight a pattern.

And if the language has binary, and therefore has a separator, why not use 
it for other bases too.

But since it has virtually zero cost, there's no reason why a language 
shouldn't have this feature.

However I don't use commas (when I have to implement the feature) unless 
it's for user input, and even then they can be troublesome when entering a 
list.

-- 
Bartc 

[toc] | [prev] | [next] | [standalone]


#1780

FromPaul Herber <paul@pherber.com>
Date2012-06-12 15:37 +0100
Message-ID<2tket7d7hit6fn2o6tjr3k77up3a1ckt49@news.eternal-september.org>
In reply to#1778
On Tue, 12 Jun 2012 07:09:19 -0700 (PDT), bob <bob@coolfone.comze.com> wrote:

>Are there any languages where you can actually use commas in the numbers?
>
>So, instead of having to write:
>
>int x = 5000000;
>
>You could write:
>
>int x = 5,000,000;
>
>I think this could improve clarity a lot.
>
>Is there really a good reason no one has done this?

Be aware that in some locales the comma is used as the decimal seperator instead of the
thousands seperator.



-- 
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/          

[toc] | [prev] | [next] | [standalone]


#1782

FromRui Maciel <rui.maciel@gmail.com>
Date2012-06-12 16:14 +0100
Message-ID<jr7mdg$pfv$1@speranza.aioe.org>
In reply to#1780
Paul Herber wrote:

> Be aware that in some locales the comma is used as the decimal seperator
> instead of the thousands seperator.

This is true.  It is also one of the most annoying features that found their 
way to some particularly popular software packages, particularly when 
different interpretations of what a comma is supposed to represent lead to 
silent conversions between formats, which in turn introduce numerical errors 
which are measured in several orders of magnitude.


Rui Maciel

[toc] | [prev] | [next] | [standalone]


#1784

From"BartC" <bc@freeuk.com>
Date2012-06-12 16:37 +0100
Message-ID<jr7noo$6uu$1@dont-email.me>
In reply to#1778

"bob" <bob@coolfone.comze.com> wrote in message 
news:f0d3d247-8eac-4ce0-bb61-296a58ea2035@googlegroups.com...
> Are there any languages where you can actually use commas in the numbers?
>
> So, instead of having to write:
>
> int x = 5000000;
>
> You could write:
>
> int x = 5,000,000;
>
> I think this could improve clarity a lot.
>
> Is there really a good reason no one has done this?

Yes, because it interferes with syntaxes when comma is used for other 
purposes, such as separating elements of a list:

int x[] = {100,200,300,400};

Is that 4 elements, or the single number 100200300400?

But if the language doesn't provide some other way of separating digits, 
then sometimes you can provide something yourself:

int y = strtoint("100,200,300,400");

except it would be slower.

-- 
Bartc 

[toc] | [prev] | [next] | [standalone]


#1785

FromRui Maciel <rui.maciel@gmail.com>
Date2012-06-12 17:10 +0100
Message-ID<jr7pl1$31d$1@speranza.aioe.org>
In reply to#1784
BartC wrote:

> Yes, because it interferes with syntaxes when comma is used for other
> purposes, such as separating elements of a list:

That, and some programming languages actually have a comma operator that 
also handles and returns integral types.


Rui Maciel

[toc] | [prev] | [next] | [standalone]


#1786

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-06-12 09:32 -0700
Message-ID<XaKBr.14619$hJ3.3099@newsfe14.iad>
In reply to#1778
On 6/12/12 7:09 AM, bob wrote:
> Are there any languages where you can actually use commas in the numbers?
>
> So, instead of having to write:
>
> int x = 5000000;
>
> You could write:
>
> int x = 5,000,000;
>
> I think this could improve clarity a lot.
>
> Is there really a good reason no one has done this?

I believe Java 7 has that capability, sort of.

Instead of "," you use "_", but the idea is the same, grouping digits

int x = 5_000_000;

equivalent to

int x = 5000000;

Honestly, I think this should be a function of the editor, and not the 
language itself, but I haven't seen an IDE that abstracts the 
programming language that extensively but remains useful.

[toc] | [prev] | [next] | [standalone]


#1787

FromBen Pfaff <blp@cs.stanford.edu>
Date2012-06-12 09:54 -0700
Message-ID<878vfsh3mp.fsf@blp.benpfaff.org>
In reply to#1786
Daniel Pitts <newsgroup.nospam@virtualinfinity.net> writes:

> I believe Java 7 has that capability, sort of.
>
> Instead of "," you use "_", but the idea is the same, grouping digits
>
> int x = 5_000_000;
>
> equivalent to
>
> int x = 5000000;
>
> Honestly, I think this should be a function of the editor, and not the
> language itself, but I haven't seen an IDE that abstracts the
> programming language that extensively but remains useful.

Emacs has "glasses" mode, described as:

    Glasses minor mode makes `unreadableIdentifiersLikeThis' readable by
    altering the way they display.  It knows two different ways to do this:
    by displaying underscores between a lower-case letter and the following
    capital letter, and by emboldening the capital letters.  It does not
    alter the buffer text, only the way they display, so you can use it
    even on read-only buffers.  You can use the command `M-x glasses-mode'
    to enable or disable the mode in the current buffer; you can also add
    `glasses-mode' to the mode hook of the programming language major modes
    in which you normally want to use Glasses mode.

I guess that it would be a minor modification to this mode to
make it also display underscores as part of numbers.

[toc] | [prev] | [next] | [standalone]


#1788

From"BartC" <bc@freeuk.com>
Date2012-06-12 18:05 +0100
Message-ID<jr7su5$b32$1@dont-email.me>
In reply to#1786
"Daniel Pitts" <newsgroup.nospam@virtualinfinity.net> wrote in message 
news:XaKBr.14619$hJ3.3099@newsfe14.iad...
> On 6/12/12 7:09 AM, bob wrote:
>> Are there any languages where you can actually use commas in the numbers?

> I believe Java 7 has that capability, sort of.
>
> Instead of "," you use "_", but the idea is the same, grouping digits
>
> int x = 5_000_000;
>
> equivalent to
>
> int x = 5000000;
>
> Honestly, I think this should be a function of the editor, and not the 
> language itself, but I haven't seen an IDE that abstracts the programming 
> language that extensively but remains useful.

You could argue that half the syntax in a language could be the 
responsibility of the editor.

For example, the language proper might only have hexadecimal constants, 
leaving it to the editor to display as decimal.

Obviously that would have all sorts of disadvantages (when posting code to a 
group such as this for example).

But why would it be such a big deal for language syntax to help out with 
this sort of stuff?

(And if anyone knows the answer to that, perhaps they can tell me why you 
can't, generally, have embedded spaces when entering a credit-card number 
on-line, so that it matches the way it is shown on the card and is far 
easier to check.)

-- 
Bartc 

[toc] | [prev] | [next] | [standalone]


#1791

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-06-12 11:51 -0700
Message-ID<4dMBr.6769$5r4.2739@newsfe18.iad>
In reply to#1788
On 6/12/12 10:05 AM, BartC wrote:
> "Daniel Pitts" <newsgroup.nospam@virtualinfinity.net> wrote in message
> news:XaKBr.14619$hJ3.3099@newsfe14.iad...
>> On 6/12/12 7:09 AM, bob wrote:
>>> Are there any languages where you can actually use commas in the
>>> numbers?
>
>> I believe Java 7 has that capability, sort of.
>>
>> Instead of "," you use "_", but the idea is the same, grouping digits
>>
>> int x = 5_000_000;
>>
>> equivalent to
>>
>> int x = 5000000;
>>
>> Honestly, I think this should be a function of the editor, and not the
>> language itself, but I haven't seen an IDE that abstracts the
>> programming language that extensively but remains useful.
>
> You could argue that half the syntax in a language could be the
> responsibility of the editor.
>
> For example, the language proper might only have hexadecimal constants,
> leaving it to the editor to display as decimal.
Kind of, however the decision of the base to use for a number might be 
better left to a human.  A bit-mask makes more sense to represent in 
Hex, Binary, or Octal, where a time-unit makes more sense in Decimal.
>
> Obviously that would have all sorts of disadvantages (when posting code
> to a group such as this for example).
Unless your newsreader was aware of the language, and was able to do the 
rendering appropriate. Although that really is a potential disadvantage 
to "not-entirely-text" files.
>
> But why would it be such a big deal for language syntax to help out with
> this sort of stuff?
Not a big deal, but you can get more out of a smart editor than a 
complex language.  The editor can express things that aren't textual at 
all. For instance, good HTML editors will show colors as swatches next 
to the definition of that color.
>
> (And if anyone knows the answer to that, perhaps they can tell me why
> you can't, generally, have embedded spaces when entering a credit-card
> number on-line, so that it matches the way it is shown on the card and
> is far easier to check.)

It's somewhat off-topic, but indeed the server should be smart enough to 
pre-process the input to remove spaces.  The JavaScript which does 
whatever kind of pre-validation (length of string?) can be made to 
support spaces. The problem is supporting non-JS enabled browsers 
gracefully. You can specify a maximum length, but that is different 
between "spaced" numbers and "unspaced".

My real point was that code editors can go beyond simple textual 
rendering (and some are starting too), and allow coding "style" to be 
customized by the reader, not by the writer.  Code folding is one 
example which is becoming common. I'm imagining a future editor where 
aspects are folded inline, from the join-points, and join-points are 
visible from the advice, etc... I think there could be novel ways of 
visualizing classes, interfaces, and their interactions, *without* 
interfering with the ability to manipulate them. Perhaps an improved way 
to manipulate the system (think refactoring) that is visualized in a 
easily consumable way.

IDE's are headed in this direction, and I'm excited to see it happen. 
The difficulty is balancing text-representable language and the other 
features, especially if the text is ill-formed. Some textual constructs 
are easier (for computers) recognize when they become corrupt than 
others. This could be solved by ignore textual representation, and 
having all the structure of a program be stored in an object model that 
can only be manipulated in "syntactically correct" manors.  Though doing 
that could make creation more difficult, if not done correctly.

Anyway, I've rambled on enough, and perhaps incoherently.  Just a 
fraction of my brain-dump on the subject.

Sincerely,
Daniel.

[toc] | [prev] | [next] | [standalone]


#1792

From"BartC" <bc@freeuk.com>
Date2012-06-12 20:36 +0100
Message-ID<jr85s3$8h9$1@dont-email.me>
In reply to#1791
"Daniel Pitts" <newsgroup.nospam@virtualinfinity.net> wrote in message 
news:4dMBr.6769$5r4.2739@newsfe18.iad...

> IDE's are headed in this direction, and I'm excited to see it happen. The 
> difficulty is balancing text-representable language and the other 
> features, especially if the text is ill-formed. Some textual constructs 
> are easier (for computers) recognize when they become corrupt than others. 
> This could be solved by ignore textual representation, and having all the 
> structure of a program be stored in an object model that can only be 
> manipulated in "syntactically correct" manors.  Though doing that could 
> make creation more difficult, if not done correctly.

I've thought about stuff like that too (from the point of view of language 
design).

You could almost get rid of ordinary syntax; either it would look something 
like Lisp, or be in some complicated machine-readable format as you suggest. 
In fact modules can also disappear, you're just left with a tree-structure 
of variables, functions and types; just a database really.

But since I'm still using 1980s-style console-based IDEs and text editors, I 
designed not to take that route yet..

-- 
Bartc

 

[toc] | [prev] | [next] | [standalone]


#1793

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2012-06-12 16:28 -0700
Message-ID<RgQBr.6771$qf3.775@newsfe12.iad>
In reply to#1792
On 6/12/12 12:36 PM, BartC wrote:
> "Daniel Pitts" <newsgroup.nospam@virtualinfinity.net> wrote in message
> news:4dMBr.6769$5r4.2739@newsfe18.iad...
>
>> IDE's are headed in this direction, and I'm excited to see it happen.
>> The difficulty is balancing text-representable language and the other
>> features, especially if the text is ill-formed. Some textual
>> constructs are easier (for computers) recognize when they become
>> corrupt than others. This could be solved by ignore textual
>> representation, and having all the structure of a program be stored in
>> an object model that can only be manipulated in "syntactically
>> correct" manors. Though doing that could make creation more difficult,
>> if not done correctly.
>
> I've thought about stuff like that too (from the point of view of
> language design).
>
> You could almost get rid of ordinary syntax; either it would look
> something like Lisp, or be in some complicated machine-readable format
> as you suggest. In fact modules can also disappear, you're just left
> with a tree-structure of variables, functions and types; just a database
> really.
Very much what I've thought about. Syntax disappears from the 
programmers concerns and is replaced with pure conceptualization.
>
> But since I'm still using 1980s-style console-based IDEs and text
> editors, I designed not to take that route yet..
There are a lot of obstacles to such a system, not least of which is the 
wide-spread use and utility of text-editors.

[toc] | [prev] | [next] | [standalone]


#1809

FromThad Smith <ThadSmith@acm.org>
Date2012-06-17 22:38 -0600
Message-ID<4fdeb0e5$0$17207$892e0abb@auth.newsreader.octanews.com>
In reply to#1778
On 6/12/2012 8:09 AM, bob wrote:
> Are there any languages where you can actually use commas in the numbers?
>
> So, instead of having to write:
>
> int x = 5000000;
>
> You could write:
>
> int x = 5,000,000;
>
> I think this could improve clarity a lot.

I haven't used Fortran in decades, but my recollection is it allowed arbitrary 
spaces to be embedded in source.  If that is still the case, you could write
        x = 5 000 000

-- 
Thad

[toc] | [prev] | [next] | [standalone]


#1810

FromRobert Wessel <robertwessel2@yahoo.com>
Date2012-06-18 00:02 -0500
Message-ID<97dtt756jsdcgrjiufo8jlpb9e51djufdv@4ax.com>
In reply to#1809
On Sun, 17 Jun 2012 22:38:47 -0600, Thad Smith <ThadSmith@acm.org>
wrote:

>On 6/12/2012 8:09 AM, bob wrote:
>> Are there any languages where you can actually use commas in the numbers?
>>
>> So, instead of having to write:
>>
>> int x = 5000000;
>>
>> You could write:
>>
>> int x = 5,000,000;
>>
>> I think this could improve clarity a lot.
>
>I haven't used Fortran in decades, but my recollection is it allowed arbitrary 
>spaces to be embedded in source.  If that is still the case, you could write
>        x = 5 000 000


Indeed, mistyping:

  DO 100 I = 1, 10

with a period instead of a comma, would result in:

  DO100I = 1.10

Which, of course, doesn't loop as intended, implicitly declares a
variable called DO100I and assigns a value to it, and would typically
not produce any sort of diagnostic.  And when you're debugging a paper
listing, printed on low quality paper with a cheap, almost worn out,
ribbon, that was not easy to spot.

[toc] | [prev] | [next] | [standalone]


#1909

Fromblmblm@myrealbox.com <blmblm.myrealbox@gmail.com>
Date2012-07-06 19:01 +0000
Message-ID<a5or09Ff9dU1@mid.individual.net>
In reply to#1810
In article <97dtt756jsdcgrjiufo8jlpb9e51djufdv@4ax.com>,
Robert Wessel  <robertwessel2@yahoo.com> wrote:
> On Sun, 17 Jun 2012 22:38:47 -0600, Thad Smith <ThadSmith@acm.org>
> wrote:
> 
> >On 6/12/2012 8:09 AM, bob wrote:
> >> Are there any languages where you can actually use commas in the numbers?
> >>
> >> So, instead of having to write:
> >>
> >> int x = 5000000;
> >>
> >> You could write:
> >>
> >> int x = 5,000,000;
> >>
> >> I think this could improve clarity a lot.
> >
> >I haven't used Fortran in decades, but my recollection is it allowed arbitrary 
> >spaces to be embedded in source.  If that is still the case, you could write
> >        x = 5 000 000

Quite belatedly, for the record maybe ....

That was true of old-style FORTRAN (standards up through FORTRAN 77).
Fortran 90 [*] introduced an alternate source format ("free form", as
opposed to the older "fixed form") with a lot fewer restrictions on
column alignment and so forth, and in this new format spaces *are*
significant.  In the new format the mistake described below wouldn't
be possible -- though neither would the above trick for making
numeric constants more readable.  The compilers I've used support
both formats, with the choice determined by either the filename
extension or a compiler switch.  (Backward compability, you know.)

Fortran these days -- if one can judge by comp.lang.fortran, it
continues to evolve and to have an active and enthusiastic user base,
but it's something of a niche language.

[*] Yeah, they also decided to drop the all-caps spelling.

> 
> Indeed, mistyping:
> 
>   DO 100 I = 1, 10
> 
> with a period instead of a comma, would result in:
> 
>   DO100I = 1.10
> 
> Which, of course, doesn't loop as intended, implicitly declares a
> variable called DO100I and assigns a value to it, and would typically
> not produce any sort of diagnostic.  And when you're debugging a paper
> listing, printed on low quality paper with a cheap, almost worn out,
> ribbon, that was not easy to spot.
> 

-- 
B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.

[toc] | [prev] | [next] | [standalone]


#2019

FromJongware <jongware@no-spam.plz>
Date2012-07-30 15:53 +0200
Message-ID<501691e6$0$6876$e4fe514c@news2.news.xs4all.nl>
In reply to#1778
On 12-Jun-12 16:09 PM, bob wrote:
> Are there any languages where you can actually use commas in the numbers?
>
> So, instead of having to write:
>
> int x = 5000000;
>
> You could write:
>
> int x = 5,000,000;
>
> I think this could improve clarity a lot.
>
> Is there really a good reason no one has done this?

Is

x = 5,00,000;

a syntax error? Is

x = 5,,000;

a syntax error? Is

x = 5,000.000,001;

a syntax error?

Anyway, *a* reason programming languages do not support this might be 
it's quite unusual to have such large constants hardcoded. For any 
really large numbers, one is more inclined to write

0x80000001

than

-2,147,483,647.

[Jw]

(I mis-counted the zeros in that hex constant! Perhaps it /would/ be 
nice to be able to write "8000:0001h" instead and let the computer sort 
it out.)

[toc] | [prev] | [next] | [standalone]


#2020

From"BartC" <bc@freeuk.com>
Date2012-07-30 15:50 +0100
Message-ID<jv6717$33i$1@dont-email.me>
In reply to#2019
"Jongware" <jongware@no-spam.plz> wrote in message 
news:501691e6$0$6876$e4fe514c@news2.news.xs4all.nl...
> On 12-Jun-12 16:09 PM, bob wrote:
>> Are there any languages where you can actually use commas in the numbers?

> Is
>
> x = 5,00,000;
>
> a syntax error? Is
>
> x = 5,,000;
>
> a syntax error? Is
>
> x = 5,000.000,001;
>
> a syntax error?

If commas are allowed, then these can be warnings. That means you might end 
up getting the 5 million that was probably intended rather than 500,000.

> Anyway, *a* reason programming languages do not support this might be it's 
> quite unusual to have such large constants hardcoded. For any really large 
> numbers, one is more inclined to write
>
> 0x80000001
>
> than
>
> -2,147,483,647.

Sure, and one would write 0xF4240H instead of 1000000!

Even in your hex example, it's very easy to miss out one of those zeros.

-- 
Bartc 

[toc] | [prev] | [next] | [standalone]


#2026

From"BartC" <bc@freeuk.com>
Date2012-08-01 01:56 +0100
Message-ID<jv9utl$sdp$1@dont-email.me>
In reply to#2020
"Stefan Ram" <ram@zedat.fu-berlin.de> wrote in message 
news:numerals-20120731140512@ram.dialup.fu-berlin.de...
> "BartC" <bc@freeuk.com> writes:
>>>0x80000001
>>Sure, and one would write 0xF4240H instead of 1000000!

> ... One can also write
>
> 123_456
>
>  (in Java, meaning the same as »123456«). In C, possibly
>
> CONCAT2(123,456)
>
>  with an appropriatly defined macro »CONCAT2«.

Yes, I know, C's macro processor can do almost anything. (I've sometimes 
wondered what that language would look like if you took out everything that 
could instead be implemented, now matter how awkwardly, with a macro.)

But, having to extend the language yourself doesn't count! Anyway having to 
write CONCAT2(123,456) is only marginally more useful than just writing 
123*1000+456, which at least is universal.

-- 
Bartc 

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.programming


csiph-web