zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@zdharma.org>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: Can ZWC be optimized, for lesser depths of recursive exec* calls?
Date: Tue, 25 Jul 2017 03:26:00 +0200	[thread overview]
Message-ID: <etPan.59769e28.2447d90.188@zdharma.org> (raw)
In-Reply-To: <etPan.5970eb83.495b9d04.6b4@AirmailxGenerated.am>

On 20 lipca 2017 at 19:40:33, Bart Schaefer (schaefer@brasslantern.com) wrote:
> On Thu, Jul 20, 2017 at 8:41 AM, Sebastian Gniazdowski
> wrote:
> >
> > - Zsh code execution is emerging from from rich number of calls to exec.c functions,  
> > - general-purpose or not-final calls are done, equilibrium is established, each Zsh  
> script part finds its (convoluted) way to execsimple, prefork, addvars,
> > - like in Prolog (but maybe in reversed direction), where each theorem finds its top  
> truths in many stages.
>  
> To some extent you're having a deeper variation of the same confusion
> that Ray Andrews sometimes has, namely, distinguishing characteristics
> of an interpreted language from a compiled one. With a true compiled
> language, the syntax and semantics can both be analyzed at compile
> time, but in an interpreted language the semantics aren't fully
> expressed until run time. In this case the chain of exec.c function
> calls traces the semantics of the language -- reconstructing the parse
> tree, traversing it, and executing it, all at the same time.

It's just that I suspect "recurse and forget" tactics in exec.c. Like zle recursive-edit – surprisingly useful, implemented by running zlecore() second time. Having an opportunity to give kudos, I would give it to that person who decided to spend time on doing this very useful in the future, but in general slightly bizarre (running zlecore() again) feature.


The comment in exec.c (first line about suspending pipelines):

 * Some years ago, zsh either couldn't suspend such things at all, or
 * it got really messed up when users tried to do it. As a solution, we
 * implemented the list_pipe-stuff, which has since then become a reason
 * for many nightmares.
 * Pipelines like the one above are executed by the functions in this file
 * which call each other (and sometimes recursively). The one above, for
 * example would lead to a function call stack roughly like:
 *
 *  execlist->execpline->execcmd->execwhile->execlist->execpline

So it looks like getting away through recursion, which is a powerful technique, but if it's "recurse and forget", and CPU time dissipates, then well, no huge problem, shell doesn't have to be fast like python, but it is an obstacle sometimes (syntax highlighting large functions, for example, I was removing functions (inlining) and also simply removing code if only it was possible, gaining many milliseconds).

I have obstacles in working on Zsh recently, I would dive into exec.c and maybe find something. Side note – all this is to make Zplugin sophisticated, dreaming about automatic extraction of functions and "turbo" compilation of them into zwc digest. But "turbo" compiling of plugin file (with global code and functions) would also work, he he, so I would close this door for the users ;)

> > some exec.c-reading hints, that the "not-following by WC_SUBLIST" means no-argumets  
> for executed function, builtin, etc.
>  
> I think that's a wrong interpretation -- WC_SUBLIST should mean a
> construct like "command1 && command2", where SIMPLE means there is no
> such conditional construct (only "command1" is present).

Thanks. It's a better situation than no-arguments, if one thinks about short-cutting execution more early to execsimple(), etc.

--  
Sebastian Gniazdowski
psprint /at/ zdharma.org


  parent reply	other threads:[~2017-07-25  1:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20 15:41 Sebastian Gniazdowski
2017-07-20 17:40 ` Bart Schaefer
2017-08-19  5:06   ` Sebastian Gniazdowski
     [not found] ` <etPan.5970eb83.495b9d04.6b4@AirmailxGenerated.am>
2017-07-25  1:26   ` Sebastian Gniazdowski [this message]
2017-07-25  5:04     ` Bart Schaefer
2017-07-25  5:42       ` Sebastian Gniazdowski

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=etPan.59769e28.2447d90.188@zdharma.org \
    --to=psprint@zdharma.org \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@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).