From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11463 invoked by alias); 6 Mar 2015 21:31:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19982 Received: (qmail 3325 invoked from network); 6 Mar 2015 21:31:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=X+5rdgje c=1 sm=1 tr=0 a=7K8QI4x6DXfJejJdwhsEbQ==:117 a=7K8QI4x6DXfJejJdwhsEbQ==:17 a=VNsaWKQvMhEA:10 a=N659UExz7-8A:10 a=UyYQEp_qsdQDIqHRRf0A:9 a=pILNOxqGKmIA:10 Message-id: <54FA15BA.3070207@eastlink.ca> Date: Fri, 06 Mar 2015 13:01:46 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: grammar triviality with '&&' References: <54F33934.2070607@eastlink.ca> <13666281425228233@web7o.yandex.ru> <54F345D3.9010204@eastlink.ca> <20150302022754.GA7449@xvii.vinc17.org> <150302005440.ZM16546@torch.brasslantern.com> <20150302103156.GB6869@xvii.vinc17.org> <150302084958.ZM17306@torch.brasslantern.com> <20150304085512.GA3609@ypig.lip.ens-lyon.fr> <54F73D18.8070801@eastlink.ca> <150305205951.ZM8811@torch.brasslantern.com> <54F9D180.4020900@eastlink.ca> <20150306163201.GD10507@ypig.lip.ens-lyon.fr> <150306094359.ZM9698@torch.brasslantern.com> In-reply-to: <150306094359.ZM9698@torch.brasslantern.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit On 03/06/2015 09:43 AM, Bart Schaefer wrote: > } I don't think that the grammar would become more complex. > > What you're both missing or at least glossing over is the interaction > between the grammar and the interactive interpreter. > > There goals are: (1) the grammar for scripts is identical to the grammer > for interactive use, (2) the execution order is identical both in scripts > and in interactive use, and (3) when used interactively, the input can be > interpreted [commands executed] as soon as a complete syntactic structure > has been recognized. Sounds sane. > Under the current grammar, the interpreter always "knows," at the point > where a line break occurs, whether or not it has a complete syntactic > element that it can execute. If you allow the and_or producion to put > a linebreak before AND_IF / OR_IF, then until it encounters an explicit > ";" or "&" (or some other lookahead token that can't appar at that > position in the pipeline production) the interpreter doesn't "know" > whether it has actually reached the end of the "and_or" production. > > Therefore it would either violate (2) to speculatively execute what has > been seen so far, or it would violate (3) to wait for the next token to > complete the lookahead. Sure, we could either discard goal (1) to > make this an interactively-only feature [there's at least precedent for > that with setopts], or we can discard goal (2); we can do whatever > we want. I assume you'd find it way too annoying to discard (3). Don't blame me! I'm just riding along with Vincent's logic, he can argue this with real knowledge, I'm just seeing what's at the bottom of this. When I type at the prompt, it clearly knows when I'm not finished, but If I type ' [ -e file1 ] ENTER', it goes to the next prompt, because it has no way of knowing that I intended to add an '&&' after it on the next line. Quite so. But surely that's not the issue. The issue is whether | two can know to implicity grab the already existing return value from the last command, whatever it may have been. Yup, the previous line is executed and finished and gone, but it has set the errorlevel, and that does persist, so it is legitimately there. Why can't it be used? I see it as violating none of your three rules. It would be the same interactively or in scripts, and it would execute at syntactic completion. All that would change is that an obviously incomplete AND_IF would default to grabbing the previous return value (which is still there). Anyway, the parser would be making a concession, and why should it? No really good reason. I'm satisfied, unless similar concessions are made routinely elsewhere. Nope, it ain't broken, don't fix it. > But this is in a sense analogous to suggesting that > > one | two | three > > could wait to see what happens to "one" before deciding whether to send > the output along to "two". > > one > | two > | three Yes. Exactly. The question was why that's not permitted, but I think I see why. > > just so that you can decide later whether you're interested in adding > yet another stage to the pipeline. Or at least I hope you would not > suggest that, though if you look through the list archives people have > in fact asked how to capture output so they can re-use it later. See > Functions/Misc/keeper for an example. Nope. I don't want to break things more broken than they already are. > In any case, I'm done trying to explain this. We've already put the lie > to the word "triviality" in the subject of this thread. > Amen! It was quite innocent at the time ;-) But it has been deeply informative.