[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: return values
From: |
Andreas Roehler |
Subject: |
Re: return values |
Date: |
Fri, 13 Nov 2009 11:56:40 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
Alan Mackenzie wrote:
> Hi, Andreas!
>
> On Tue, Nov 10, 2009 at 11:33:39AM +0100, Andreas Roehler wrote:
>
>> Hi,
>
>> IMHO it might be helpful, if classes of functions have a regular return
>> value.
>
>> For example functions which move point should return point.
>
> Here, it's probably more accurate to say "would have been a good idea",
> since some users of the current functions will use the current return
> values, even if only relying on the fact that they're always nil.
>
>> `goto-char' does it presently, beginning/end-of-defun not.
>
> Indeed.
>
>> Also I suggest mentioning the return value in docstring.
>
> I am in favour of mentioning the return value of EVERY function, even
> when (or _especially_ when :-) it's only a sentence like "The return
> value is of no significance".
...
Hi Alan,
what about not to have just one return value
hard-coded, but let it being choosed via optional
return-flags?
Let's consider the case of `forward-comment' employed
inside a `delete-comments-in-region' function.
First `forward-comment' must move. If a comment-section
is reached, function must determine its borders in
order to delete.
Now this second operations basically is redundant, as
`forward-comment' determined borders already, otherwise
it couldn't know about nested comments.
A forward-comment is already able to deliver beg, end
--separately or as a list-- and the comment itself as a
string.
So instead of executing two consecutive functions to
determine, forward-comment could take a flag:
For example
b - return beginning
e - return end
l - return beginning and end as a list
s - return found item as a string
Cheers
Andreas
--
https://code.launchpad.net/s-x-emacs-werkstatt/
http://bazaar.launchpad.net/~a-roehler/python-mode/python-mode.el/