* Re: convincing management to switch to Ocaml (fwd)
@ 1999-09-02 12:38 Anton Moscal
0 siblings, 0 replies; only message in thread
From: Anton Moscal @ 1999-09-02 12:38 UTC (permalink / raw)
To: Caml list
On Fri, 27 Aug 1999, Andreas Rossberg wrote:
> > >For example, type safety,
> >
> > Wrong. C++ is type safe, provided you don't use casts.
>
> Wrong, due to pointer arithmetics. This can happen silently: e.g. the
> combination of arrays and subtyping as present in C++ is unsound, you
> can produce segmentation faults without using any casts or explicit
> pointer arithmetics or other features deemed unsafe. I think the basic
> example is even in one of Stroustrups books.
Another examples of C++ type unsafety:
union types
(...) function prototypes
!! hangling references (for example - to local variables)
scalar delete instead of array deletion (and inverse)
And about templates & polymorphism:
one month ago I try to translate into C++ the following very
useful FP idiom (opeartor for postfix application):
let (+>) x f = f x
printf "%g" (1.0 +> sin +> cos);;
I wrote:
template <class A, class B, class C>
C operator >> (B x, C (*f) (B)) { return (*f) (x); }
...
printf ("%g", 1.0 >> sin >> cos);
It doesn't compiles (due to C++ restriction: one of the parameters of the
user-defined operator must be a class). This is good illustration of the
problems with usage advanced C++ features. Actually I can't find
any reasonable application in C++ for this template.
Regards,
Anton Moscal
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-09-02 18:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-02 12:38 convincing management to switch to Ocaml (fwd) Anton Moscal
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).