From: Brian Hurt <bhurt@spnz.org>
To: John Hughes <jfh@cs.brown.edu>
Cc: "'caml-list'" <caml-list@inria.fr>
Subject: RE: [Caml-list] Why must types be always defined at the top level?
Date: Thu, 24 Jun 2004 18:08:27 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0406241742560.4202-100000@localhost.localdomain> (raw)
In-Reply-To: <20040624142732.9767110EF06@clark.cs.brown.edu>
On Thu, 24 Jun 2004, John Hughes wrote:
>
> 2. Why no "end" on "let" expressions, i.e.,
>
> let a = 3 and b = 2 in a + b;;
>
> rather than
>
> let a = 3 and b = 2 in a + b end; ?
Let doesn't need them- there are a lot of other places where Ocaml could
use disambiguation. Basically, I'm a beleiver that if there is a
shift-reduce conflict in the obvious implementation of the grammar, there
is a problem the programmer is going to trip over.
One big one- I wish if was ended with an endif or similiar. How many
times have you accidentally coded something like:
if x > 3 then
printf "x = %d\n" x;
x - 3
else
x + 1
This is especially common when, like in my example, you're dropping in
debug print statements. Unfortunately, the semicolon at the end of the
printf statement also ends the if statement.
>
> 3. Why semicolons for separating list items, so that
>
> [2,3] is interpreted as [(2,3)] ?
How would I make a list of one element of type int * int?
>
> 4. Why expose the hardware with float (and make it have equality
> testing) rather than continue with "real" (which was not an eqtype, if
> I recally correctly)?
sqrt(2.);;
Mathematicians don't have a problem with dealing with an infinite number
of decimal places. Computers do. You can hide some of the problems- at
great cost in terms of performance and memory- but sooner or later you're
going to deal with precision loss.
$ ocaml
Objective Caml version 3.07
# 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1 +. 0.1;;
- : float = 0.999999999999999889
Plus, all the comments I made about integers apply, and then some.
Hardware based floating point is much faster than any software based
floating point (even ignoring the infinities and nan problems). Going to
software base FP is easily 10x slower than hardware, possible (probably)
more. And doesn't really save you much of anything.
This is just pointing up, to me, why there is a difference between a
teaching language and a production language. As something looking at
using Ocaml as a production language, I am opposed to even adding overflow
detection on ints- in the few, minor places I need it, I'll either use
larger integers, or I'll add in explicit checks myself. But don't slow
down even a little the vast majority of my integer operations. This goes
at least double for my floating point operations.
For a teaching language, I'd definately include integer overflow detection
at the least, and would seriously consider making integers arbitrary
precision. I'd also strongly consider making floats software, but not so
that I could increase precision, but so that I could decrease precision-
numerical instability is a lot easier to demonstrate if you only have four
digits of precision, and not 15. But, then again, performance isn't a
concern with a production language.
--
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
- Gene Spafford
Brian
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2004-06-24 23:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-22 22:41 Richard Jones
2004-06-22 22:53 ` Markus Mottl
2004-06-22 23:32 ` skaller
2004-06-23 12:01 ` Andreas Rossberg
2004-06-23 14:45 ` skaller
2004-06-23 16:28 ` Andreas Rossberg
2004-06-23 20:21 ` skaller
2004-06-23 20:52 ` skaller
2004-06-24 14:27 ` John Hughes
2004-06-24 16:47 ` Andreas Rossberg
2004-06-24 17:30 ` Markus Mottl
2004-06-24 17:45 ` Xavier Leroy
2004-06-24 19:46 ` John Hughes
2004-06-24 19:56 ` David Brown
2004-06-24 19:57 ` William D. Neumann
2004-06-24 20:13 ` Olivier Andrieu
2004-06-24 23:26 ` Brian Hurt
2004-06-25 10:20 ` skaller
2004-06-25 11:07 ` Basile Starynkevitch [local]
2004-06-25 12:30 ` skaller
2004-06-25 14:38 ` [Caml-list] Thread and kernel 2.6 pb still there in CVS Christophe Raffalli
2004-06-25 16:08 ` [Caml-list] " Marco Maggesi
2004-06-25 16:32 ` Markus Mottl
2004-06-28 15:08 ` [Caml-list] " Xavier Leroy
2004-06-28 18:50 ` Benjamin Geer
2004-06-29 2:26 ` Christophe Raffalli
[not found] ` <7AFB5F64-C944-11D8-975C-00039310CAE8@inria.fr>
[not found] ` <40E11621.3050709@univ-savoie.fr>
2004-07-05 15:14 ` Christophe Raffalli
2004-07-05 16:34 ` Xavier Leroy
2004-07-06 9:33 ` Alex Baretta
2004-07-08 13:51 ` Christophe Raffalli
2004-07-08 15:03 ` Xavier Leroy
2004-07-09 23:21 ` Donald Wakefield
2004-07-10 10:56 ` Damien Doligez
2004-06-24 23:23 ` [Caml-list] Why must types be always defined at the top level? Brian Hurt
[not found] ` <Pine.LNX.4.44.0406241813370.4202-100000@localhost.localdom ain>
2004-06-26 23:08 ` Dave Berry
2004-06-25 1:59 ` Yaron Minsky
2004-06-24 23:08 ` Brian Hurt [this message]
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=Pine.LNX.4.44.0406241742560.4202-100000@localhost.localdomain \
--to=bhurt@spnz.org \
--cc=caml-list@inria.fr \
--cc=jfh@cs.brown.edu \
/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