caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Fwd: Re: [Caml-list] writing some code using a function for which only the signature is known]
@ 2011-01-21  8:25 Francois Berenger
  0 siblings, 0 replies; only message in thread
From: Francois Berenger @ 2011-01-21  8:25 UTC (permalink / raw)
  To: caml-list

-------- Original Message --------
Subject: Re: [Caml-list] writing some code using a function for which 
only the signature is known
Date: Fri, 21 Jan 2011 08:05:57 +0200
From: dmitry grebeniuk
To: Francois Berenger

Hello.

> If I am writing some code, and I don't want to dive
> into implementing some sub function I will need but don't
> have yet, what is the standard way to do this in ocaml?

   I don't know any standart way, but I'm using "raise Exit"
for this purpose.

   Or you can use exception that carry function's name,
like this:

exception Not_implemented of string
let notimpl funcname = raise (Not_implemented funcname)
let myfunc = notimpl "myfunc"

   And there are some cases when you need to specify
the type of function (either "you need", or "it
will ease your life substantially"), even if the function
is not implemented.

   Moreover, it's better to describe arguments of such function
(to document the code, to add type constraints, to ease
implementation of the function later (either full or partial)):

let  process_them  _len  _contents  _on_finish  =  raise Exit

   Notice the first underscores in arguments' names: they
are here to suppress warnings about unused bindings
(really, these bindings are unused in this function).

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-01-21  8:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21  8:25 [Fwd: Re: [Caml-list] writing some code using a function for which only the signature is known] Francois Berenger

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).