Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Fri, 29 Mar 2024 17:01:45 -0700 Organization: None to speak of Lines: 58 Message-ID: <87il14si3a.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sat, 30 Mar 2024 00:01:53 +0100 (CET) Injection-Info: dont-email.me; posting-host="55d3bec1253354bc3d638b21ffa9fc4c"; logging-data="632026"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19v99dZlGOR0pAbfyrM6/uD" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:ELJvvEtxoCl8vW7hG7EwMO0PVGo= sha1:eJoecgRWJSgO8Y/1UWmjS0XkkXM= Xref: csiph.com comp.unix.shell:24842 comp.unix.programmer:15590 comp.lang.misc:10263 Janis Papanagnou writes: > On 29.03.2024 21:59, Lawrence D'Oliveiro wrote: >> On Fri, 29 Mar 2024 10:37:22 +0100, Janis Papanagnou wrote: >> >>> Program text is initially text.[*] During parsing (either in >>> an interpreted or in a compiled language) you split the text >>> in tokens. >> >> And then, how do you interpret the tokens? > > In an interpreter the tokens are interpreted, in a compiler > they are subject to the parsing. (But you know that I'm sure.) Are you suggesting that interpreters don't parse their input? No doubt there are interpreters that handle tokens one at a time, but shells typically don't work that way. There are a lot of different ways to distinguish between languages like sh/ksh/bash that are normally interpreted and languages like C that are normally compiled to machine code: - Is the language primarily designed for interactive command-line use? - Is the language normally compiled to machine code? - Is the language compiled by some kind of byte code that is then interpreted? Is that byte code *sometimes* translated to machine code? - Is foo treated by default as a string or as an identifier? (Treating it as a string is convenient for interactive use.) - Does a syntax error on line 10 prevent lines 1-9 from being executed? I don't think *any* of these distinctions are fundamental. For example, a Perl or Python program/script is parsed and "compiled" into some in-memory form before execution begins. A syntax error prevents the entire script from being executed. In Bourne-line shells, a syntax error won't be detected until execution reaches that line. (Things like Perl's BEGIN and eval can complicate things.) Shells also have to parse their input, though it's done a bit differently. Typically the entire script isn't parsed as a unit. [...] > So what is 'for i in a ; do ... ; done' then in your world? > > This is one of many basic shell constructs that I use in shell > programming (not "shell scripting") regularly. I use it both in shell scripting/programming and interactively. And the entire construct needs to be processed before the shell can begin to execute it. Misspelling "done" prevents the whole thing from running. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Medtronic void Void(void) { Void(); } /* The recursive call of the void */