From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.user Subject: Re: Pure (side-effect-free) calls into c/c++? Date: Sat, 11 Jan 2020 22:32:24 -0600 Message-ID: References: Reply-To: linasvepstas@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="80264"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Guile User To: Taylan Kammer Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jan 12 05:34:58 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iqUvk-0014gF-Nb for guile-user@m.gmane-mx.org; Sun, 12 Jan 2020 05:32:52 +0100 Original-Received: from localhost ([::1]:35148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iqUvj-0000zd-1T for guile-user@m.gmane-mx.org; Sat, 11 Jan 2020 23:32:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57250) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iqUvX-0000yM-1Z for guile-user@gnu.org; Sat, 11 Jan 2020 23:32:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iqUvV-0007DI-QN for guile-user@gnu.org; Sat, 11 Jan 2020 23:32:38 -0500 Original-Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:46895) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iqUvV-00076Z-Fh for guile-user@gnu.org; Sat, 11 Jan 2020 23:32:37 -0500 Original-Received: by mail-lj1-x22f.google.com with SMTP id m26so6328963ljc.13 for ; Sat, 11 Jan 2020 20:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=aPK4EyJD8raYdk8b4Q8jwf/kwrWh+j/4yqztjE3ygxQ=; b=XYdYU/5Eng+B/tS/g+fOyqyLpvbnI3lvX+9c51usggm6KCbkOb6NQp05OQzH+Upj8T QVKb5ck+PblwW3dWNsN+2FmiBxKtLbqGiveYZFiq278TvIHNW8gCpY02gALwbH6GENqK QiPlIbb+iwcCaZbgHc12Gc7vA6DIXr68ehncJJjfaPO9PenOaxsvP9ghNeXwuyqkIuED 3vqJloB3DGwMPBqC2wWvVWjGeiVz6NmtQ7+1ipl1A3peW6QZepcdRQbBv2zO7IGZ2DmK cKDIKO4cB8MWsWkGB9niEBTQKbxUMzb91dXQdYMCtcSIbuDZznY2T0iEh5UBHi3mQ1ei Wc5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=aPK4EyJD8raYdk8b4Q8jwf/kwrWh+j/4yqztjE3ygxQ=; b=dNcpkmfCoIiUQgqrYDIAGlehGmw2dr24V/SBzQUfMpv0RjN0eWnPFCTbhpKAzAA7ZQ uHE9yMDOn3wB5PdcTZEiapTcxkVmbB7cVVbZmDod0m4yR9cRHYc+UYYdBe1tAFNHrJnK dKSn+h1EyXr3SjXcC3W18HZKq3a2igQQO/q7YRNDHc+yA7KYY3VgThFL6zduQW8repIx 46NOWLQhdq1p8IFz/kqZ2vFGoc4XYneaGNmI50pGdxFa/NXr+4bjKFWNAwVotF/IlPSr ExE32QXtcMaD2BenynpPcqmmVL2X2qqPUcrn2kqNS7xFwPiVyQhCz8z8cGUfXSTpgMF7 FpOg== X-Gm-Message-State: APjAAAVmsKWItYeolnE/fRixOJvh5PT2kkqivpI4/MEWQg/kojXVHr6m qFjPQOVO2wIDjWpsgGSiAeGh2UJX2ya3jMeuOn4= X-Google-Smtp-Source: APXvYqwPNgPNGM7wxoaqp+cRlpidfAiz4VaDNtXfcWUoWl9lBp1DBcObe60ZH6V1KstAChE1HRbIRp3kfUNfYn1bavg= X-Received: by 2002:a2e:81d0:: with SMTP id s16mr7069784ljg.166.1578803556027; Sat, 11 Jan 2020 20:32:36 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22f X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:16040 Archived-At: Hi Taylan, Our emails are crossing in the ether... On Sat, Jan 11, 2020 at 9:21 PM Taylan Kammer wrote: > > It might be possible to create a sort of "compile-time memoization" Yes, that's what I'm looking for... So the following: > > (display (f-memo 42)) > (display (f-memo 66)) > (display (f-memo 42)) > (display (f-memo 66)) > > would magically emit code like: > > (define _x1 (f 42)) > (define _x2 (f 66)) > (display _x1) > (display _x2) > (display _x1) > (display _x2) > > But I'm not sure how I'd write that hypothetical f-memo macro. > Well, how about a simpler case, then: an incrementing counter? (define-syntax incr (syntax-rules () ((incr) ... something??? ...))) so that (display (incr)) (display (incr)) (display (incr)) emits (define _x1 1) (display _x1) (define _x2 2) (display _x2) (define _x3 3) (display _x3) The hard part, from what I can tell, is making the macro stateful, (or continuable, or whatever you want to call it), to have it remember where it last left off with the counter. I presume that emitting the defines "shouldn't be that hard", just some kind of string pasting with the stateful macro state. -- Linas -- cassette tapes - analog TV - film cameras - you