Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Mattias Engdegård" <mattias@virtutech.se>
To: jon@ffconsultancy.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE
Date: Fri, 8 Dec 2006 19:20:21 +0100	[thread overview]
Message-ID: <200612081820.kB8IKL023123@virtutech.se> (raw)
In-Reply-To: <200612081748.03288.jon@ffconsultancy.com> (message from Jon Harrop on Fri, 8 Dec 2006 17:48:03 +0000)

>I wouldn't call it a bug. It looks like modulo arithmetic to me.

Let's not make a virtue of necessity. The type "int" was likely designed
with the intent to provide a type that could be used for actual integers
in a variety of circumstances, while giving good performance. The modulo
semantics is rarely useful (especially the 30-bit signed variety) but
is the price paid for reasonable performance with a simple implementation.

>> I would love to have a fast unboxed integer type that automatically
>> overflows to bignum, but it would be a tad slower than the current "int".
>
>How can it be both unboxed and allow overflow to a bignum? Would you generate 
>int and bigint versions of all functions and then bail to the bigint version 
>if anything overflowed?

This is just what Lisp implementations have done for decades.

Yes, it means that code must be prepared to handle either version
(unless the compiler can prove that this is not necessary).
Generating two versions of all functions is neither necessary nor sufficient.


  reply	other threads:[~2006-12-08 18:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-07 18:32 Pal-Kristian Engstad
2006-12-07 19:19 ` [Caml-list] " Jonathan Roewen
2006-12-07 19:43   ` Mattias Engdegård
2006-12-07 20:02     ` Brian Hurt
2006-12-08  2:37     ` skaller
2006-12-08 11:09       ` Mattias Engdegård
2006-12-08 17:48     ` Jon Harrop
2006-12-08 18:20       ` Mattias Engdegård [this message]
2006-12-08 18:37         ` Brian Hurt
2006-12-09  2:03           ` skaller
2006-12-07 21:13 ` Martin Jambon

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=200612081820.kB8IKL023123@virtutech.se \
    --to=mattias@virtutech.se \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.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