info-gnus-english
[Top][All Lists]
Advanced

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

Re: Strip signature on reply without standard separator


From: Emanuel Berg
Subject: Re: Strip signature on reply without standard separator
Date: Sat, 24 Sep 2022 17:29:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Satoshi Yoshida wrote:

>> Just try - and you will fly ...
>> 
>> ;;; -*- lexical-binding: t -*-
>> 
>> (defun c ()
>>   (message b) )
>> 
>> (defun a (b)
>>   (message b)
>>   (setq b "ah")
>>   (c) )
>> 
>> ;; (a "oh")
>> ;;         ^ eval me
>
> Error message is displayed on *Backtrace* buffer.

Indeed, it shouldn't work with lexical/static scope since,
despite `setq', b is not a global variable. So it'll be
undefined in 'c'.

> And "ah" is displayed on mini buffer in case without
> ";;; -*- lexical-binding: t -*-".

Yes, with dynamic/special scope it does work but it's not
encouraged to use that unless one has a good reason. Actually,
to use that _in general_ I think is never encouraged. One can
still have individual variables that are global tho if and
when that's called for ...

>> Also, byte-compiling this will echo a warning saying b is
>> a free variable, and this even under dynamic/special scope
>> where the code actually works tho (i.e. this particular use
>> of 'a' and 'c' where 'a' is used first).
>
> My understanding is 50%.

That's normal and in particular in this case ...

> Do you mean that using setq without ";;; -*-
> lexical-binding: t -*-" has no problem?

I'm saying

1) Always use lexical/static scope, i.e. put 

;;; -*- lexical-binding: t -*-

first in all and every new Elisp file you create.

2) In this case, since there is a formal parameter with the
same name, `setq' does not create a global variable.

  (defun strip-signature (re &optional rep)
    (or rep (setq rep ""))
    ;; ...

This is OK. Only if you misspell "rep" to something that isn't
rep (or re) a global variable will be created :)

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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