F
Frode Vatvedt Fjeld
Gerry Quinn said:What do you mean? Rabbit::Jump() seems a perfectly applicable
example.
This is functional abstration, which is all good and well. Lisp macros
provide for syntactic (and even linguistic[*]) abstraction, which opens
up a whole new playing field. The combination of functional and
syntactic abstraction is the dynamic duo that defines Lisp's power.
Well, many of the boasts about Lisp seem to be about its ability to
create 'new languages' for a given problem domain. You mutter about
people not seeing the benefits, but you don't seem so keen to
elucidate them.
It is one of those things whose value is difficult to convey except by
personal experience. Imagine trying to convince a dedicated 1980's era
BASIC programmer of the benefits of functional abstraction. He'd say
something like "Oh, so a function is just a GOSUB with a name instead
of a line-number? Doesn't seem like much to me. Functions have
arguments and return values, you say? Well, duh, I pass arguments in
global variables, and I think anyone unable to keep their variables
straight are unfit to write programs. So this just helps weed out the
weaklings." Well, not quite.
Do you know what "functional programming" means? Some say it's
programming without side-effects, but really it's about writing your
programs in terms of functional abstraction. Or, in other words, in
terms of the function-call protocol your language provides in the form
of syntax and mechanism. Some people think this concept is the panacea
that should be applied universally to solve the software crisis. But
let's assume it's not. Still, the benefit of the clear, manifest,
predictable relationship between the program text and the result of
the program's execution is unquestionable (even if the hypothtetical
BASIC-programmer preferred his global variables). Bugs tend to creep
in when programs have side-effects (which might be called ad-hoc
protocols, contrasted to the language's function-call protocol) that
have consequences for the program that are difficult to spot by
looking at the program text. It is one of the very great benefits of
syntactic abstraction to be able to massage program text such that one
gets the best of both worlds: the clear, manifest relationship between
program text and program execution results, and also
application-specific, non-function-call protocols/side-effects
(i.e. one is not restricted to "functional programming"). (And this is
not to say that there isn't many cases of programming with
side-effects where the consequences are clear and simple without the
use of macros.)
[*] By linguistic abstraction I mean syntactic abstraction carried out
to such a degree that one cannot anymore be said to program in the
original language. Normally, syntactic abstraction integrates
naturally with the original language.