[go: up one dir, main page]

|
|
Log in / Subscribe / Register

Little things that matter in language design

Little things that matter in language design

Posted Jun 8, 2013 2:58 UTC (Sat) by neilbrown (subscriber, #359)
In reply to: Little things that matter in language design by nlucas
Parent article: Little things that matter in language design

Not impossible. We could use Rust's attributes:

[#decimal_comma];

or maybe

#pragma decimal_commas

I don't think I would recommend that though.

Interesting problem - thanks for mentioning it.


to post comments

Little things that matter in language design

Posted Jun 8, 2013 16:46 UTC (Sat) by nlucas (subscriber, #33793) [Link] (1 responses)

The problem is if we implement locale based decimals then there could be cases where at first glance there are no differences.

For example, suppose we have a simple file with constants:

const double CONST1 = 123,456;
const double CONST2 = 123.456;

If someone deletes the meta-data indicating the locale, how do you parse it? There is no way to know what the original values were if you don't know the original locale.

You could fix this by making the thousand separator an invalid character (by only allowing '_' or space as the thousand separator), but with so many locales out there could this really be fixed on a global scale?

Localization is hard, and should never be taken lightly. For example, my country uses ',' as decimal separator, but the keyboard "numpad" has '.', not ','. So it's usual for applications to accept both on input as decimal separators. No standard libraries I know of support this case, which means most applications have to implement (or filter) it's input functions instead of relying on the standard libraries.

Little things that matter in language design

Posted Jun 9, 2013 16:32 UTC (Sun) by alankila (guest, #47141) [Link]

I recently hid myself in a dark cave fearing wrath of god after I implemented a heuristic number parser for an application I wrote for customer just so that it would recognize and support various forms of writing money: 1.234,45; 1 234.45; 1 234,45 etc. In general I make the guess that the last dot/comma I see is the decimal separator and all other characters that are not numbers are ignored.

I wrote a very similar horror for date parsing, trying to support yyyy-mm-dd, dd.mm.yyyy and dd/mm/yy OR mm/dd/yy based on whether user is expected to reside in UK or US.

I hate people and their myriad conventions.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds