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 00834200B97 for ; Sun, 9 Oct 2016 15:53:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F357F160ADA; Sun, 9 Oct 2016 13:53:33 +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 6AE3D160AC3 for ; Sun, 9 Oct 2016 15:53:33 +0200 (CEST) Received: (qmail 90927 invoked by uid 500); 9 Oct 2016 13:53:32 -0000 Mailing-List: contact notifications-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 notifications@groovy.apache.org Received: (qmail 90918 invoked by uid 99); 9 Oct 2016 13:53:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Oct 2016 13:53:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 43374DFB78; Sun, 9 Oct 2016 13:53:32 +0000 (UTC) From: mariogarcia To: notifications@groovy.apache.org Reply-To: notifications@groovy.apache.org References: In-Reply-To: Subject: [GitHub] groovy pull request #439: WIP Add groovy-macro docs Content-Type: text/plain Message-Id: <20161009135332.43374DFB78@git1-us-west.apache.org> Date: Sun, 9 Oct 2016 13:53:32 +0000 (UTC) archived-at: Sun, 09 Oct 2016 13:53:34 -0000 Github user mariogarcia commented on a diff in the pull request: https://github.com/apache/groovy/pull/439#discussion_r82522775 --- Diff: src/spec/doc/core-metaprogramming.adoc --- @@ -2829,6 +2829,153 @@ to use the Groovy Console, in particular the AST browser tool, to gain knowledge resource for learning is the https://github.com/apache/groovy/tree/master/src/test/org/codehaus/groovy/ast/builder[AST Builder] test suite. +==== Macros + +===== Introduction + +Until version 2.5.0, when developing AST transformations, developers should have a deep knowledge about how the AST +(Abstract source tree) was built by the compiler in order to know how to add new expressions or statements during +compile time. + +Although the use of `org.codehaus.groovy.ast.tool.GeneralUtils` static methods could mitigate the burden of creating +expressions and statements, it's still a low-level way of writing those AST nodes directly. +We needed something to abstract us from writing the AST directly and that's exactly what Groovy macros were made for. +They allow you to add code during compile time directly, without having translate the code you had in mind to the --- End diff -- :+1: --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---