Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
doc strings for both interfaces and concrete implementations
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Warren Lynn  
View profile  
 More options Jul 29 2012, 2:12 pm
From: Warren Lynn <wrn.l...@gmail.com>
Date: Sun, 29 Jul 2012 11:12:37 -0700 (PDT)
Local: Sun, Jul 29 2012 2:12 pm
Subject: doc strings for both interfaces and concrete implementations

Is there a way to create doc strings on both interfaces (procotols, multi
functions) and concrete implementations (protocol implementation,
multi-methods)? For now it seems to me I can only have doc strings for the
interfaces. If that is the case, I feel it is something worth fixing,
because in my view doc string is not a nice-to-have thing, but essential
for dynamic languages.

Assuming we don't have it yet, what I am hoping for is, when I do (doc
symbol), or use slime-describe-symbol, it should list the doc strings for
the interfaces along with the doc strings of all of its concrete
implementations.

For example, I may have a multi-function like this:

(defmulti make-obj
  "Create a new obj."
  (fn [& args] (first args)))

This multi function dispatches on the first argument, and each method can
have quite different argument list and of course doc strings. But for now I
don't seem to have a way to document them.

Another thing I hope for (but less important), is to be able to have
different doc strings for different signatures of the same function.

I think computer language is called "language" for a reason. It is not just
for making computers to do magic things, but also be able to let people
(youself in 4 months or another programmer) to under how that magic
happens. It is a communication media like a natural language, and doc
strings are even more important here because dynamic languages are so
"dynamic".


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Jul 29 2012, 3:02 pm
From: Tassilo Horn <t...@gnu.org>
Date: Sun, 29 Jul 2012 21:02:43 +0200
Local: Sun, Jul 29 2012 3:02 pm
Subject: Re: doc strings for both interfaces and concrete implementations

Warren Lynn <wrn.l...@gmail.com> writes:
> Is there a way to create doc strings on both interfaces (procotols,
> multi functions) and concrete implementations (protocol
> implementation, multi-methods)?

No, I don't think so.

> Assuming we don't have it yet, what I am hoping for is, when I do (doc
> symbol), or use slime-describe-symbol, it should list the doc strings
> for the interfaces along with the doc strings of all of its concrete
> implementations.

You could use alter-meta! to add a hunk to the docstring of the
"interface" at the place where you add a new implementation (to have
impl and docs near each other).  Not all interfacy thingies know their
implementations, btw, so having separate docs for the impls wouldn't
neccessarily allow what you request above.

> Another thing I hope for (but less important), is to be able to have
> different doc strings for different signatures of the same function.

In general, all different versions of a function should somehow do the
same thing, so with separate docstrings you'd need to repeat yourself.
A good guideline is to write the "big picture" first, followed by the
meaning of the different parameters.

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Warren Lynn  
View profile  
 More options Jul 29 2012, 5:59 pm
From: Warren Lynn <wrn.l...@gmail.com>
Date: Sun, 29 Jul 2012 14:59:04 -0700 (PDT)
Local: Sun, Jul 29 2012 5:59 pm
Subject: Re: doc strings for both interfaces and concrete implementations

> In general, all different versions of a function should somehow do the
> same thing, so with separate docstrings you'd need to repeat yourself.
> A good guideline is to write the "big picture" first, followed by the
> meaning of the different parameters.

I agree the design should keep all implementations to do the same thing
*conceptually*, as that is what an interface is for. However, I can imagine
it is very common that a concrete implementation needs extra documentation
for certain implementation specific things. That does not mean the
implementation violates the interface, it is just that there are more
details that are outside the scope of the interface. An interface spec
cannot capture everything, otherwise it is already a concrete
implementation instead of an interface. A simple example will be "nth". If
"nth" were defined as an interface, then its spec would be "Return the nth
element of an ordered collection". But for its implementation of a
sequence, the doc can say "this takes linear time", or maybe "will throw an
exception on infinite sequence". But for its implementation of a vector, it
may say "this takes constant time".

In summary, in my view, this is a very legitimate and basic need.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Jul 30 2012, 4:26 am
From: Tassilo Horn <t...@gnu.org>
Date: Mon, 30 Jul 2012 10:26:40 +0200
Local: Mon, Jul 30 2012 4:26 am
Subject: Re: doc strings for both interfaces and concrete implementations

Warren Lynn <wrn.l...@gmail.com> writes:
>> In general, all different versions of a function should somehow do
>> the same thing, so with separate docstrings you'd need to repeat
>> yourself.  A good guideline is to write the "big picture" first,
>> followed by the meaning of the different parameters.

> I agree the design should keep all implementations to do the same
> thing *conceptually*, as that is what an interface is for. However, I
> can imagine it is very common that a concrete implementation needs
> extra documentation for certain implementation specific things.  [...]

> In summary, in my view, this is a very legitimate and basic need.

I won't object, and the alter-meta! approach allows you to do that.  Of
course, it cannot provide documentation for the implementations, but the
interface docs may be extended with impl docs incrementally at the
location where the implementation is defined.  That's at least better
than nothing...

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Warren Lynn  
View profile  
 More options Aug 4 2012, 11:33 am
From: Warren Lynn <wrn.l...@gmail.com>
Date: Sat, 4 Aug 2012 08:33:14 -0700 (PDT)
Local: Sat, Aug 4 2012 11:33 am
Subject: Re: doc strings for both interfaces and concrete implementations

I won't object, and the alter-meta! approach allows you to do that.  Of

> course, it cannot provide documentation for the implementations, but the
> interface docs may be extended with impl docs incrementally at the
> location where the implementation is defined.  That's at least better
> than nothing...

> Bye,
> Tassilo

Thanks for pointing out the alternative. As you said, this is better than
nothing. I filed a Jira ticket for this and hope some day it will get some
consideration.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »