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 989AE200C04 for ; Tue, 24 Jan 2017 14:43:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 97183160B3D; Tue, 24 Jan 2017 13:43:27 +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 DFBA0160B31 for ; Tue, 24 Jan 2017 14:43:26 +0100 (CET) Received: (qmail 17311 invoked by uid 500); 24 Jan 2017 13:43:23 -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 17301 invoked by uid 99); 24 Jan 2017 13:43:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Jan 2017 13:43:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id BCDC0180688 for ; Tue, 24 Jan 2017 13:43:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id LuIUfNzu9RXn for ; Tue, 24 Jan 2017 13:43:21 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 642505F649 for ; Tue, 24 Jan 2017 13:43:21 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id z134so110914821lff.3 for ; Tue, 24 Jan 2017 05:43:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=/iOkJyNKg7PVMGSJiD3FL8NeNwsWv4ACYTbFD4FFB0E=; b=QWSPbd1sBvb7J8w54H8lRsgezyeLi7ySCpgurCbMRVviZpXx1v0FQAJXBqkvNBrd+9 x0Fif6bF05R0AZllz0ZG3KIFsVNdqj+VKqIZfHgZrEdjL5VzVRaPX+1sGwEUUlFb0K1K asf/52N5s47lLely+m1imXjLt9j8rRxUnmC9QJvm0Zz2HiWy8dPm21kGInUz3AV3tADl Ln0DdFSMRC6mWW3KGKtrlezwTgEu3owQlT64gZZ8i7XCNat/1Z99GDBmNFg5N9zbGAL5 mz0pIVdp2KARpAK1MCUBHsRTw7oovGyYhPJxwnEVezdHiLN3NZIJ67gha+cUjx1eUsf2 Gj4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/iOkJyNKg7PVMGSJiD3FL8NeNwsWv4ACYTbFD4FFB0E=; b=bUXl0T/gKfc08kAYFJtG4kuIxTEdT/y6IpldJ/tf+qY0kzwcTxEkrDg2/W1W9fidr4 d934E03dcxLdKckK+3Y+b0DcO+jLVoVzlsa3Fr7aYfM7kiHQ5a+hKthWdYlE+3bemXW2 bju6r3OIl56sUd0nW7mj63WGNTjC1SFbnoLfCfs/AEEDTeLqZpYN1LXry0zSPLAmttrI mFmjLkDJxVyor9D7zQ5bJ16MpT9sNI6uwQG8hi9ExtD5tdTm1Ehg92RRUOhLeXhKvbFp VGzWqeDmai7tQk9mIHtpemGF2qEgX+iBPgaGcFbYqW9HK8mitbY3t825gCtNeUNeZgll 3vUw== X-Gm-Message-State: AIkVDXL5d1vGIWW51wZEgWSG7JNuap1PYoqdVuvINbxHQFxQ0jt3WeUzVEDA2ZeSm+2RHE2fG92/ouRB8yy5aQ== X-Received: by 10.25.145.89 with SMTP id y25mr11449879lfj.102.1485265394003; Tue, 24 Jan 2017 05:43:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.199.131 with HTTP; Tue, 24 Jan 2017 05:43:13 -0800 (PST) From: Joe Wolf Date: Tue, 24 Jan 2017 08:43:13 -0500 Message-ID: Subject: Parrot and the ++ and -- operators To: dev@groovy.apache.org Content-Type: multipart/alternative; boundary=94eb2c1cd53e34f3be0546d74cc0 archived-at: Tue, 24 Jan 2017 13:43:27 -0000 --94eb2c1cd53e34f3be0546d74cc0 Content-Type: text/plain; charset=UTF-8 I accidentally discovered that Groovy 2, in contrast to Java, allows you to apply the ++ and -- operators to the left and right sides of variables simultaneously. int i = 0 ++i++ assert i == 1 and you can also chain them in a single statement provided you apply parens int i = 0 ((i++)++)++ assert i == 1 ++(++(++i)) assert i == 2 ++(++(++i++)++)++ assert i == 3 I can understand allowing the chaining syntax, considering that it's roughly equivalent to next().next().next(), but as far as I reckon, being able to use these operators in such a way has no practical purpose. I haven't tried this code with the Groovy 3 parser yet--I was wondering if it supported the ++ and -- operators similarly. -Joe --94eb2c1cd53e34f3be0546d74cc0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I accidentally discovered that Groovy 2, in contrast to Ja= va, allows you to apply the ++ and -- operators to the left and right sides= of variables simultaneously.

int i =3D 0
++i+= +
assert i =3D=3D 1

and you can also cha= in them in a single statement provided you apply parens

int i =3D 0
((i++)++)++
assert i =3D=3D 1
++(++(++i))
assert i =3D=3D 2
++(++(++i++)++)++=
assert i =3D=3D 3

I can understan= d allowing the chaining syntax, considering that it's roughly equivalen= t to next().next().next(), but as far as I reckon, being able to use these = operators in such a way has no practical purpose.

= I haven't tried this code with the Groovy 3 parser yet--I was wondering= if it supported the ++ and -- operators similarly.

-Joe

--94eb2c1cd53e34f3be0546d74cc0--