emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: forward-paragraph return value


From: Andreas Röhler
Subject: Re: forward-paragraph return value
Date: Tue, 24 Aug 2010 11:14:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6

Am 24.08.2010 10:27, schrieb Stephen J. Turnbull:
Andreas Röhler writes:

  >  Then people may write functions taking already the return value.

Sure.  But will they?  Show us examples of existing functions
(preferably already in Emacs) that would benefit from this change.

Didn't I point to?

If a look in forward-paragraph doesn't speak to you,
maybe have a look into

bounds-of-thing-at-point .

Forms like
        (let
          (beg
            (progn
             (funcall
              (or (get thing 'beginning-op)
                              (lambda () (forward-thing thing -1))))
             (point))))

Thats bug-sourcing BTW, as it returns point in any case, even if move failed.
Why not make implementation of return value from

search-forward

canonical instead, returning the position if succesful, nil otherwise.

The gain will be for newly written code.
For writers first, who must not learn function by function the return value.

In the example above we could write

(let
    (beg
     (funcall
      (or (get thing 'beginning-op)
          (lambda () (forward-thing thing -1))))))

Its clean and much more reliable, as beg will be nil, if nothing was found.

An easy example would be functions which look like

     ;; some code here
     (forward-paragraph count)
     (foo (point) other args)
     ;; more code

But it's not clear to me that

     ;; some code here
     (foo (forward-paragraph count) other args)
     ;; more code

is going to be more readable without seeing examples.  Since point has
a byte code, it's not particularly costly to use point.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]