<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/d0f044211e2146d5acbb23e7a5bfbd75"
  from="Andreas Rossberg &lt;rossberg@p...&gt;"
  author="Andreas Rossberg"
  date="2002-07-19T17:19:07"
  subject="Re: [Caml-list] productivity improvement"
  prev="2002/07/aa90e8987502a2062bb4131d5b0d2901"
  next="2002/07/ffda4354af9f91affee591b990f23ce1"
  prev-in-thread="2002/07/2ca0ce69b274daa5d62c6c200453fdc9"
  next-in-thread="2002/07/e526f6886b6068d87015ec9c87602b52"
  prev-thread="2002/07/c22d9fd21bcea5691f5678e925df1862"
  next-thread="2002/07/1555d185cf3a3a8758041c92a7f7d521"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/315f6c499a501e6f0b02d1bddacd4ee1"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-18T23:13:10"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/4675668fddffa94f558110a6a47fcea6"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2002-07-18T23:54:10"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/4890279c2ad66748afc7cb554cf02ebe"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-19T03:58:12"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/cdd23bf04bb19a6191ed787cbb39b10b"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-19T08:21:49"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/0a22394ba16e1be19dbc11a844233536"
  from="Andreas Rossberg &lt;rossberg@p...&gt;"
  author="Andreas Rossberg"
  date="2002-07-19T08:50:40"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/5830232e60808a2a2d12b2619015af15"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T10:06:47"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/c0f52395e551fc67daf00d3613dcd063"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-19T18:15:49"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/b61fd235edd5b365489366fade93ada5"
  from="Brian Smith &lt;brian-l-smith@u...&gt;"
  author="Brian Smith"
  date="2002-07-19T18:33:21"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/5cecdbd360abfdc5b5553e4a24e44dd3"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-20T17:30:44"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
<msg 
  url="2002/07/fcdb1d567d28038f0795dbedc8703612"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T18:59:30"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/1311d5475a156defb5e3448f20d85315"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-20T17:49:11"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/2ca0ce69b274daa5d62c6c200453fdc9"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-19T10:37:27"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/d0f044211e2146d5acbb23e7a5bfbd75"
  from="Andreas Rossberg &lt;rossberg@p...&gt;"
  author="Andreas Rossberg"
  date="2002-07-19T17:19:07"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/e526f6886b6068d87015ec9c87602b52"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-20T16:58:22"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/aa90e8987502a2062bb4131d5b0d2901"
  from="Brian Rogoff &lt;bpr@a...&gt;"
  author="Brian Rogoff"
  date="2002-07-19T16:35:12"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/9a655e0da7b32273cb71f8cc5fe7c8c6"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-17T08:32:49"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/4e7fd140d3b4edee8e9e2f6acc9fd1eb"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T01:18:46"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/fe3c7bd3d243f1f7b4c2eed75e44d456"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-19T04:03:10"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/61090af523bf875fc4ebc1a4a14c8ce7"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T15:39:39"
  subject="Re: [Caml-list] Rule based language [was: productivity improvement]">
<msg 
  url="2002/07/ffda4354af9f91affee591b990f23ce1"
  from="Julie Farago &lt;farago@e...&gt;"
  author="Julie Farago"
  date="2002-07-19T17:20:45"
  subject="[Caml-list] compact.c">
</msg>
</msg>
</msg>
<msg 
  url="2002/10/2673b6a958e12595d4f377eb23300fde"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-15T11:00:27"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/10506201acc84b3fca638f4cce55748f"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-10-15T12:34:11"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/227d76b8e3291647b70e216a84ed1050"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-15T17:11:16"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/4ea471c9b5dc5d496a40fb34a60d9f00"
  from="Emmanuel Renieris &lt;er@c...&gt;"
  author="Emmanuel Renieris"
  date="2002-07-19T04:42:09"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/bafcc930158b1e4ef9cf8990deef2a44"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-19T09:56:48"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/ac004f0bf1e2757debd128f2def8ef91"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T10:36:32"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/d268d6d85acf33a994f988ac968b22bc"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-19T10:52:32"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/07/2c53d122c8500845192452834a5d8d93"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-19T11:29:39"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/12e8fc3009383004d83e8e746bc02072"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-19T11:11:20"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/162c10804d9252dab346d1f6647961a3"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-15T11:00:20"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/32721a368455f27fc6b2ac163ff47e35"
  from="Pal-Kristian Engstad &lt;engstad@n...&gt;"
  author="Pal-Kristian Engstad"
  date="2002-10-15T18:47:16"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/3b927989eeb00f13d1a3a08adb0b5a6d"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-17T08:38:01"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/d0b38de16b1d88ea930f2525d7d74e4f"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-10-17T09:37:54"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/1e715e1544ec6426c6727ba80f862674"
  from="Jeffrey Palmer &lt;jeffrey.palmer@a...&gt;"
  author="Jeffrey Palmer"
  date="2002-10-17T15:55:10"
  subject="Re: [Caml-list] productivity improvement">
<msg 
  url="2002/10/71058b239015be081d7e541a46413fdb"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2002-10-17T16:15:12"
  subject="Re: [Caml-list] productivity improvement">
</msg>
<msg 
  url="2002/10/69ccda807609447f6e2af2b2ea80fffe"
  from="Christophe TROESTLER &lt;debian00@t...&gt;"
  author="Christophe TROESTLER"
  date="2002-10-17T18:18:35"
  subject="[Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
<msg 
  url="2002/10/b3805138b0c1ce941e882eacd4fc29f4"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-17T18:32:17"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
<msg 
  url="2002/10/66d9636fac47bb0d8d0c660b7a7c7248"
  from="Shivkumar Chandrasekaran &lt;shiv@e...&gt;"
  author="Shivkumar Chandrasekaran"
  date="2002-10-17T19:07:17"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
<msg 
  url="2002/10/d7aa0ce05030395f08a19034ab71f870"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-17T20:01:33"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
</msg>
</msg>
<msg 
  url="2002/10/806efec1e799f5e5422d49df924ab818"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-10-17T19:36:46"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
</msg>
<msg 
  url="2002/10/a4392f89c82205d6aa4773c0c0f70926"
  from="Brian Hurt &lt;brian.hurt@q...&gt;"
  author="Brian Hurt"
  date="2002-10-17T19:53:39"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity  improvement)">
<msg 
  url="2002/10/ddd8ec5b5184177f3e93a81c4b28d0a2"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-17T20:22:37"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity  improvement)">
<msg 
  url="2002/10/59fce5d6bf17d1c6e156ae7dd6ec2538"
  from="Brian Hurt &lt;brian.hurt@q...&gt;"
  author="Brian Hurt"
  date="2002-10-17T21:14:20"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/3eec5b83b44876bb4b82e66661e3b3fc"
  from="Jeffrey Palmer &lt;jeffrey.palmer@a...&gt;"
  author="Jeffrey Palmer"
  date="2002-10-17T21:37:32"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/6491c619e07668fd8cdd02bdbdae9256"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-10-17T23:45:08"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/c0bd2ffc4c8328c165b20226be4c5c76"
  from="Jeffrey Palmer &lt;jeffrey.palmer@a...&gt;"
  author="Jeffrey Palmer"
  date="2002-10-18T00:57:51"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/c266d8e7c314cdea2d0a086091f77b21"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-10-18T04:11:03"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/f1b9af8d9099b116f83eb5d9c6c6db10"
  from="Remi VANICAT &lt;vanicat@l...&gt;"
  author="Remi VANICAT"
  date="2002-10-18T08:23:29"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/a221071f0765da003963569e48fed7e2"
  from="Sven Luther &lt;luther@d...&gt;"
  author="Sven Luther"
  date="2002-10-18T08:46:51"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement)">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/10/2585e980ce3edfe7f38579edd7631029"
  from="Brian Hurt &lt;brian.hurt@q...&gt;"
  author="Brian Hurt"
  date="2002-10-18T01:41:36"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
</msg>
</msg>
<msg 
  url="2002/10/2e244c3c0a6a92d79ba5a6d70d723f4b"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-18T08:29:38"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity   improvement)">
<msg 
  url="2002/10/33dd1413d1a28faa17e2ee72c0a8ef0d"
  from="brogoff@s..."
  author="brogoff@s..."
  date="2002-10-18T23:55:57"
  subject="Re: [Caml-list] Re: Camlp4 optimizations (was: productivity    improvement)">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/10/7ce12a7a2b633b8a4d7b7762f30c116a"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-10-18T10:45:30"
  subject="Re: [Caml-list] productivity improvement">
</msg>
<msg 
  url="2002/10/dd0c7f80fedaa74938f2ed0a6aaa952e"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-10-21T08:57:04"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/cfac32c08aafecbb2414ee0832350833"
  from="Brian Smith &lt;blsmith@b...&gt;"
  author="Brian Smith"
  date="2002-07-20T14:28:01"
  subject="Re: [Caml-list] productivity improvement">
</msg>
</msg>
</thread>

<contents>
Oleg wrote:
&gt; 
&gt; &gt; And how would you do more complex case analysis, corresponding to nested
&gt; &gt; patterns?
&gt; 
&gt; I think I know what nested patterns are (something like
&gt; Node (x, y, Bla(1, _)) -&gt; ...), but I don't see where any extra difficulty
&gt; will come from while using virtual functions. Could you give specific
&gt; examples please?

Consider a simple expression language again. This time extended with
variables and function expressions:

  type 'a expr = Const of 'a | Var of string
               | Unop of 'a -&gt; 'a
               | Binop of 'a -&gt; 'a -&gt; 'a
               | Lambda of string * 'a expr
               | Apply of 'a expr * 'a expr

Evaluation has to rely on (one-step) reduction (sketch only):

 let rec reduce1 env = function
 | Var x -&gt; List.assoc x env
 | Apply (Lambda (x, e), v) -&gt; eval ((x,v)::env) e
 | Apply (Unop f,  Const x) -&gt; Const (f x)
 | Apply (Binop f, Const x) -&gt; Unop (f x)
 | Apply  _ -&gt; raise Error
 | e -&gt; e

Doing this with method dispatch requires serious amounts of object
spaghetti. I believe you are imaginative enough to see that this is
absolutely hopeless for realistic examples with a large number of more
complex cases - the number of additional helper methods polluting all
your classes will grow exponentially. (And note that even multiple
dispatch isn't expressive enough to avoid that.)

&gt; &gt; This is more than cumbersome and error-prone in C++ - with
&gt; &gt; RTTI, and even more so with method dispatch, where your single algorithm
&gt; &gt; will have to be scattered over tons of distant functions. A maintenance
&gt; &gt; nightmare.
&gt; 
&gt; Why would maintaining code organized by data type be harder? Isn't it what
&gt; encapsulation is all about?

No. That's one of the things OO ideology gets wrong. Making the type the
unit of encapsulation is much too inflexible. Often you want to
encapsulate several types simultanously, e.g. when you have functions
operating on a group of closely related types, which cannot sensibly be
implemented knowing only one of the types' internals. Thus
orthogonalising types and modules is a definite plus.

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
 as kids, we would all be running around in darkened rooms, munching
 magic pills, and listening to repetitive electronic music."
 - Kristian Wilson, Nintendo Inc.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

