From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8803 invoked by alias); 25 Jul 2017 01:35:15 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41451 Received: (qmail 24070 invoked from network); 25 Jul 2017 01:35:15 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(0.0/5.0):. Processed in 1.69905 secs); 25 Jul 2017 01:35:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at zdharma.org does not designate permitted sender hosts) X-Virus-Scanned: by amavisd-new using ClamAV (7) Date: Tue, 25 Jul 2017 03:26:00 +0200 From: Sebastian Gniazdowski To: Bart Schaefer Cc: "=?utf-8?Q?zsh-workers=40zsh.org?=" Message-ID: In-Reply-To: References: Subject: Re: Can ZWC be optimized, for lesser depths of recursive exec* calls? X-Mailer: Airmail (442) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 20 lipca 2017 at 19:40:33, Bart Schaefer (schaefer=40brasslantern.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 ex= ec.c functions, =20 > > - general-purpose or not-final calls are done, equilibrium is establi= shed, each Zsh =20 > script part finds its (convoluted) way to execsimple, prefork, addvars,= > > - like in Prolog (but maybe in reversed direction), where each theore= m finds its top =20 > truths in many stages. > =20 > 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 =22recurse and forget=22 tactics in exec.c. Like= zle recursive-edit =E2=80=93 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) fe= ature. The comment in exec.c (first line about suspending pipelines): =C2=A0* Some years ago, zsh either couldn't suspend such things at all, o= r =C2=A0* it got really messed up when users tried to do it. As a solution,= we =C2=A0* implemented the list=5Fpipe-stuff, which has since then become a = reason =C2=A0* for many nightmares. =C2=A0* Pipelines like the one above are executed by the functions in thi= s file =C2=A0* which call each other (and sometimes recursively). The one above,= for =C2=A0* example would lead to a function call stack roughly like: =C2=A0* =C2=A0* =C2=A0execlist->execpline->execcmd->execwhile->execlist->execplin= e So it looks like getting away through recursion, which is a powerful tech= nique, but if it's =22recurse and forget=22, and CPU time dissipates, the= n well, no huge problem, shell doesn't have to be fast like python, but i= t is an obstacle sometimes (syntax highlighting large functions, for exam= ple, 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 =E2=80=93 all this is to make Zplugin so= phisticated, dreaming about automatic extraction of functions and =22turb= o=22 compilation of them into zwc digest. But =22turbo=22 compiling of pl= ugin file (with global code and functions) would also work, he he, so I w= ould close this door for the users ;) > > some exec.c-reading hints, that the =22not-following by WC=5FSUBLIST=22= means no-argumets =20 > for executed function, builtin, etc. > =20 > I think that's a wrong interpretation -- WC=5FSUBLIST should mean a > construct like =22command1 && command2=22, where SIMPLE means there is = no > such conditional construct (only =22command1=22 is present). Thanks. It's a better situation than no-arguments, if one thinks about sh= ort-cutting execution more early to execsimple(), etc. -- =20 Sebastian Gniazdowski psprint /at/ zdharma.org