From dev-return-5293-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Tue Sep 4 00:31:08 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E5EEF180647 for ; Tue, 4 Sep 2018 00:31:07 +0200 (CEST) Received: (qmail 30158 invoked by uid 500); 3 Sep 2018 22:31:07 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 30148 invoked by uid 99); 3 Sep 2018 22:31:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2018 22:31:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id F1910C057F for ; Mon, 3 Sep 2018 22:31:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.99 X-Spam-Level: * X-Spam-Status: No, score=1.99 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=asert-com-au.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id MvmhRTuf55Ex for ; Mon, 3 Sep 2018 22:31:02 +0000 (UTC) Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 6F4EB5F401 for ; Mon, 3 Sep 2018 22:31:01 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id j62-v6so1758057edd.7 for ; Mon, 03 Sep 2018 15:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asert-com-au.20150623.gappssmtp.com; s=20150623; h=mime-version:reply-to:from:date:message-id:subject:to; bh=bPVVEEXfr3/2ERzEMEZDYpTfIsHikr3r2IVlqXPyZZw=; b=oTQ2ck0jFU7uUIK/w7c3zwX9cr6CMFuCsIGswZAuxCiCMCL9Tg9t67NM5WFHL3g+Mk J8vP5LdfUvTfZdJHAb1PF/raYiwxTb6bklRLuD8Z1drAq1wiYfMJzbvCbPYOYurpgiXi J8zg0JdI8gerpjG6fbbCylrx3keBrJlhPby3I/gReXJ26Y+M4Ya453xV9shD7PK1GXxk wHQu+vLLOrMkAY2EbmXDhxJGXj1JdeLcZNAuJdnOJJMbCWjwud4LgHuEhGbFLhyOEH0C xKQt25wzyWJMlo1fT7zTngd/6x1H+AgnpG1lxB0Lh7wIrZmAtOj5fdb9uUt09+Lu7jFx ZnGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:from:date:message-id :subject:to; bh=bPVVEEXfr3/2ERzEMEZDYpTfIsHikr3r2IVlqXPyZZw=; b=Nv6UfRvQzyO12D+LkG+SmmtDo5NkeZmLzUn53uUWewNtntna75NoXJzXpse37I0jVu FkFRd5aKBwghqACS/3uXMNgaeQmq/MPZwYhAayQyxbapSjdS2B5F/+xJ9MsfcqKw37GG B1bqOAoJ+WOJwM7O6oqHUJHfHN8ArEu7J2PNLoPgwETxeqmqN1L3WFyzoyuOLJnsBRNo oD2YLnTYpFPFlZngAFxbDfk3alnq8lDOS5xg2jXiotanFviihctai5IQ/HhsfqjUAz5V 0Z6mNatzcE8aHfx6wLnNchlr1S6QuZVC0o1BsgSb/6RDiN/JCPG+PGh4McY8iy2ytc3w lkyw== X-Gm-Message-State: APzg51C24avKHtyFWjLEEWcUgJmCcyI5zXxEjGNeb0FDfDVqFOVEcwe8 k+3BPLWBXGo2QbflPbl1NVJ85yTt1F3WqThSxRYAdCq+580= X-Google-Smtp-Source: ANB0VdZJy+PsY+a/m517ZJ8cLRIcqxDoswiBudfmBxWDlCijmcjhL4SqSWIlY0Hw08ZbhyfSab/BdwT5yihtLL55E+0= X-Received: by 2002:a50:8345:: with SMTP id 63-v6mr32839775edh.5.1536013861065; Mon, 03 Sep 2018 15:31:01 -0700 (PDT) MIME-Version: 1.0 Reply-To: paulk@asert.com.au From: Paul King Date: Tue, 4 Sep 2018 08:30:50 +1000 Message-ID: Subject: Constructor call short-hand syntax To: dev@groovy.apache.org Content-Type: multipart/alternative; boundary="0000000000008f25bd0574ff18cb" --0000000000008f25bd0574ff18cb Content-Type: text/plain; charset="UTF-8" Groovy has a rarely used shorthand syntax for constructors: println Date[time:0] // same as new Date(time:0) println Date[year: 118, month: 8, date: 3] // same as new Date(year: 118, month: 8, date: 3) 1. GROOVY-8602 points out that the safe args version isn't supported, e.g.: println Date?[time:0] I was thinking of closing this as won't fix since we only support this shorthand for class constants. Any objections? Also, I noticed that the empty map isn't catered for: println Date[:] // as per above, might be expected to be the same as new Date([:]) or new Date() // currently NPE: Cannot get property '{}' on null object So, the map isn't found and the expression becomes "println Date" which returns void and then we convert the map to a String and look for that property. I realise this is a weird edge case but I was thinking of creating an issue to fix this for consistency (just Groovy 3). We already support this: def map = [:] println Date[*:map] Let me know if you have other thoughts. Cheers, Paul. --0000000000008f25bd0574ff18cb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Groovy has a rarely used shorthand syntax for constructors:

println Date[time:0] // same as new Date(time:0)
println Date[year: 118, month: 8, date: 3] // same as new Date(year= : 118, month: 8, date: 3)

  1. GROOVY-8602
  2. points out t= hat the safe args version isn't supported, e.g.:=

    println Date?[time:0]

    I was thinking= of closing this as won't fix since we only support this shorthand for = class constants.

    Any objections?

    Also, I noticed that the empty map isn't cater= ed for:

    <= div>println Date[:] // as per above, might be expected to be the same as ne= w Date([:]) or new Date()
// currently NPE:= Cannot get property '{}' on null object

=
So, the map isn't found and the expression becomes "println D= ate" which returns void and then we convert the map to a String and lo= ok for that property.

I realise this is a weird ed= ge case but I was thinking of creating an issue to fix this for consistency= (just Groovy 3). We already support this:

def map =3D [:]
println Date[*:map]

Let me know if you= have other thoughts.


Cheers, Paul.=

--0000000000008f25bd0574ff18cb--