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

A beginners question on docstrings

39 views
Skip to first unread message

hdm_persist

unread,
Jun 30, 2012, 8:44:27 AM6/30/12
to
I'm new to scheme and have been looking at some code examples to familiarize myswlf with idiomatic scheme. I saw something similar to the following:

1 (define (test un)
2 "What is the purpose of this string?"
3 (display (string-append "un" un)))
4
5 (test "believable")

Line 2 appears to be a docstring similar to those in python. Is this a docstring? Are they commonly use in scheme? Are they available at runtime or stripped like a comment? Thank you...

John Cowan

unread,
Jun 30, 2012, 6:13:26 PM6/30/12
to
On Saturday, June 30, 2012 8:44:27 AM UTC-4, hdm_persist wrote:

> 1 (define (test un)
> 2 "What is the purpose of this string?"
> 3 (display (string-append "un" un)))
> 4
> 5 (test "believable")
>
> Line 2 appears to be a docstring similar to those in python.
> Is this a docstring? Are they commonly use in scheme?
> Are they available at runtime or stripped like a comment?
> Thank you...

What it is, is an expression whose value is being discarded. If there is more than one expression in `define`, the values of all but the last are thrown away. It may be that in some implementation this value is associated with the name of the variable and accessible somehow, but it is not portable to assume that.

David Duffy

unread,
Jun 30, 2012, 7:05:53 PM6/30/12
to
John Cowan <johnw...@gmail.com> wrote:
> On Saturday, June 30, 2012 8:44:27 AM UTC-4, hdm_persist wrote:

>> Line 2 appears to be a docstring similar to those in python.

> What it is, is an expression whose value is being discarded.
[...]
> It may be that in some implementation this value is
> associated with the name of the variable and accessible somehow, but it
> is not portable to assume that.

More common in other lisp dialects: Emacs Lisp, Common Lisp ...

hdm_persist

unread,
Jul 1, 2012, 5:00:28 PM7/1/12
to
That explains why I hadn't seen this before. Thanks John...

hdm_persist

unread,
Jul 1, 2012, 5:01:47 PM7/1/12
to
Thanks David...
0 new messages