Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

documentation strings of lexically scoped functions

46 views
Skip to first unread message

kodifik

unread,
Feb 15, 2012, 11:46:57 AM2/15/12
to
Out of curiosity :
In common lisp, functions created by 'flet' or 'labels' are allowed to
have doc strings, as any other function.
But they are not accessible from outside.
Are those doc strings useful ?
Are they used?
If so... how? Can anyone provide some example-s?

Pascal J. Bourguignon

unread,
Feb 15, 2012, 12:15:34 PM2/15/12
to
kodifik <kod...@eurogaran.com> writes:

> Out of curiosity :
> In common lisp, functions created by 'flet' or 'labels' are allowed to
> have doc strings, as any other function.
> But they are not accessible from outside.
> Are those doc strings useful ?

Yes. To the programmer who reads them from the sources! :-)

> Are they used?
> If so... how? Can anyone provide some example-s?

In anycase, (documentation 'f 'function) may always return nil…

--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Barry Margolin

unread,
Feb 15, 2012, 12:21:52 PM2/15/12
to
In article
<1ba20170-33aa-4ded...@l1g2000vbc.googlegroups.com>,
Some implementations provide extensions that allow you to access lexical
functions. E.g. IIRC, Symbolics CL had names something like (:INTERNAL
<containing-fun> <internal-fun>). You could pass them to operators like
DISASSEMBLE, TRACE, and DOCUMENTATION.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Zach Beane

unread,
Feb 15, 2012, 12:29:57 PM2/15/12
to
kodifik <kod...@eurogaran.com> writes:

> Out of curiosity :
> In common lisp, functions created by 'flet' or 'labels' are allowed to
> have doc strings, as any other function.
> But they are not accessible from outside.

Here's one way to get it in SBCL:

* (defun foo (value)
(flet ((closure ()
"local function docstring"
(incf value)))
#'closure))
FOO

* (foo 42)
#<CLOSURE (FLET CLOSURE) {1003487A6B}>

* (documentation * t)
"local function docstring"

Zach

kodifik

unread,
Feb 16, 2012, 2:19:52 AM2/16/12
to
On 15 feb, 18:15, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> In anycase, (documentation 'f 'function) may always return nil…

Yeah.
For me, that's a (necessary) concession to a failure:
Either the failure of hardware manufacturers to provide a decent
memory
infrastructure (i.e. one that would not need to separate RAM from
disc)
or the failure of Lisp's attempt to unify the concepts
of programming language and operative system.
Perhaps the latter is a consequence of the former.

Pascal J. Bourguignon

unread,
Feb 16, 2012, 2:43:13 AM2/16/12
to
It's rather a concession to CL implementations targetting
microcontrollers. But it's inadmissible from implementations running on
today hardware. When even a $25 computer on a chip (isn't that a
microcontroller?) has 128 MB, that's megabyte, not kilobyte, or memory,
implementations may keep around the docstrings. Perhaps in compressed
UTF-8 form, if they're self-conscious of their implementation choices
for STRING… In any case, I doubt docstrings represent a high
percentage of the 50 MB of sbcl images.

Tamas Papp

unread,
Feb 16, 2012, 3:49:12 AM2/16/12
to
Considering the time when the standard was finalized, I think that
this choice is understandable. If you really depend on docstrings,
you can create a trivial-docstrings library that would just refuse
loading on implementations that don't support what you need, and make
your code depend on it.

Given that CL is one of the most customizable programming languages,
99% of the time I find it really weird when I hear people complaining
about what the standard does or does not specify. I think that the
more productive approach is to write compatibility layers and CDRs.

Best,

Tamas

Tim Bradshaw

unread,
Feb 16, 2012, 5:32:38 AM2/16/12
to
On 2012-02-16 07:43:13 +0000, Pascal J. Bourguignon said:

> It's rather a concession to CL implementations targetting
> microcontrollers.

Well, be fair. One of the early systems I used to write CL on had
3.7MB of memory (why 3.7 I never knew: it was not the only thing that
was weird about those machines), and I think 40MB of disk, which was
pretty much entirely used up by the virtual memory image of the current
instance together with, if you were fairly lucky, a spare one (but I
think in practice you had to fetch a sysout from a fileserver somewhere
when the system died). Later I used a relate machine which had a whole
80MB of disk which could hold not only a spare sysout but a filesystem
as well: luxury! (Documentation strings almost certainly worked on it,
though).

And this is significantly after the initial (ClTL) specification of CL.
The truth is that when the CL spec was written, what people thought of
as high-end workstations were almost inconceivably puny systems by
today's standards (I'm trying to say "less powerful than a phone"
butthe truth is it's hard to find a device you might recognise as a
computer that they were more powerful than: compare the above spec with
the Raspberry Pi, say, and you'll see what I mean).

0 new messages