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 433AE2004F5 for ; Fri, 1 Sep 2017 18:35:35 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 400B016CE8F; Fri, 1 Sep 2017 16:35:35 +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 5FF7016CE35 for ; Fri, 1 Sep 2017 18:35:34 +0200 (CEST) Received: (qmail 21710 invoked by uid 500); 1 Sep 2017 16:35:33 -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 21695 invoked by uid 99); 1 Sep 2017 16:35:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Sep 2017 16:35: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 D6B181A17C7 for ; Fri, 1 Sep 2017 16:35:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.48 X-Spam-Level: ** X-Spam-Status: No, score=2.48 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, 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-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id nSDCZqSwnGzj for ; Fri, 1 Sep 2017 16:35:30 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id B80E060D14 for ; Fri, 1 Sep 2017 16:35:29 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id z12so2677118lfd.3 for ; Fri, 01 Sep 2017 09:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=nx2YqeWLHyJ2kGP82Qf2/5yr4W4D7g7EzYE+nUJQEf4=; b=oqjqfUINdr6yutFRExrB2R8AHU1Bjqj6I+iY1U3msuXbgI9vr/XYZ/aF/8yCAFwZ/w WEotX+vpj0GkPgWLv2t8TAe5y1dAN8zJtm9TpE+hGItuTnnHgARhNj+vIDEga5CNRPzS /iRKuvdtV8IXFQZZQo/zkUPRC1uvV+Dm3vR1xDlJF6ZWbn1CNFz7gZKJfElU5c2/tQd+ Rscj6KGZNomxcfcVGYfHdytQka8IJYCzs8k/TlTUt2J/HECouJpGKiN1CgDwmB+NpQnR tULT+q2jYO/Cqw6JFhFZZVGNRFyKdH/ho4rtEKEG6nY/v4rDMPHecFIjvyB70yLGn7nX 2nuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=nx2YqeWLHyJ2kGP82Qf2/5yr4W4D7g7EzYE+nUJQEf4=; b=Ub19FCUU6nlxL4WliJ84JzFBE3Ot3NAF2Hs+mqVCcl5v2uAosniS8xiNzdgrpq9QA5 5msJOvFeMxdDmsUL9fyuhSUnMcEgfX7uvFwSx/7Cs674W/Eo6aS7QyfJBfBw1pbjuHOe 791kFAjyuZzjndg+FMB6m45iJoZARU8pkNN52a5KFidi8BDRVYTlOIV6t/Fgj1wCqKYZ fjiTnld7OqX05rkTItrrnj2TzEsjrPfJBBkhjaNjlWBZ3di2QiM59K83QesNveZITr+L TqVeMlUZH05H1gHSakEgV1tdMKHJYJGnglX++N8Yx2lZpl2nR4TTuUM8OWgawyLnfgY4 p2bw== X-Gm-Message-State: AHPjjUhnW6wCv03AVZHiWdeW3+VMlq4f6Ne/c6qPhOVLgIWF12Tv77iQ evgRIK6Hi6r0PWs/d2UwlBs/JWbbDA== X-Google-Smtp-Source: ADKCNb4KVYi2CYTn9SD2kt2OmvUdcODbq9FoH4KwHSshijCh1HOA8F8v9Ye7p4tYr0Uf2GCqOoTMQEExKV2M+LuZeCQ= X-Received: by 10.25.15.228 with SMTP id 97mr983299lfp.248.1504283728928; Fri, 01 Sep 2017 09:35:28 -0700 (PDT) MIME-Version: 1.0 Sender: rjohnson.uiuc@gmail.com Received: by 10.25.33.140 with HTTP; Fri, 1 Sep 2017 09:35:28 -0700 (PDT) From: Ralph Johnson Date: Fri, 1 Sep 2017 11:35:28 -0500 X-Google-Sender-Auth: zg7gxwGFTA7vR4xZg6JH-CVy9f8 Message-ID: Subject: recursive calls on Script object? To: users@groovy.apache.org Content-Type: multipart/alternative; boundary="001a113fbbdc4de6af0558235969" archived-at: Fri, 01 Sep 2017 16:35:35 -0000 --001a113fbbdc4de6af0558235969 Content-Type: text/plain; charset="UTF-8" I've been extending a system that is mainly in Groovy. It has a database that includes thousands of scripts, each of which gets turned into a Script object. Most are very small, but a few are large. Often one script calls another. In fact, the call hierarchy of scripts can get pretty deep. There is nothing to prevent these scripts from being recursive, though I don't think any are. I ran into a problem where bindings were being reused inappropriately, and it made me study Scripts in more detail. It looks to me like a script that calls itself recursively will reuse the original binding. That is because you set the binding with setBinding and then just use the existing binding when you call evaluate(). I would prefer a design in which you would pass in the binding to evaluate() so that a script could call itself recursively or you could have two concurrent evaluations of a script in different threads. Now, it is possible that recursion works fine on Scripts. I haven't tested it. Perhaps the execution of a Script clones the relevant info including the binding and changing the binding during the execution of a Script will have no effect on the Script. I couldn't find any documentation that said anything about this. I will do some experiments, but it will be a lot of work because I have to change some things in our system before I can use it for the experiments. So, I thought I would ask here first. I tried cloning a Script. I know that compiling a Script creates a subclass of Script and the result is a unique instance of that class. I imagined that the instance held the binding and used it as a delegate. I figured we could clone the Script instance, set a new binding, and all would be well. However, Scripts don't seem to like to be cloned. If Scripts don't like to call themselves recursively, is there any way to make a copy so each call can be to a unique instance? -Ralph Johnson --001a113fbbdc4de6af0558235969 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've been extending a system that is mainly in Groovy.= =C2=A0 It has a database that includes thousands of scripts, each of which= gets turned into a Script object.=C2=A0 Most are very small, but a few are= large.=C2=A0 Often one script calls another.=C2=A0 In fact, the call hiera= rchy of scripts can get pretty deep.=C2=A0 There is nothing to prevent thes= e scripts from being recursive, though I don't think any are.

<= /div>
I ran into a problem where bindings were being reused inappropria= tely, and it made me study Scripts in more detail. =C2=A0 It looks to me li= ke a script that calls itself recursively will reuse the original binding.= =C2=A0 That is because you set the binding with setBinding and then just us= e the existing binding when you call evaluate(). =C2=A0 I would prefer a de= sign in which you would pass in the binding to evaluate() so that a script = could call itself recursively or you could have two concurrent evaluations = of a script in different threads.

Now, it is possi= ble that recursion works fine on Scripts. =C2=A0 I haven't tested it.= =C2=A0 Perhaps the execution of a Script clones the relevant info including= the binding and changing the binding during the execution of a Script will= have no effect on the Script. =C2=A0 I couldn't find any documentation= that said anything about this.=C2=A0 I will do some experiments, but it wi= ll be a lot of work because I have to change some things in our system befo= re I can use it for the experiments.=C2=A0 So, I thought I would ask here f= irst.

I tried cloning a Script. =C2=A0 I know that= compiling a Script creates a subclass of Script and the result is a unique= instance of that class. =C2=A0 I imagined that the instance held the bindi= ng and used it as a delegate.=C2=A0 I figured we could clone the Script ins= tance, set a new binding, and all would be well. =C2=A0 However, Scripts do= n't seem to like to be cloned. =C2=A0 If Scripts don't like to call= themselves recursively, is there any way to make a copy so each call can b= e to a unique instance?

-Ralph Johnson
--001a113fbbdc4de6af0558235969--