From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: Special variables to relax boxing Date: Sat, 23 Mar 2013 19:31:10 +0100 Message-ID: References: <3101921.Ei70kTLzB2@warperdoze> <87wqt19ts2.fsf@tines.lan> <87d2usa845.fsf@tines.lan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1364063479 15073 80.91.229.3 (23 Mar 2013 18:31:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Mar 2013 18:31:19 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Mar 23 19:31:43 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UJTED-0005p6-Vk for guile-devel@m.gmane.org; Sat, 23 Mar 2013 19:31:42 +0100 Original-Received: from localhost ([::1]:37220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJTDq-0007Hb-7Q for guile-devel@m.gmane.org; Sat, 23 Mar 2013 14:31:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJTDk-0007HW-SV for guile-devel@gnu.org; Sat, 23 Mar 2013 14:31:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJTDj-00076k-Ul for guile-devel@gnu.org; Sat, 23 Mar 2013 14:31:12 -0400 Original-Received: from mail-pa0-f50.google.com ([209.85.220.50]:33970) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJTDj-00076e-NU for guile-devel@gnu.org; Sat, 23 Mar 2013 14:31:11 -0400 Original-Received: by mail-pa0-f50.google.com with SMTP id bg2so410506pad.23 for ; Sat, 23 Mar 2013 11:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=PF85LmkE0kZprJrMhz9671igkzbUteyHzRa6Vpr+2Gg=; b=oQO4ogfeQOmNKd6fPJnBUvnEhE/ZizGSKsyPaLu2tpowaM+aa1nsvNpo7wDzHPoTch +Zj9ISMSj5Ij6t4AcS5QbOw7fIgS+Mc7zKpiOsq9riQ4mJr9Bki3ApPdKAdZVGoXvk4R fGbBLPI0i8YyndZ8t7qvBfs5yk4TqndR0GUlj0AE3zZ9dG8sYLYZ7te8P1FccTxuj/6S oUqQ8lA1Rd65oO3B6SHpE5902VPBDoZXcxYAdMvvGpTPK9T4hq/5wmhSfI92u6OtJke8 rsD28wu7ilHWUtrRbFGlvOqxoRAHhdv2iWtsGnCDgZr2H/NEiUvSBILcfCpvXZayoQmv /iLg== X-Received: by 10.68.49.167 with SMTP id v7mr8918705pbn.131.1364063470866; Sat, 23 Mar 2013 11:31:10 -0700 (PDT) Original-Received: by 10.70.45.8 with HTTP; Sat, 23 Mar 2013 11:31:10 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.50 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:15983 Archived-At: There are some bugs in the semantics. I try to fix them here Consider * k, the r5rs continuation * dynamic-wind, r5rs dynamic wind with the addition that continuation k is an argument to the rewinder. Introduce (with-special ((a:id kind:object) ...) code ...) and (set~ a:id v:obj) Introduce (special-set! i k value) (special-ref i k) A setter and a getter of an object indexed by i and k Also define (guard-special? k kind) That index an object on k, wich depedning on kind ask to restore the value of the old saved state. Let (make-id) generate a unique object Then the semantic for with-special in guard mode would be (let ((last #f) (i (make-id))) (dynamic-wind (lambda (k) (set! last #f) (when (guard-special? k kind) (set! a (special-ref i k)))) (lambda () (call-with-values (lambda () (begin code ...)) (lambda ret (set! last #t) (apply values ret)))) (lambda (k . l) (unless last (special-set! i k a)))) Guard mode is entered only if a is referenced with set~ and never with set! if it can be proved Otherwise guard mode is never entered. The semantics of set~ is the same as with set! otherwise. if with-special is not in guard-mode then it behaves just as (let () code ....) Hope that I don't spam the list but guile is a cooperative effort. /Stefan