What is Expressiveness in a Computer Language

Joe Marshall eval.apply at gmail.com
Tue Jun 27 17:26:31 EDT 2006


Marshall wrote:
> Joe Marshall wrote:
> > Looking back in comp.lang.lisp, I see these examples:
> >
> > (defun noisy-apply (f arglist)
> >   (format t "I am now about to apply ~s to ~s" f arglist)
> >   (apply f arglist))
> >
> > (defun blackhole (argument)
> >   (declare (ignore argument))
> >   #'blackhole)
> >
> > But wait a sec.  It seems that these were examples I invented in
> > response to the same question from you!
>
> Ah, how well I remember that thread, and how little I got from it.
>
> My memories of that thread are
> 1) the troll who claimed that Java was unable to read two numbers from
> standard input and add them together.
> 2) The fact that all the smart people agreed the blackhole
> function indicated something profound.
> 3) The fact that I didn't understand the black hole function.
>
> The noisy-apply function I think I understand; it's generic on the
> entire arglist. In fact, if I read it correctly, it's even generic
> on the *arity* of the function, which is actually pretty impressive.
> True?

Yes.

> This is an issue I've been wrestling with in my own type
> system investigations: how to address genericity across arity.
>
> Does noisy-apply get invoked the same way as other functions?
> That would be cool.

Yes, but in testing I found an incompatability.  Here's a better
definiton:

(defun noisy-apply (f &rest args)
  (format t "~&Applying ~s to ~s." f (apply #'list* args))
  (apply f (apply #'list* args)))

CL-USER> (apply #'+ '(2 3))
5

CL-USER> (noisy-apply #'+ '(2 3))
Applying #<function + 20113532> to (2 3).
5

The internal application of list* flattens the argument list.  The
Common Lisp APPLY function has variable arity and this change makes my
NOISY-APPLY be identical.

> As to the black hole function, could you explain it a bit?

It is a function that takes any argument and returns the function
itself.

> I apologize
> for my lisp-ignorance. I am sure there is a world of significance
> in the # ' on the third line, but I have no idea what it is.

The #' is a namespace operator.  Since functions and variables have
different namespaces, I'm indicating that I wish to return the function
named blackhole rather than any variable of the same name that might be
around.




More information about the Python-list mailing list