From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Re: Adding Identities to Peval Date: Thu, 16 Feb 2012 21:22:02 -0500 Message-ID: References: <87mx8jjf0s.fsf@pobox.com> <87hayqkecl.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1329445332 12906 80.91.229.3 (17 Feb 2012 02:22:12 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 17 Feb 2012 02:22:12 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Feb 17 03:22:09 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RyDSa-0005oX-8s for guile-devel@m.gmane.org; Fri, 17 Feb 2012 03:22:08 +0100 Original-Received: from localhost ([::1]:58127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyDSZ-0000wC-GK for guile-devel@m.gmane.org; Thu, 16 Feb 2012 21:22:07 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyDSW-0000w7-Ho for guile-devel@gnu.org; Thu, 16 Feb 2012 21:22:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RyDSV-0005ku-BK for guile-devel@gnu.org; Thu, 16 Feb 2012 21:22:04 -0500 Original-Received: from mail-tul01m020-f169.google.com ([209.85.214.169]:49022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RyDSV-0005kq-89 for guile-devel@gnu.org; Thu, 16 Feb 2012 21:22:03 -0500 Original-Received: by obbta7 with SMTP id ta7so4732862obb.0 for ; Thu, 16 Feb 2012 18:22:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=8Xyl86Bj4wGHypF/sUyrHy8svXbzGS4ya+9CfZmiGpI=; b=aDjsTD5JT8m7ScRUgtbdhzLRLLSwPrD5Rew1esE+fv2DjRANlZEGS+H8/U8X4JuHqM gZS3eUAvGk12KawZhCXRJ2/6X43LtT2aykZ5MQ7yNMQzeptSqLRutlALipM2DTAT0sc6 Hcbg+5GU+z2QNQi/nI0f1u60H91TxmSATIkNU= Original-Received: by 10.50.57.234 with SMTP id l10mr6310913igq.12.1329445322277; Thu, 16 Feb 2012 18:22:02 -0800 (PST) Original-Received: by 10.42.142.7 with HTTP; Thu, 16 Feb 2012 18:22:02 -0800 (PST) In-Reply-To: <87hayqkecl.fsf@pobox.com> X-Google-Sender-Auth: zkq8-OYWCICgw4606HTXiB3lavQ X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.169 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13880 Archived-At: Hello, On Thu, Feb 16, 2012 at 10:06 AM, Andy Wingo wrote: > On Thu 16 Feb 2012 14:18, Noah Lavine writes: > >>> =A0(let ((x (random))) >>> =A0 =A0(eq? x x)) >> >> (let* ((x (random)) >> =A0 =A0 =A0 =A0(y (list x)) >> =A0 =A0 =A0 =A0(z (car y)) >> =A0 (eq? x z)) > > This one should reduce to the same thing, but currently doesn't because > (list x) is not considered a "constant expression" because `let' is a > "constructor" (quotes to indicate the language of peval). =A0If we can > propagate it (probably true in this case, given that it has only one > use), then the expression folds as before: > > =A0(let* ((x (random)) > =A0 =A0 =A0 =A0 (z (car (list x)))) > =A0 =A0(eq? x z)) > =A0=3D> > =A0(let ((x-129 (random))) > =A0 =A0(eq? x-129 x-129))) > > So I don't think that for this purpose (identity) we need any more > mechanism So you're saying that the gensym that comes from psyntax should essentially be the identity marker, because there is one gensym for each value. To make sure I understand, in the x-y-z example, psyntax would produce different gensyms for x and z, but peval could merge them later on, right? In that case, peval would maintain the invariant "if two values must always be the same, they have the same gensym". Correct? This seems just a good as what I implemented. I am happy with either way. >> In order to type-check, you need to be able to associate extra >> information with a value (its type) even in cases where you don't know >> the value. > > For this purpose, have you considered creating a functional database of > facts? =A0Then you can add facts when you see conditionals, for example, > and you get different facts in the different branches. > > =A0(if test consequent alternate) > =A0;; assuming the test doesn't fold > =A0=3D> (make-if (for-test test current-facts) > =A0 =A0 =A0 =A0 =A0 =A0 =A0(for-tail consequent (add-fact test #t current= -facts)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0(for-tail consequent (add-fact test #f current= -facts))) This is an interesting idea, and I hadn't really considered it. I had certainly planned to let the information associated with values change as the environment changes, which would let it use conditional and nonlocal-exit information. But a database goes beyond that. The big difference is that a database could express relationships between values - if information is associated with a value, where does the information x < y go? This makes me think that a database is a long-term solution. However, if you're not expressing relationships, then I think the functional database would just amount to keeping an environment mapping value names to information about them. I hadn't thought this through when I made my post, but I realize that this is what I would have to do to let my information-about-values change over time. So three paragraphs later, I think we agree :-). However, what I'd really like to do is use an IR that expresses control flow, as you say below. > This is related to range analysis. =A0But, it's also something that's > easier to do with an explicit notion of control flow (i.e. a CPS IR). Yes, I think you're right. I would be very interested in working on a CPS IR, but I remember you had a blog post a couple months ago where you said you weren't sure if CPS or ANF was better for Guile. What do you think about intermediate representations now? Noah