Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id t8OHL46r023703 for ; Thu, 24 Sep 2015 19:21:05 +0200 Received: from relay2.uni-heidelberg.de ([129.206.119.212]) by mx-ha.gmx.net (mxgmx107) with ESMTPS (Nemesis) id 0MEKyS-1ZuWGJ0mEK-00FRco for ; Thu, 24 Sep 2015 19:20:59 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t8OHEZEt026357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 24 Sep 2015 19:14:35 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t8OCthjQ017266; Thu, 24 Sep 2015 19:14:35 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 12579971 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 24 Sep 2015 19:14:35 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t8OHEYaY019654 for ; Thu, 24 Sep 2015 19:14:34 +0200 Received: from mail-ig0-f170.google.com (mail-ig0-f170.google.com [209.85.213.170]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id t8OHETDo031177 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Thu, 24 Sep 2015 19:14:32 +0200 Received: by igbkq10 with SMTP id kq10so126086460igb.0 for ; Thu, 24 Sep 2015 10:14:28 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.143.2 with SMTP id sa2mr659030igb.13.1443114868597; Thu, 24 Sep 2015 10:14:28 -0700 (PDT) Received: by 10.36.84.19 with HTTP; Thu, 24 Sep 2015 10:14:28 -0700 (PDT) References: <56020530.4070302@clear.net.nz> <56025C88.6050307@morningstar2.co.uk> Content-Type: text/plain; charset=UTF-8 Message-ID: Date: Thu, 24 Sep 2015 13:14:28 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: An incomplete int-erface? To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <56025C88.6050307@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:rP6DLxsB3GI=:LTdr+oodswov0/BXYqopvNsmni bp16p1G48F5KqY/MeMP9yn2SYSg9xXaCy+DhdKV0V9wpq4voqs42Q0d7PP5gtiIWsm34mCZX4 CyA4R+EQLtbNt+kaOY1JOndqufuYi6ULKRL9FkEROOH9qhk/tz/U3VhM2ykItMD8s9GtamzK2 eGk5GAnC1xDwt30vPJbEq7TpV+juklBvjr/TgmIW7vVaKxh2IguvZBKypzaO4pwAtk1JmlvMh 1QmGd2ZuwW7atEEHPqGUcRWPk8C/DcDZQpuw2Ur5991tlXJmaIGgF6UVF4X5CEVz/tOKDT33c BwO9VyWcHHUS+6QzLhOgTSA40t7/KVluSHlYx/m0D3qV0wV4rfJQRWLrmiR/CawyGq3TArC9K cHpfnzjUuTaSf7+CKWDCV1aBSHf3v+ie6X1ecoAQiVuqpJWewIrgK2BFXuuygYEU6ArknOA0E teVWcVAnrQBK0Fnwtbofs1aHAio+RGiTAGTxKvq2AMs5ieP7DdF70q99Rymcsj+QCB+zm63Ar yguxAp6is+C21rc7rsPRegu57o+tMvi5gWRj91y3pgtIq6+/jfhUy5rfJXSD5Sce4OtRJOW2/ jub67VARiT7XBABRenkzbxLmQ0TKofbKh8NSGH0mFsF8sgycw0T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7A6qUSP9CS7QG6arc532e2 fhTpPFT9UjzzYmSHwXq9Sq9VhMNsL8clY8p/cpIT/MEPtbI4/Uih5xbApW/eXctGbSlJTyeP3 5jJLLALX1DrxX4LuGpKvVIep5JrKFYt/kP5Y2xNa03WExxIY12usDaEjC97Hizf/3gjEl6M5w e6CZglCE9aYLvAj3B2LyKC3tJAV9rLJCWQ6qv7w5Gysv+2cVAR7arrdw+9bwW90npnKXL0BQg MlVFNHwFdhp19I6ZljPMpWRP0Gw/vWlIWl4Pg4KZkG9jcogVe5KsnjxphlHsC/CBC0JiItEUO ICdymQ3aSIq7+R03nWn2NKWVydeuK2Sb6GuXHZokgY6Gfd21u4D9UuS4DaqiPwe+nVjZtXOGm O5VGa9bLYOj+vzn3rvdRiCU18nZoQmOTVEQ2Hez8VIbFc09ggVSa X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7891 On 9/23/15, Joseph Wright wrote: > On 23/09/2015 02:49, Andrew Parsloe wrote: >> \int_eval:n { - (1+2) } >> >> gives a "Missing number, treated as zero" message. So does \int_eval:n { >> + (1+2) }. As Joseph says, this is due to the syntax of eTeX's primitive \numexpr. Let me answer Will's suggestion of adding "0+" to the start of every \int_eval:n. That won't cover cases such as \int_eval:n { 1 + ( - (2 + 3) + 4) * 5 } where the "-(" construction (with no left-hand operand) appears in the middle of an expression. >> But >> >> \int_eval:n { 0 - (1+2) } >> >> evaluates correctly. If + ( or - ( are the first members of an integer >> argument, an error results; if they are not the first members, they are >> accepted by \int_eval:n etc. I don't know that this is a bug as such but >> it certainly feels to me like an untidiness in the l3int interface. It >> means that the order in which component parts of an expression are >> presented to \int_eval:n matters, even though in an arithmetical sense, >> they evaluate to the same number. I agree that it would be better to have a nicer interface, and it is very close to being a bug, but one in eTeX rather than LaTeX3, and not fixable on our end. >> I query too whether an expression like >> >> \int_eval:n { 3(1+2) } >> >> should "evaluate" to 3(1+2), rather than 9, without showing an error. That we could catch. Heiko once suggested that we include parentheses in our expressions, defining \int_eval:n {#1} as \tex_the:D \etex_numexpr:D (#1) \tex_relax:D . That would at least produce an error when an expression is terminated early (say because of a ^ or juxtaposition, or space in the middle of a number, etc). Of course that wouldn't help with unbalanced parentheses. >> (Alternatively, I find myself wondering what would be entailed to >> harmonize the integer interface with the fp one (which has no problem >> with these expressions)? Then one could choose whether to evaluate an >> expression involving integral numerals in l3fp or l3int without having >> to change the expression, as one does at present. For instance, if the >> expression involves an exponent, use l3fp; if not use l3int. This choice >> becomes more complicated when the expression itself needs to be changed.) >> >> Andrew > > The different 'behind the scenes' here is that \int_eval:n is just the > engine \numexpr primitive in a macro wrapper, but \fp_eval:n is > implemented entirely in macros (as there is no floating-point > primitive). Thus while we can alter the parser for fp work, we can't for > int work, or rather not without significant changes. In particular, > there would be a performance implication in parsing int input and doing > the calculations 'by hand'. I suspect int parsing would be easier than > for fp expressions, but even so this looks like a significant effort. I would expect at least a 10x slow-down (rough estimate, I can look into this more if requested). > As Will has commented, we might manage at low cost to avoid the bracket > issue, but allowing \int_eval:n { 3(1+2) } would be rather more tricky. > Indeed, I'd probably say we shouldn't: here I think requiring an > explicit "*" is the right approach. Bruno is best-placed to comment on > the fp implementation here. I actually fear that I probably made a mistake when allowing juxtaposition of this kind in l3fp. Maybe it is not too late to change. We never really had time for a discussion of the syntax of l3fp, which I cooked up myself with no outside input. > The reason I'm wary of making any changes, quite apart from effort both > in terms of the team and in terms of TeX when using expressions, is that > life gets more complex when you look at dim/skip/muskip cases. There, > the underlying primitives have particular requirements, thus > > \dim_eval:n { 4pt * 3 } > > is valid but > > \dim_eval:n { 3 * 4pt } > > is not. I really don't think we want to implement all of the necessary > parsing for this by hand, so saying that we follow the underlying > primitive requirements is a position I think we are best with in general. Yeah, getting this \dim_eval:n to work would require pretty much as much work as fp parsing. The code is mostly available but I would expect something like a 100x slow down. > BTW, as far as I know there is nothing that would be valid for an int > expr. that would fail for l3fp. That is true, so any int expression can be turned into an fp one if you realize that you want to use ^ for instance. The reverse is not true. Bruno