[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggested additional example to Emacs Lisp Manual: Variables: Let
From: |
John Wiegley |
Subject: |
Re: Suggested additional example to Emacs Lisp Manual: Variables: Let |
Date: |
Sun, 29 Jan 2017 11:20:37 -0800 |
User-agent: |
Gnus/5.130016 (Ma Gnus v0.16) Emacs/25.1.91 (darwin) |
>>>>> "br" == ben rudgers <address@hidden> writes:
br> The manual does not provide an example showing a locally scoped function.
br> Though the behavior can potentially be inferred from the documentation of
br> functions, an example showing the relationship between =let= and =funcall=
br> might be of practical help for someone who has not made a deep dive into
br> the manual.
I think it would be better to encourage the use of `cl-flet' or `cl-labels',
as though macros are specifically intended for binding local function
definitions, and will automatically handle whether the function should be a
`lambda' or a `closure', depending on the setting of `lexical-binding'.
Your approach may have merit in terms of pedagogy, but I'd prefer to nudge
users toward more idiomatic usage from the beginning.
@example
(require 'cl-macs)
(defun foo (x)
(cl-flet ((bar (y) (+ x y)))
(bar 3)))
(foo 4)
@result{} 7
@end example
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2