From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#24102: Use guile variable objects as SRFI-111 boxes. Date: Fri, 05 Aug 2016 00:31:39 -0400 Message-ID: <87a8grygyc.fsf@netris.org> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1470371604 15592 195.159.176.226 (5 Aug 2016 04:33:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 5 Aug 2016 04:33:24 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: 24102@debbugs.gnu.org To: "Glenn Michaels" Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Aug 05 06:33:20 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVWov-00039J-Db for guile-bugs@m.gmane.org; Fri, 05 Aug 2016 06:33:17 +0200 Original-Received: from localhost ([::1]:42742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVWos-0002tc-35 for guile-bugs@m.gmane.org; Fri, 05 Aug 2016 00:33:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVWom-0002q8-Po for bug-guile@gnu.org; Fri, 05 Aug 2016 00:33:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVWog-0006gj-SQ for bug-guile@gnu.org; Fri, 05 Aug 2016 00:33:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVWog-0006gd-PB for bug-guile@gnu.org; Fri, 05 Aug 2016 00:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bVWog-0002Cq-Hw for bug-guile@gnu.org; Fri, 05 Aug 2016 00:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 05 Aug 2016 04:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24102 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch Original-Received: via spool by 24102-submit@debbugs.gnu.org id=B24102.14703715248401 (code B ref 24102); Fri, 05 Aug 2016 04:33:02 +0000 Original-Received: (at 24102) by debbugs.gnu.org; 5 Aug 2016 04:32:04 +0000 Original-Received: from localhost ([127.0.0.1]:56024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVWnk-0002BR-CH for submit@debbugs.gnu.org; Fri, 05 Aug 2016 00:32:04 -0400 Original-Received: from world.peace.net ([50.252.239.5]:42122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bVWng-0002At-Vk for 24102@debbugs.gnu.org; Fri, 05 Aug 2016 00:32:02 -0400 Original-Received: from pool-71-174-42-86.bstnma.east.verizon.net ([71.174.42.86] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bVWna-0002au-Ot; Fri, 05 Aug 2016 00:31:54 -0400 In-Reply-To: (Glenn Michaels's message of "Fri, 29 Jul 2016 05:21:53 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8331 Archived-At: Hi Glenn, "Glenn Michaels" writes: > Currently, guile's (srfi srfi-111) module ("mutable boxes") provides > an implementation based on records with a single value field. > > Wouldn't it make more sense to re-export the functions make-variable, > variable?, variable-ref and variable-set! from the guile core as box, > box?, unbox and set-box! respectively? > > These functions have the same signatures and the same semantics as > required by the SRFI-111 spec., and they appear to be significantly > faster than the current record-based implementation. > > Moreover, SRFI-111 boxes and guile variable objects are clearly > semantically the same thing. Unfortunately, they are not quite the same thing. Unlike SRFI-111 boxes, Guile variables are a union type: they contain an arbitrary Scheme value, *or* they may be "unbound". For such a simple data type, this added complication is semantically quite significant. As a result, some important properties of SRFI-111 boxes do not hold for your proposed implementation. For example, in SRFI-111, (box? x) implies that (box-ref x) will not raise an exception, and this fact can be exploited by a compiler to produce better native code for 'box-ref' when the type of its argument is known to be a box. In such cases, I guess 'box-ref' can be implemented as a single load instruction, whereas 'variable-ref' will require a conditional branch. Especially for such a simple and fundamental data type, I think it's important to retain precisely the specified semantics, without *any* additional complexity. For this reason, I am opposed to this change. What do you think? Regards, Mark