Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Re: convincing management to switch to Ocaml (fwd)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-09-02 (18:46)
From: Anton Moscal <msk@t...>
Subject: Re: convincing management to switch to Ocaml (fwd)
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.

Anton Moscal