From: "Lawrence Velázquez" <larryv@zsh.org>
To: "Ray Andrews" <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: Source mangling in $functions_source and typeset -f
Date: Sat, 27 Nov 2021 14:40:02 -0500 [thread overview]
Message-ID: <8ad53605-3f4c-482b-afb2-82a627de44d0@www.fastmail.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2021-11-27 19:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-27 8:01 Zach Riggle
2021-11-27 17:47 ` Bart Schaefer
2021-11-27 19:25 ` Ray Andrews
2021-11-27 19:40 ` Lawrence Velázquez [this message]
2021-11-27 20:09 ` Ray Andrews
2021-11-27 20:14 ` Bart Schaefer
2021-11-27 21:56 ` Ray Andrews
2021-11-29 16:00 ` Peter Stephenson
2021-11-29 17:55 ` Bart Schaefer
2021-12-01 6:53 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ad53605-3f4c-482b-afb2-82a627de44d0@www.fastmail.com \
--to=larryv@zsh.org \
--cc=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).