Subject: bug#12895: 24.3.50; Replacement for flet

From: Stefan Monnier <[email-masked]>
Date: Thu, 15 Nov 2012 13:35:34 -0500

tags 12895 notabug
thanks

>   Temporarily bind to PLACEs. This is the analogue of `let', but with
>   generalized variables
> If it excludes overrides, I think it should say so explicitely.  Right
> now I'm led to think it's like let for functions, and I've been using
> let for overriding just fine.

letf and cl-letf do not exclude overrides: it only does overrides
(well, pretty much, except if PLACE is a variable, in which case it's
just like a let).

But, indeed, the docstring of cl-flet was wrong since it said "Make
temporary function definitions" whereas these are not temporarily but local.
I just fixed it now, thank you.

>> Such override should be done with an advice.
> Unless I'm missing something easier, using an advice would be cumbersome
> (define the advice, activate it, run the function, then deactivate the
> advice, protecting for errors). Would you consider un-obsoleting flet?
> It isn't deprecated by either cl-flet or cl-letf.

Overriding a function is bad.  It can mess things up and throw you
majorly off-course when debugging the problem.  So it's good if
it's cumbersome.

Check my recent patch to js.el to see how I replaced flet with advices.

        Stefan