[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Passing buffers to function in elisp
From: |
Petteri Hintsanen |
Subject: |
Passing buffers to function in elisp |
Date: |
Tue, 21 Feb 2023 23:18:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hello list,
Alan J. Perlis said "A LISP programmer knows the value of everything,
but the cost of nothing."
I'm reading some bytes into a temp buffer, like so:
(with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally filename nil 0 64000))
then I pass these bytes to functions for processing, like this
(func1 (buffer-string))
or sometimes just part of them
(func2 (substring (buffer-string) 100 200))
Now:
. does this generate garbage? (I believe it does.)
. if there are many funcalls like that, will there be lots of garbage?
(I guess there will be.)
. is this bad style? (I'm afraid it is, hence asking.)
Is it better just to assume in functions that the current buffer is the
data buffer and work on that, instead of passing data as function
arguments?
[Why am I doing like this? It is /slightly/ easier to write tests when
functions get their data in their arguments.]
Also: is it good idea to try to limit the number temp buffers
(with-temp-buffer expressions)? Or are they somehow recycled within the
elisp interpreter?
Thanks,
Petteri
- Passing buffers to function in elisp,
Petteri Hintsanen <=
- RE: [External] : Passing buffers to function in elisp, Drew Adams, 2023/02/21
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/22
- Re: [External] : Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/24
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Michael Heerdegen, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Michael Heerdegen, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, tomas, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Stefan Monnier, 2023/02/25
- Re: [External] : Passing buffers to function in elisp, Petteri Hintsanen, 2023/02/27