From owner-freebsd-arch@freebsd.org Wed Jul 15 08:17:47 2015 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C21909A2AA9 for ; Wed, 15 Jul 2015 08:17:47 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id A7EDF166E for ; Wed, 15 Jul 2015 08:17:47 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: by mailman.ysv.freebsd.org (Postfix) id A73649A2AA8; Wed, 15 Jul 2015 08:17:47 +0000 (UTC) Delivered-To: arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A6BD79A2AA7 for ; Wed, 15 Jul 2015 08:17:47 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 6CCFA166B for ; Wed, 15 Jul 2015 08:17:47 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id DD68E3BB88; Wed, 15 Jul 2015 08:17:44 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.9/8.14.9) with ESMTP id t6F86UKi078060; Wed, 15 Jul 2015 08:06:31 GMT (envelope-from phk@phk.freebsd.dk) To: John-Mark Gurney cc: arch@freebsd.org Subject: Re: add inverse option to ministat In-reply-to: <20150715071534.GE8523@funkthat.com> From: "Poul-Henning Kamp" References: <20150715002013.GZ8523@funkthat.com> <77609.1436942964@critter.freebsd.dk> <20150715071534.GE8523@funkthat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <78058.1436947590.1@critter.freebsd.dk> Date: Wed, 15 Jul 2015 08:06:30 +0000 Message-ID: <78059.1436947590@critter.freebsd.dk> X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2015 08:17:48 -0000 -------- In message <20150715071534.GE8523@funkthat.com>, John-Mark Gurney writes: >Poul-Henning Kamp wrote this message on Wed, Jul 15, 2015 at 06:49 +0000: >> -------- >> In message <20150715002013.GZ8523@funkthat.com>, John-Mark Gurney writes: >> >> >Instead of having to massage the data, or know that below a certain >> >percentage you can just flip the sign, provide this, and you'll now >> >convert to x per second, giving you an easier comparision for talking. >> >> Why isn't this fundamentally against the UNIX and Software Tools Philosphy >> and the first step on a long road to turn ministat into R ? > >Didn't that get violated when options -C and -d were added in r161692? Those have pretty solid precedents in cut(1), sort(1) etc. I protest primarily because I called it *mini*stat for a reason, and secondarily because I think it is a slippery slope doing it operator by operator the way this patch invites to, next thing you know we will have -a(dd) -s(ubtract) -m(ultiply) and -d(ivide). *Iff* we want to allow transformations of input values, we should be general about it, and allow people to enter a full expression: ministat -e '(x - 645134) / 1203.5 + 7.5' But that means adding another full expression evaluator to the tree because none of the many we already have offer a library interface, and once you've implemented +,-,/,* people will ask for log(), exp() and... The shortcut to just hack it so ministat does a popen(awk) to do the math, doesn't offer anything over running awk by hand in my view. There are of course ways we could do this "right": If we had an official "little-language" in the base-system (Tcl, Lua, Intercal - pick your poison) we could use that, but apart from the religions fundamentalism, little languages always suffer from latent chronic obesity. A more feasible way might be to adopt plan9's pipe-trick, where fopen(3) does popen(3) if the first char is '|': ministat "|awk '{print 1/$1}' file1" "|awk '{print 1/$1}' file2" (I never understood why that got shouted down in 199x, and I still think it would be a damn nice feature to have...) But for ministat specificall, I'd rather stop before we even get started, point at the 'mini' and tell people to run awk(1) or learn R if they need non-mini functionality. PS: I also agree with Michael that claiming copyright for adding a single division operation comes across as a bit expansionist. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.