D
David Rush
No one is talking about need, but about clarity of exposition. ....
It just makes code less readable to use _anonymous_ functions.
No. It doesn't.
david rush
No one is talking about need, but about clarity of exposition. ....
It just makes code less readable to use _anonymous_ functions.
Ken Shan said:But in the style of programming that you advocate, as I understand
it, one does not need to give a name to function application from the
problem domain before using it.
In the context in which the offsets are added, it isn't necessary to
know that the offsets are added using map, as opposed, for example, to
an interative construct, such as loop.
Raffael Cavallaro said:No, one doesn't, as long as that function application is the one place
where the implementation of that bit of functionality needs to be
expressed.
I have no problem with a HOF, as long as the HOF corresponds to
something in the language of the problem domain. But it doesn't here. I
think it is telling that your example is taken from the problem domain
of computer science (memoization of functions), not that of the domain.
If we were writing a program that simulated people running and swimming,
it's very doubtful that "quickly" would mean "memoize." "Quickly" would
mean, "with-increased-framerate," or something similar.
(Note that with-increased-framerate would almost certainly be a
macro).
In domains outside of functional programming and mathematics, the
concepts of the problem domain don't usually map to applicable HOFs.
People fall in love with HOFs because they are great tools for lower
level implementation. But I don't think they usually map well to the
concepts of problem domains other than mathematics and computer science.
Named functions and macros let us capture the power of HOFs inside a
vocabulary _and_ syntax that matches the problem domain.
Ken Shan said:So according to you, I need to find a name for function
application, and not just any name -- it needs to be a name from the
problem domain.
Raffael Cavallaro said:From the problem domain _at_that_level_. If, at that level, we're
dealing with array bounds checking (assuming, for the moment that
we're using a language that doesn't have that built in), then function
names like check-index, report-invalid-index-error, etc. are names
from the problem domain at that level.
Indeed. Had the first lisp been programmed on a 680x0, we would have
d0 and d1 instead of car and cdr, or worse, had it been done on 8086,
we would have ax and bx...
The problem I see with the use of the typical anonymous functional
style is twofold:
1. The same functional idiom is repeated, but not abstracted (i.e.,
not named). This leads to unnecessary "programmer inlining," that is,
writing out the implementation everywhere it is used, rather than
naming it once, and using the name everywhere else.
2. The anonymous functional idioms map well to domains such as
arithmetic, mathematics, and functional programming itself. These same
idioms don't map so well to other domains. The more abstract the
program becomes (that is, the closer it moves to the problem domain,
and the farther it moves from the low level arithmetic and functional
abstractions) the less the anonymous functional idioms will correspond
to the existing concepts and vocabulary of the problem domain.
David Rush said:I have in a mail-processing application 2 functions IF-FROM-LINE (used in
mbox file processing) and RFC822-COLLAPSE-HEADER (used in RFC822 header
processing) which both implement algorithms which are parameterized
by functions. This is vaguely similiar in spirit to the visitor pattern
from OO land, but much more flexible. Both of these functions are used
in multiple contexts where the anonymous functions contextualize the
operations performed under specific conditions in their implemented
algorithms. These operations have (so far) been strictly one-off animals.
In the event that I ever feel a need to re-use one of them I will simply
lift the anonymous function from its original source location, give it
a top-level name et voila - instant reuse.
Note that the PDP-10 AOBJP/AOBJN/BLKI/BLKO/PUSH/PUSHJ/POP/POPJ
instructions used a similar format.
It's certainly true that mathematicians do not _write_
proofs in formal languages. But all the proofs that I'm
aware of _could_ be formalized quite easily. Are you
aware of any counterexamples to this? Things that
mathematicians accept as correct proofs which are
not clearly formalizable in, say, ZFC?
+---------------
| AFAIK car stands for contents of address register and
| cdr for contents of contents of data register.
+---------------
From the IBM 704 CPU instruction format:
CAR == "Contents of Address [part of] Register".
CDR == "Contents of Decrement [part of] Register".
See <URL:http://www.catb.org/~esr/jargon/html/C/cdr.html>.
Jacek said:Yes, you use flet (or labels) if you want a local function definition,
and defun if you want a global one. Lisp caters for both
possibilities. Does Python ?
Which one do you think is the usual proof?
http://www.ics.uci.edu/~eppstein/junkyard/euler/
Anyway, this exact example was the basis for a whole book about what is
involved in going from informal proof idea to formal proof:
http://www.ics.uci.edu/~eppstein/junkyard/euler/refs.html#Lak
Oh? My comments always say what _really_ should have happened.Comments should say _why_ something is being done.
Ken Shan said:I'm not sure if I understand your notion of problem-domain levels. For
instance, in a preceding example
amount_due = sum(item_prices) * (1 + tax_rate)
is the problem domain possibly "functions and their arguments", or is
the problem domain possibly "customer billing"?
(when do I stop?)?
In comp.lang.scheme Andrew Dalke said:Pascal Costanza:
Okay, I gave alternatives of "." and ">" instead of "car" and "cdr"
"." for "here" and ">" for "the rest; over there". These are equally
composable.
. == car
cadr == >.
caddr == >>.
cddr == >>
Alex Shinn said:If you are seriously arguing against the use of HOFs in
general then I think you have a lot to learn.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.