[Gllug] Web Site Creation

Richard Jones rich at annexia.org
Tue Nov 8 12:47:48 UTC 2005


On Tue, Nov 08, 2005 at 12:06:36PM +0100, Dani Pardo wrote:
>  Functors? What's that? I'm starting to feel like 'been living under a 
> rock all this time :?

I keep meaning to write a tutorial on functors and put it up on
http://www.ocaml-tutorial.org/ becuse there really aren't any good
ones on the web.

In brief, a functor allows you to compose two or more modules together
to make a larger one.  So for example you could compose a "model" and
a "view" module to make a model-view module (and later compose a
controller, to make a model-view-controller module, etc.)

The clever bit -- which is the bit which the tutorial will get around
to explaining -- is that you can use modules from the standard library
instead of having to write, say, a specific model module for your
application.  So a load of essentially glue stuff (the "model") which
you'd have to write in [insert OO language] just disappears in OCaml.

BTW, the Wikipedia definition of "functor" is nothing to do with the
above.  In classic style, it explains the stupid C++ "function object"
hack which is a poor workaround for C++ not supporting functions as
first class objects (Perl, Python and Ruby all have closures /
first-class functions, Java doesn't, latest C# will support a
half-baked notion).

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Team Notepad - intranets and extranets for business - http://team-notepad.com
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list