From: "Jon Harrop" <jon@ffconsultancy.com>
To: "'Jonathan Kimmitt'" <jonathan@kimmitt.co.uk>, <caml-list@inria.fr>
Subject: RE: [Caml-list] How much optimized is the 'a option type ?
Date: Sat, 18 Jan 2014 01:18:20 -0000 [thread overview]
Message-ID: <02d801cf13eb$2d53e970$87fbbc50$@ffconsultancy.com> (raw)
In-Reply-To: <sympa.1389956970.13214.762@inria.fr>
Jonathan Kimmitt wrote:
> If you compare this behaviour with the inferior clone F# written by
Microsoft,
> you can see that one of the things they added to the language was a nil
> pointer, thus abandoning all type safety immediately and all because they
> did not want to change their .NET runtime system for C# etc.
F# has a very good FFI to C#. In particular, it is memory safe. F# has null
because it is required for interop with C#. Idiomatic F# code does not use
null. Compare with OCaml's memory-unsafe FFI to C...
> They also have the notion of initialising a typed object to in an invalid
default,
> which is another obvious disaster area.
When you dequeue an element from a mutable queue that is represented
internally as an over-sized array you need to null-out the removed element
or you leak everything reachable from that value that would otherwise be
unreachable. F# uses Unchecked.defaultof<_> to create a default value of any
type (even a value type). The Queue module in the OCaml stdlib uses
"Obj.magic None" which works because OCaml doesn't have value types.
> Oh and did I mention operators like +/- etc are overloaded so you cannot
> infer function types without adding type annotations.
In F# the same arithmetic operators work transparently on the byte, sbyte,
uint16, int16, uint32, int32, uint64, int64, float, float32, BigInteger and
BigRational types as well as decimal, DateTime, vectors, matrices and
user-defined types. OCaml has + for int, +. for float and +/ for big
rationals and no other numeric types. Imagine what would happen if OCaml
supported just the full complement of numeric types, let alone the others?
You'd need 15 different operators just to support the numeric types I
listed...
> The final insult is to make indentation significant in the syntax so that
if
> you post a program to a list which does not respect whitespace (for
> example using a well-known Microsoft mail client), it completely destroys
> the meaning of the program.
I agree. :-)
Cheers,
Jon.
-----Original Message-----
From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On
Behalf Of Jonathan Kimmitt
Sent: 17 January 2014 11:24
To: caml-list@inria.fr
Subject: Re: [Caml-list] How much optimized is the 'a option type ?
In my humble opinion the main purpose of Some _ | None is to avoid the
requirement for a nil pointer in OCaml. If an external function wants to
return nil in order to indicate, for example that a certain resource is not
available, it can return None instead and this prevents dereferencing a nil
pointer in OCaml because the None cannot be dereferenced. If you compare
this behaviour with the inferior clone F# written by Microsoft, you can see
that one of the things they added to the language was a nil pointer, thus
abandoning all type safety immediately and all because they did not want to
change their .NET runtime system for C# etc. They also have the notion of
initialising a typed object to in an invalid default, which is another
obvious disaster area. Oh and did I mention operators like +/- etc are
overloaded so you cannot infer function types without adding type
annotations.
The final insult is to make indentation significant in the syntax so that if
you post a program to a list which does not respect whitespace (for example
using a well-known Microsoft mail client), it completely destroys the
meaning of the program.
I'm sure the authors of F# have their reasons for making all these changes,
and I'm not one to stand in the way of progress, and I don't set out to
offend anybody, but I think they got it wrong ...
--
Caml-list mailing list. Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
next prev parent reply other threads:[~2014-01-18 1:18 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 7:35 Damien Guichard
2014-01-17 7:55 ` David House
2014-01-17 8:16 ` Julien Blond
2014-01-17 8:40 ` David House
2014-01-17 9:10 ` Gabriel Scherer
2014-01-17 9:22 ` Simon Cruanes
2014-01-17 17:57 ` Gerd Stolpmann
2014-01-18 1:35 ` Jon Harrop
2014-01-19 6:19 ` oleg
2014-01-21 1:51 ` Francois Berenger
2014-01-18 1:01 ` Jon Harrop
2014-01-24 10:06 ` Alain Frisch
2014-01-24 10:16 ` Alain Frisch
2014-01-24 13:32 ` Yaron Minsky
[not found] ` <CAK=fH+jfi=GsMYBZzmuo=V5UAWimyxiiamY2+DkLg6F0i8XHGw@mail.gmail.com>
2014-01-17 9:11 ` David House
2014-01-17 11:23 ` Jonathan Kimmitt
2014-01-17 13:46 ` Nicolas Braud-Santoni
2014-01-17 13:56 ` Frédéric Bour
2014-01-17 14:02 ` Yaron Minsky
2014-01-17 14:09 ` Simon Cruanes
2014-01-17 22:52 ` Yaron Minsky
2014-01-18 1:37 ` Jon Harrop
2014-01-17 14:24 ` Gabriel Scherer
2014-01-17 22:29 ` Yaron Minsky
2014-01-18 1:27 ` Jon Harrop
2014-01-18 1:18 ` Jon Harrop [this message]
2014-01-20 10:16 ` Goswin von Brederlow
2014-01-20 11:23 ` Jonathan Kimmitt
2014-01-21 2:05 ` Francois Berenger
2014-01-22 21:22 ` Jon Harrop
2014-01-22 21:26 ` Jon Harrop
2014-01-23 9:29 ` Goswin von Brederlow
2014-01-23 23:20 ` Jon Harrop
2014-01-23 23:28 ` Yotam Barnoy
2014-01-24 8:22 ` Jon Harrop
2014-01-24 8:34 ` Andreas Rossberg
2014-01-24 16:56 ` Jon Harrop
2014-01-27 15:29 ` Goswin von Brederlow
2014-01-27 16:18 ` Yotam Barnoy
2014-01-29 7:56 ` Goswin von Brederlow
2014-01-29 8:32 ` Jon Harrop
2014-01-29 16:11 ` Yotam Barnoy
2014-01-30 18:43 ` Yotam Barnoy
2014-02-01 15:58 ` Goswin von Brederlow
2014-01-30 21:31 ` Jon Harrop
2014-01-30 21:43 ` Yotam Barnoy
2014-01-31 8:26 ` Jon Harrop
2014-02-01 15:40 ` Goswin von Brederlow
2014-01-27 10:03 ` Goswin von Brederlow
2014-01-17 14:36 ` Markus Mottl
2014-01-17 15:49 ` Yotam Barnoy
2014-01-17 16:22 ` Markus Mottl
2014-01-20 10:09 ` Goswin von Brederlow
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='02d801cf13eb$2d53e970$87fbbc50$@ffconsultancy.com' \
--to=jon@ffconsultancy.com \
--cc=caml-list@inria.fr \
--cc=jonathan@kimmitt.co.uk \
/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