Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4453E200D16 for ; Tue, 10 Oct 2017 18:18:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 42DDE160BE1; Tue, 10 Oct 2017 16:18:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8A8431609E5 for ; Tue, 10 Oct 2017 18:18:05 +0200 (CEST) Received: (qmail 28600 invoked by uid 500); 10 Oct 2017 16:18:04 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 28591 invoked by uid 99); 10 Oct 2017 16:18:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2017 16:18:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3540FCEDC4 for ; Tue, 10 Oct 2017 16:18:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id yGteNr6QV3GO for ; Tue, 10 Oct 2017 16:18:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 25F515FD33 for ; Tue, 10 Oct 2017 16:18:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 2E52BE0EE9 for ; Tue, 10 Oct 2017 16:18:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 96FBE24392 for ; Tue, 10 Oct 2017 16:18:00 +0000 (UTC) Date: Tue, 10 Oct 2017 16:18:00 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (FREEMARKER-77) expr!! as a shorthand for (expr)! MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 10 Oct 2017 16:18:06 -0000 [ https://issues.apache.org/jira/browse/FREEMARKER-77?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D1= 6198539#comment-16198539 ]=20 Daniel Dekany edited comment on FREEMARKER-77 at 10/10/17 4:17 PM: ------------------------------------------------------------------- Or rather, first I want a concrete working solution in FM3, and then see ho= w to port ideas back with causing the least confusion. Though for many of t= he changes back porting just wont be feasible... The problem with {{(...)!default}} in FM2 is that parentheses already have = a commonly understood meaning. In particular, if the evaluation order with = and without the parenthesis is the same, like in the case of {{(a * b) + c}= }, t can be removed. {{(...)!default}} works differently, which is confusin= g. Can you show me an example where you suspect the FM3 approach won't work= well? (Though you don't really know how FM3 meant to do it. The relevant discussi= on is [here in the mail archive|https://lists.apache.org/thread.html/2715ec= c7a47fbacf18996169dfd4ed4b82bc38c567f114cec86e0db1@], but it's admittedly very long and not easy to follow.) was (Author: ddekany): Or rather, first I want a concrete working solution in FM3, and then see ho= w to port ideas back with causing the least confusion. Though for may of th= e changes back porting just wont be feasible... The problem with {{(...)!default}} in FM2 is that parentheses already have = a commonly understood meaning. In particular, if the evaluation order with = and without the parenthesis is the same, like in the case of {{(a * b) + c}= }, t can be removed. {{(...)!default}} works differently, which is confusin= g. Can you show me an example where you suspect the FM3 approach won't work= well? (Though you don't really know how FM3 meant to do it. The relevant discussi= on is [here in the mail archive|https://lists.apache.org/thread.html/2715ec= c7a47fbacf18996169dfd4ed4b82bc38c567f114cec86e0db1@], but it's admittedly very long and not easy to follow.) > expr!! as a shorthand for (expr)! > --------------------------------- > > Key: FREEMARKER-77 > URL: https://issues.apache.org/jira/browse/FREEMARKER-77 > Project: Apache Freemarker > Issue Type: New Feature > Reporter: Ondra =C5=BDi=C5=BEka > Priority: Minor > > a.very.long.expr!! could be a shorthand for {{(a.very.long.expr)!}}. > The effect of !! would go back to the "root" of the expression, i.e. at t= he start of the part ending with !! . Not sure if that would have clear eno= ugh rules, though. > The use case is, that often there is a long expression, (again, getting s= omething from a deep graph), and anywhere on the path something can be miss= ing. The only relevant thing is at the end. And the parentheses make the ex= pression less readable. > Example made-up situatuon: > {code} > (foo.bar.baz[(foo.transform((a.very.long.expression())!"defaultResult"))!= fallbackKey(context)])!"-" > {code} > 1) The long expression can be missing at any point, so the transform woul= d get some default value. > 2) The transform may return null if the argument is somehow improper. For= that case, the {{fallbackKey()}} would return a key as per the {{context}}= . > 3) If the map doesn't contain the entry or any of {{foo.bar.baz}} is miss= ing, the whole expression would turn into {{"-"}}. > {code} > foo.bar.baz[foo.transform(a.very.long.expression()!!"defaultResult")!!fal= lbackKey(context)]!!"-" > {code} > Ok, this one is perhaps a candidate for splitting into few steps. But it'= s just for illustration. > Does it make sense? Is it doable? > Marking it as minor as it's not really too much pain, just would be nice = to have. -- This message was sent by Atlassian JIRA (v6.4.14#64029)