A Tango Fibers question and a functional programming anecdote.

Bill Baxter dnewsgroup at billbaxter.com
Sun Oct 28 13:00:59 PDT 2007


Robert Fraser wrote:
> downs Wrote:
> 
>>> ["Load ", "Prefetch ", "Prefetch "] /zip/ ([0, 1, 2] /map/ (&info
>> /rfix/ currentComic /fix/ (&subtract!(int) /fix/ currentStrip))) /map/
>> &concat!(string) /zip/ [&update, &prefetch /fix/ (currentStrip-1),
>> &prefetch /fix/ (currentStrip-2)] /map/ &Pool.addTask;
> 
> Ewwww!
> 
> That whole create-your-own infix operator thing *is* cool, no doubt, but IMO, it reduces readability. To me:
> 
> map(array, &func);
> 
> ... is more readable than...
> 
> array /map/ &func;
> 
> ... but maybe that's because I've never actually done any functional programming.

The use of infix operators is unrelated to functional programming.  Lisp 
doesn't have infix operators, for instance.  map(array, &func) is every 
bit as "functional" as  array /map/ &func.  Or array.map(&func) for that 
matter.  The functional style part comes from hiding the explicit 
procedural steps taken by the computer in functions like 'map', and by 
treating functions like 'func' more as data than code.

--bb



More information about the Digitalmars-d mailing list