From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3422 invoked from network); 16 Feb 2022 14:36:42 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 16 Feb 2022 14:36:42 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 14A7F9D0BE; Thu, 17 Feb 2022 00:36:40 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 85EE99D036; Thu, 17 Feb 2022 00:34:50 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 40AEE9D036; Thu, 17 Feb 2022 00:34:49 +1000 (AEST) Received: from relay05.pair.com (relay05.pair.com [216.92.24.67]) by minnie.tuhs.org (Postfix) with ESMTPS id 326CD9D035 for ; Thu, 17 Feb 2022 00:34:48 +1000 (AEST) Received: from orac.inputplus.co.uk (unknown [84.93.57.220]) by relay05.pair.com (Postfix) with ESMTP id F10A11A2B1D for ; Wed, 16 Feb 2022 09:34:46 -0500 (EST) Received: from orac.inputplus.co.uk (orac.inputplus.co.uk [IPv6:::1]) by orac.inputplus.co.uk (Postfix) with ESMTP id 7C4EE2111F for ; Wed, 16 Feb 2022 14:34:45 +0000 (GMT) To: tuhs@tuhs.org From: Ralph Corderoy MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-reply-to: References: Date: Wed, 16 Feb 2022 14:34:45 +0000 Message-Id: <20220216143445.7C4EE2111F@orac.inputplus.co.uk> Subject: [TUHS] dc after bc. X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" Hi, Dave Horsfall wrote: > > I never quite got DC, and wondered at the duality of them. > > You know you're a greybeard if you can remember why the DC sequence > "99k2vp8opq" was so popular... I used to use bc, and still do when ‘a(1)*4’ would be useful, but moved to dc because I didn't know it well and wanted to improve. Plus reverse Polish tends to better match what I want to enter. But I think I'm missing the idiomatic way to use it; I'm puzzled there's no command to print and pop the top of stack followed by a linefeed. - ‘p’ prints the top of stack without popping it, and then linefeed. - ‘n’ pops and prints the top of stack but without a linefeed. - ‘f’ prints the stack, one number per line. - ‘c’ clears the stack. This means my multiple unrelated calculations tend to end with ‘pc’ as otherwise the stack builds up and I might accidentally use old stuff on the stack if the operators for this next sum don't push enough operands of their own. If I use n then the stack is popped, which I want, but the cursor remains after the number. I could see that's useful if the number was still the top of stack because I could continue typing on the same line to make use of it. So I'm left with ‘pc’ or ‘fc’, or ‘n10P’. Popping without printing is ‘ss’ or similar to store it in register s. So ‘pss’ prints ToS and pops just it, simpler than ‘n10P’. How did dc's users balance printing the results with not building stack detritus? -- Cheers, Ralph.