Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Source mangling in $functions_source and typeset -f
- X-seq: zsh-users 27372
- From: Lawrence Velázquez <larryv@xxxxxxx>
- To: "Ray Andrews" <rayandrews@xxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Source mangling in $functions_source and typeset -f
- Date: Sat, 27 Nov 2021 14:40:02 -0500
- Archived-at: <https://zsh.org/users/27372>
- In-reply-to: <66a84643-de4f-ef74-4664-d2400f74f2e6@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5n-hGj5ifk9KDZM29=e1u8m6nLDhxtsNgsqHKr7mLALcQ@mail.gmail.com> <CAH+w=7bkxmP9rVeiMObYBXpeayY2Hf8qDRp6r_570wkE3ZdQHA@mail.gmail.com> <66a84643-de4f-ef74-4664-d2400f74f2e6@eastlink.ca>
On Sat, Nov 27, 2021, at 2:25 PM, Ray Andrews wrote:
> On 2021-11-27 9:47 a.m., Bart Schaefer wrote:
>>
>> With the exception of the contents of strings (including
>> here-documents), the original source of a function is not kept in
>> shell memory. Instead a parse tree is stored and used to regenerate
>> the function definition by "typeset -f" et al.
> That's most interesting, it seems circular so there must be a good
> reason for it, but why take the source as written, then parse it down to
> 'clean code' and then construct whatever internal representations zsh
> uses and then reconstruct clean code from that when one could just
> repeat the first step?
Are you asking why ''typeset -f'' and its ilk don't reread the
original source code?
> Is it perhaps faster to perform the 3d step than
> repeat the first step?
Surely it is, if the first step involves disk I/O.
> But repeating the first step would surely preserve more?
Don't assume code comes from a file that can be read again. What
if the original file is no longer available? What if the function
was defined using standard input and didn't originate from a file
at all?
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author