optimization of list comprehensions

Mats Cronqvist mats.cronqvist@REDACTED
Fri Mar 10 10:13:37 CET 2006



Richard A. O'Keefe wrote:
 > [...]
> The pattern illustrated for "fun", if it is to be taken seriously as a
> grep-style pattern, is guaranteed to miss many of the funs in the OTP
> sources.

   "many"? enough to affect the result significantly? example please.

> [...]
> > When it comes to version control systems, I'm a troglodyte.  I still use
> SCCS whenever I can.  One of the things SCCS has been able to do since I
> first used it about 25 years ago is tell you who wrote each line.  Surely
> any decent version control system can do this?

   we're using ClearCase. as far as i know (which admittedly isn't very far) 
there's no easy way to do that. and even if you could, it would only tell you 
the username of the person who checked in the file (which is often, but not 
always, the same as the person who *wrote* the code).

> 	   note also that most of this code sample has been used for
> 	years in a very challenging environment,
> 
> And this is surely the explanation.  Old code does not contain funs
> because old Erlang didn't *have* funs.  They are not described in the
> classic Erlang book.

   we have been using mnesia for as long as i can remember. when were real funs 
(and tuple-funs) introduced?

> [...]
> The language has changed.  What *was* 'perfectly fine' Erlang isn't any
> more.  It's perfectly fine in that it still works, but new code should
> not be written that way.

   well, i guess i'm a bit more flexible than you in that regard. i think it's 
ok for people to write C for C++ compilers, FORTRAN77 for Fortran90 compilers, 
etc, as long as the code works and is readable.
   of course it would be much *better* if they didn't.

> [...]
> To decide whether programmers are using the new language features
> effectively, we have to look at code written *after* the new language
> features were described in training material and *after* programmers
> could trust that their code would not need to run under old releases
> that didn't support these features.

   i believe *most* of the code was written well after real funs were introduced.
   but yes, it would be intersting to have a sample that was started from 
scratch more recently than the AXD code. there is a huge inertia in adopting new 
features, because old guys tend to stick to what they know, and new guys learn 
from the old code.

> In fact, given that we are talking about source code that has been
> around for a while and not fixed when it wasn't broken, I draw the
> opposite conclusion to Mats from his own figures.

   this was my conclusion; "one can write well working Erlang code while rarely, 
if ever, using funs". quite a feat to draw the opposite conclusion from my figures.
   i also stated a hypothesis; "most of this code was produced by programmers 
that rarely use funs if they don't have to". i'm not even sure what the opposite 
of that is, but i doubt the figures support it.

>     Hypothesis:
>         The proportion of 'funs' (and list comprehensions) in files
>         is increasing with time, so that 'industrial programmers'
>         *are* taking up the new features, they just aren't rewriting
>         old code for the fun of it.

   this is probably true. of course, it's a non sequitur (or perhaps even a 
straw man argument?). noone has claimed the opposite, and  no figures that i'm 
aware of says anything about trends over time.

   mats



More information about the erlang-questions mailing list