caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oliver <oliver@first.in-berlin.de>
To: David House <dhouse@janestreet.com>
Cc: "Gabriel Scherer" <gabriel.scherer@gmail.com>,
	"Matej Košík" <5764c029b688c1c0d24a2e97cd764f@gmail.com>,
	caml-list@inria.fr
Subject: Re: [Caml-list] syntactic detail
Date: Wed, 8 Feb 2012 14:39:26 +0100	[thread overview]
Message-ID: <20120208133926.GC1823@siouxsie> (raw)
In-Reply-To: <4F32741C.4040501@janestreet.com>

On Wed, Feb 08, 2012 at 01:09:48PM +0000, David House wrote:
> On 02/08/2012 12:54 PM, Gabriel Scherer wrote:
> >There is no purpose, it's just an edge case of the simple lexical
> >specification you can find at:
> >http://caml.inria.fr/pub/docs/manual-ocaml/lex.html#float-literal
> >
> >Everywhere digits are allowed, you can insert extraneous underscores.
> >There is no restriction that there must be at least one digit for
> >underscores to be valid. I don't see why there should be.
> 
> I would actually prefer a slightly more constrained format. It is
> very easy to typo large numbers like:
> 
>   let ten_million = 10_000_0000 in
> 
> When eyeballing this, it is extremely easy to mistake this as 10^7,
> when it actual fact it is 10^8.
[...]

I think the problem of being confounding 10_000_0000 with 100_000_000
or 10_000_0000 with 10_000_000 is less prominent then confounding
100000000 with 10000000.

So this syntax rule already makes things much easier to read.
That's it's advantage.

To have here all three characters as syntax rule could make sense,
but is less a problem than having no allowance of "_" in numbers at all.


For rare cases it might also make sense to have "_" inserted arbitrarily,
for example in math education or when clarifiying things to others,
it might also make sense to put "_" around the differing values.
So it migth make sense for clarifiying differences and for educational
purposes.

For example you might have a startvalue of an algorithm and the staring value
for a certin behaviour is
  3.36639926549992
but your colleague uses
  3.36639296549992

For clarification one could write:
  3.36639926549992 vs.
  3.36639296549992

or better

  3.36639_92_6549992 vs.
  3.36639_29_6549992

A case, where two digits were switched.


Might not be the case that pops up all to often,
but if so, it might be fine, if both values can be used:

  let startval_correct = 3.36639_92_6549992 
  let startval_wrong   = 3.36639_29_6549992


So I have invented reasons why it's fine as it is.
Why should this case be forbidden?


> 
> I would prefer a syntax rule that only allows underscore every three
> characters (starting at the RHS of the number, i.e. complying to the
> usual convention). Well, certainly that for decimal literals. For
> hex literals you probably want to enforce the same, but every four
> characters.
[...]

For Hex it might also make sense to have it all two characters.

If the rule would be only all 4 characters, that would be bad.

Ciao,
   Oliver

  reply	other threads:[~2012-02-08 13:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 12:46 Matej Košík
2012-02-08 12:54 ` Gabriel Scherer
2012-02-08 13:09   ` David House
2012-02-08 13:39     ` oliver [this message]
2012-02-08 13:45       ` oliver
2012-02-08 13:46       ` David House
2012-02-08 13:58         ` oliver
2012-02-08 14:12           ` David House
2012-02-08 14:39             ` Gabriel Scherer
2012-02-08 14:50               ` David House
2012-02-08 15:19                 ` Vincent Aravantinos
2012-02-10  8:39                   ` Andrew
2012-02-08 16:30                 ` oliver
2012-02-10  3:37                   ` Jun Furuse
2012-02-08 16:21             ` oliver
2012-02-08 13:05 ` rixed
2012-02-09  9:05   ` Matej Košík
2012-02-09 10:56     ` Wojciech Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120208133926.GC1823@siouxsie \
    --to=oliver@first.in-berlin.de \
    --cc=5764c029b688c1c0d24a2e97cd764f@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dhouse@janestreet.com \
    --cc=gabriel.scherer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).