help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Defining functions on the fly


From: Stefan Monnier
Subject: Re: Defining functions on the fly
Date: Tue, 16 Jun 2015 21:12:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

>> > (fset (function name-of-function)
>> [...]
>> > (define name-of-function
>> Actually, `fset' is more like Scheme's `set!',

> How so?

Exactly in the sense you describe:

> `define' is typically used if or when a symbol has yet to be bound to
> either a lambda function or value.
> set! is used to destructively re-bind something to a symbol already
> bound to something.

`defun' macroexpands to `defalias' rather than to `fset'.

>> so if it's the *definition* of a function, you should use `defalias' 
>> which is more like Scheme's `define'.
> I don't see it that way, but if works to one's satisfaction then why not?

Actually, they don't do the same thing.  E.g. fset will throw
away/override any advice you may have applied to that function, whereas
defalias will combine the new definition with the pieces of advice.


        Stefan


reply via email to

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