Subj : Re: OO compilers and efficiency To : comp.programming From : Chris Dollin Date : Wed Jul 27 2005 10:38 am Chris Dollin wrote: > Functional programs have if-then-else. What they don't have is > updatable locations. Probably I should say that *pure* functional *languages* don't have update. Impure FLs - eg ML, Scheme - have limited update and lots of idioms that don't use it. [My excuse is that I spent too much time in an environment when "functional" implied "pure", and it hasn't worn off yet.] So, to be positive, what do functional programs - better, languages - have (or tend to have)? A non-exhaustive list includes: * functions as first-class objects, so any function can be passed as an argument or returned as a result, capturing any bound non-local variables [ie thay are "closures"] * notation for function-expressions, so you can write anonymous functions, eg (x => x + 1) to denote "the [a] function that adds one to things". Sometimes this includes operator abbreviation such as (1.0 /), "reciprocal". * [Sometimes] strong static inferred typing, which gives a lot of the benefits of compile-time type-checking without the syntactic litter * [Sometimes] compact definitions of data-types like tuples, records, and tagged unions, often with syntactic sugar for decomposing them ... * ... using pattern-matching in function definitions. EG, and with no particular syntax, type List T = nil | cons of (hd: T x tl: List T) def length nil = 0 | length cons of (h, t) = 1 + length t -- Chris "electric hedgehog" Dollin predicting self-predictors' predictions is predictably unpredictable. .