caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anton Moscal <msk@tepkom.ru>
To: Caml list <caml-list@pauillac.inria.fr>
Subject: Re: convincing management to switch to Ocaml (fwd)
Date: Thu, 2 Sep 1999 16:38:21 +0400 (MSD)	[thread overview]
Message-ID: <Pine.LNX.4.03.9909021637540.17094-100000@post.tepkom.ru> (raw)

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




                 reply	other threads:[~1999-09-02 18:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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.03.9909021637540.17094-100000@post.tepkom.ru \
    --to=msk@tepkom.ru \
    --cc=caml-list@pauillac.inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).