Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ADC0817A2F for ; Wed, 2 Dec 2015 08:16:37 +0000 (UTC) Received: (qmail 77827 invoked by uid 500); 2 Dec 2015 08:16:32 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 77791 invoked by uid 500); 2 Dec 2015 08:16:32 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 77781 invoked by uid 99); 2 Dec 2015 08:16:32 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2015 08:16:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 148A51A0AB1 for ; Wed, 2 Dec 2015 08:16:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id FWv4B7zAeEPa for ; Wed, 2 Dec 2015 08:16:31 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 50E89204DE for ; Wed, 2 Dec 2015 08:16:30 +0000 (UTC) Received: by lffu14 with SMTP id u14so40469796lff.1 for ; Wed, 02 Dec 2015 00:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=E5ip+iNTm2BuFVqUskNDDiFlnLSU7tay93+RHwQodE0=; b=TsTLiuBIGanUiU2MQmdO+GdruyaFK/qzL2GCYNjzj1RKqoCsHOfETRnLrriB19AzAq 1j3M4QKxPhIWpvSOu+IpzI/CNChJsqe9zeIdHTBhVzXjqN+YbpnLefjiG3KWBDwtAj2m 54pYks9hrmeMkUKTqrL2oEjSnaMftwkFZ1wgz5ZAmzTzJsoyQXQplKU3xvGOMaK2Y2cu o4E4WOPctNHdXFPz/c3zwWR9lxtgvbM9gp9ashhzzKiMk/SEjPVHouMSYoPiq/mhbbHt +3P9JgyOSOQNbqXw/Qj9xDlkx2UieFgeubiwTFKPRDBuWrsWSSQDiNZ05Jl48gAwJV4L OemQ== MIME-Version: 1.0 X-Received: by 10.25.135.195 with SMTP id j186mr1074896lfd.141.1449044189684; Wed, 02 Dec 2015 00:16:29 -0800 (PST) Received: by 10.112.169.8 with HTTP; Wed, 2 Dec 2015 00:16:29 -0800 (PST) In-Reply-To: References: <565E1F9F.1090704@gmx.org> <565E2D14.2050709@gmx.org> Date: Wed, 2 Dec 2015 09:16:29 +0100 Message-ID: Subject: Re: "External" closures, why? From: =?UTF-8?Q?C=C3=A9dric_Champeau?= To: users@groovy.apache.org Content-Type: multipart/alternative; boundary=001a113fad5230a95e0525e5e47f --001a113fad5230a95e0525e5e47f Content-Type: text/plain; charset=UTF-8 I don't think any discussion that is centered around this topic of being possible to put the closure out of the parens will ever bring anything. Groovy had it for a long time, and it's one of the main things that make it suitable for human readable DSLs. Just compare the readability of builders. If we had to write: html({ head({ title('Damn ugly' )}) body({ div([class:'main'], { p('foo') }) }) }) instead of what we can do today: html { head { title 'Groovy' } body { div(class: 'main') { p 'foo' } } } No doubt I would never have chosen Groovy to build DSLs. 2015-12-02 1:14 GMT+01:00 alessio : > > > > yes > > Thanks. > > > > > the problem simply is that while(x, {doSomething()}) looks quite ugly ;) > > It absolutely does, agreed (but then all these inlined functions do in > most languages :) ). > Nonetheless, while visually maybe not appealing, I'd argue it makes > semantically more sense to have it in that place than "suddenly" > outside of the function call. > > And yes, I understood that the regular way is still possible, my > "complaint" was rather about this additional alternative, which really > left me staring at the screen for a good while today (possibly > similarly as when I discovered Angular's insanity of using the > argument names for dependency injection - different subject though). > > Anyhow, thanks for having taken the time to explain the details. > > > > > if ultimate means last argument, then yes ;) > > It does :) > Thanks for the clarification. > > So, just for yet another better understanding, whenever there is a > code block (-> closure) after a function call, it automatically gets > appended as additional argument? > --001a113fad5230a95e0525e5e47f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I don't think any discussion that is centered around t= his topic of being possible to put the closure out of the parens will ever = bring anything. Groovy had it for a long time, and it's one of the main= things that make it suitable for human readable DSLs. Just compare the rea= dability of builders. If we had to write:

html({=C2=A0
=C2=A0 =C2=A0head({ title('Damn ugly' )})
=C2=A0= =C2=A0body({
=C2=A0 =C2=A0 =C2=A0 div([class:'main'], { = p('foo') })
=C2=A0 =C2=A0})
})

instead of what we can do today:

html {
=C2=A0 =C2=A0 head { title 'Groovy' }
=C2=A0 =C2= =A0 body {
=C2=A0 =C2=A0 =C2=A0 =C2=A0div(class: 'main') = { p 'foo' }
=C2=A0 =C2=A0 }
}

No doubt I would never have chosen Groovy to build DSLs.

2015-12-02 1:14 = GMT+01:00 alessio <alessino@gmail.com>:
>
> yes

Thanks.

>
> the problem simply is that while(x, {doSomething()}) looks quite ugly = ;)

It absolutely does, agreed (but then all these inlined functions do = in
most languages :) ).
Nonetheless, while visually maybe not appealing, I'd argue it makes
semantically more sense to have it in that place than "suddenly"<= br> outside of the function call.

And yes, I understood that the regular way is still possible, my
"complaint" was rather about this additional alternative, which r= eally
left me staring at the screen for a good while today (possibly
similarly as when I discovered Angular's insanity of using the
argument names for dependency injection - different subject though).

Anyhow, thanks for having taken the time to explain the details.

>
> if ultimate means last argument, then yes ;)

It does :)
Thanks for the clarification.

So, just for yet another better understanding, whenever there is a
code block (-> closure) after a function call, it automatically gets
appended as additional argument?

--001a113fad5230a95e0525e5e47f--