From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109607 invoked by alias); 1 Nov 2018 10:21:22 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 109516 invoked by uid 89); 1 Nov 2018 10:21:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-6.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Ideas, D*com=c2, H*c:alternative, online?= X-HELO: mail-it1-f178.google.com Received: from mail-it1-f178.google.com (HELO mail-it1-f178.google.com) (209.85.166.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Nov 2018 10:21:19 +0000 Received: by mail-it1-f178.google.com with SMTP id m15so1324572itl.4 for ; Thu, 01 Nov 2018 03:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WtHOvdlV/ezwtZK7+5DcnMue7t2cScCcd7MxGxH8GLI=; b=OsdCyam8iK7Y2C+2gnPagSvaUhbkK3mpJEeyK4P0IKYxh1UcMlskgxVcLKJMuQPtB5 fIcrvHCn9dGOEG2v26lbWaRYGq+gQG7m7EWdLU8fh3/kvc4PB/Ba1CuiQ3cTzRj4xM68 2AY92cUzFhmJPGFUvLgwo387flVIjYuYZfQHaN8fFNgf/yhyVcIsmNdEvkSLuzvMWUwn 559qvbOG3034q82xNXtuMUNn19TzdQI775xtL6zxiTIw8jFwhjRxeAv+3Z1NK6Lvx9/l BJy/lXzoDs/P9a6eGgMkcc79ocaoku4DQJtCi/0mPhbl3AB/6C4sOdEhlBCxjDDpT+cN oAqg== MIME-Version: 1.0 References: <1301.1540979293@vpaur.eip10.org> <43f199d7-e2e8-ecf3-726f-c0ddc6965f39@bothner.com> <57543c7a-11fa-a0ce-9b07-bcc5c4243b9c@bothner.com> In-Reply-To: <57543c7a-11fa-a0ce-9b07-bcc5c4243b9c@bothner.com> From: Arie van Wingerden Date: Thu, 01 Nov 2018 10:21:00 -0000 Message-ID: Subject: Re: JavaFX unexpected warning To: Per Bothner Cc: kawa@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-q4/txt/msg00020.txt.bz2 Hi Per, thanks for this effort. At the moment it is of course not a real problem, if I only can get around it. But it would be a nice "to have" thing. You created a *very* nice product :-) /Arie Op do 1 nov. 2018 om 06:33 schreef Per Bothner : > On 10/31/18 10:23 AM, Per Bothner wrote: > > This could be fixed if we implemented an optimization which sets the > 'button' > > variable before we set its fields. This has a big advantage in that it > enables > > building self-referential data structures more easily, as well as data > structures that > > mutually reference each other. It would have the side-effect of fixing > this mini-bug. > > > > I've thought into doing the above optimization, but I don't remember how > far I got. > > (There are lot of old corners in Kawa.) > > > > Anyway, I'm looking into it. > > It looks like more work than I want to spend right now, but I came up with > an approach that I think makes sense. I wrote it up in the "Ideas and > tasks for > contributing to Kawa" section (in the git version of the manual but not > yet online): > > > 3.6.1 Recusively initialized data structures > -------------------------------------------- > (GSoC) > > Kawa has convenient syntax to *note allocate and initialize objects: > Allocating objects, but it gets messier it you want to initialize > multiple objects that reference each other. Likewise for a single > object =E2=80=9Ctree=E2=80=9D which contains links to the root. In this = example, we > will looks at two vectors, but the feature is more useful for tree > structures. Assume: > (define-constant list1 [1 2 list2]) > (define-constant list2 ['a 'b list1]) > The compiler translates this to: > (define-constant list1 > (let ((t (object[] length: 3))) ;; allocate native Java array > (set! (t 0) 1) > (set! (t 1) 2) > (set! (t 2) list2) > (FVector:makeConstant t))) > (define-constant list2 > (let ((t (object[] length: 3))) ;; allocate native Java array > (set! (t 0) 'a) > (set! (t 1) 'b) > (set! (t 2) list1) > (FVector:makeConstant t))) > The problem is that =E2=80=98list2=E2=80=99 has not been created when= we evaluate the > initializing expression for =E2=80=98list=E2=80=99. > > We can solve the problem by re-writing: > (define-private tmp1 (object[] length: 3)) > (define-constant list1 (FVector:makeConstant tmp1) > (define-private tmp2 (object[] length: 3)) > (define-constant list2 (FVector:makeConstant tmp2) > (set! (tmp1 0) 1) > (set! (tmp1 1) 2) > (set! (tmp1 2) list2) > (set! (tmp2 0) 1) > (set! (tmp2 1) 2) > (set! (tmp2 2) list1) > > The complication is that the code for re-writing vector and object > constructors is spread out (depending on the result type), and not where > we deal with initializing the variables. One solution is to introduce > an inlineable helper function =E2=80=98$build$=E2=80=99 defined as: > (define ($build$ raw-value create init) > (let ((result (create raw-value)) > (init raw-value result) > result)) > Then we can re-write the above code to: > (define-constant list1 > ($build$ > (object[] length: 3) > (lambda (raw) (FVector:makeConstant raw)) > (lambda (raw result) > ($init-raw-array$ raw 1 2 list2)))) > (define-constant list2 > ($build$ > (object[] length: 3) > (lambda (raw) (FVector:makeConstant raw)) > (lambda (raw result) > ($init-raw-array$ raw 'a 'b list1)))) > Note that the call to =E2=80=98$build$=E2=80=99, as well as the gener= ated =E2=80=98lambda=E2=80=99 > expressions, are all easily inlineable. > > Now assume if at the top-level BODY if there is a sequence of > =E2=80=98define-constant=E2=80=99 definitions initialized with calls to = =E2=80=98$build$=E2=80=99. Now > it is relatively easy to move all the =E2=80=98init=E2=80=99 calls after = all =E2=80=98alloc=E2=80=99 and > =E2=80=98create=E2=80=99 expressions. The =E2=80=98$init-raw-array$=E2= =80=99 calls are expanded after > the code has been re-ordered. > > The project includes both implementing the above framework, as well > as updating type-specific (and default) object creation to use the > framework. It would also be good to have compiler warnings if accessing > an uninitialized object. > > > > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ >