From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Chris K. Jester-Young" Newsgroups: gmane.lisp.guile.devel Subject: SRFI 9's default printer doesn't handle cyclic data structures Date: Mon, 25 Jul 2011 23:33:59 -0400 Message-ID: <20110726033359.GA15555@yarrow.destinee.acro.gen.nz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="d6Gm4EdcadzBjdND" X-Trace: dough.gmane.org 1311651338 4685 80.91.229.12 (26 Jul 2011 03:35:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 26 Jul 2011 03:35:38 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jul 26 05:35:34 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QlYQg-0003A3-2C for guile-devel@m.gmane.org; Tue, 26 Jul 2011 05:35:34 +0200 Original-Received: from localhost ([::1]:43185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlYQf-0004xX-Bc for guile-devel@m.gmane.org; Mon, 25 Jul 2011 23:35:33 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlYQd-0004xH-9N for guile-devel@gnu.org; Mon, 25 Jul 2011 23:35:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QlYQc-0002cr-A7 for guile-devel@gnu.org; Mon, 25 Jul 2011 23:35:31 -0400 Original-Received: from mail-yx0-f169.google.com ([209.85.213.169]:52813) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QlYQc-0002ce-7c for guile-devel@gnu.org; Mon, 25 Jul 2011 23:35:30 -0400 Original-Received: by yxn22 with SMTP id 22so18320yxn.0 for ; Mon, 25 Jul 2011 20:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:user-agent; bh=yHlAadQLTGs/7YmzLxI9jv9U2IFaZ2KN02foEoTUyXE=; b=ZUsLz0AKkdMpKdMrFy9NcghLznfTwQvkBWJy3PBV3oRVJZkNHd6L++fkSyAdPWkHJk qiL1EH+7k1NWqfIZHBF35DEel5wBdvIvfe94Efq8ylOgAAn3StS8wLT4DlI3m2xAv/9g ISp0gqqS2UzW0n44JU/Eb97FZjsPPd9NroYys= Original-Received: by 10.101.18.7 with SMTP id v7mr4631485ani.64.1311651329084; Mon, 25 Jul 2011 20:35:29 -0700 (PDT) Original-Received: from yarrow.destinee.acro.gen.nz (cpe-076-182-054-128.nc.res.rr.com [76.182.54.128]) by mx.google.com with ESMTPS id v9sm47232anv.30.2011.07.25.20.35.28 (version=SSLv3 cipher=OTHER); Mon, 25 Jul 2011 20:35:28 -0700 (PDT) Mail-Followup-To: guile-devel@gnu.org Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.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:12682 Archived-At: --d6Gm4EdcadzBjdND Content-Type: text/plain; charset=us-ascii Content-Disposition: inline [Crossposted from bug-guile@ since my message isn't posting there. :-(] Hi there, I've been playing around with Guile's implementation of SRFI 45 (which uses SRFI 9), and have noticed something interesting: if you run the following code in the REPL, printing out the value of the promise will cause a stack overflow: (use-modules (srfi srfi-45)) (define promise (delay promise)) (force promise) #> For reproducibility, I attached the diff to make SRFI 45 use Guile native records. So, it seems like SRFI 9's record printer doesn't handle cycles in the record data very well. Unfortunately I don't know how to fix this (I tried looking at the printer for Guile's native records, but couldn't figure out what made it special enough to handle cycles correctly), so no fix is attached. Many thanks, Chris. --d6Gm4EdcadzBjdND Content-Type: text/x-diff; charset=us-ascii Content-Disposition: inline; filename="srfi-45.diff" --- module/srfi/srfi-45.scm 2011-02-08 22:38:34.000000000 -0500 +++ module/srfi/srfi-45.scm 2011-07-23 20:24:51.000000000 -0400 @@ -37,15 +37,21 @@ lazy force eager) - #:replace (delay force) - #:use-module (srfi srfi-9)) + #:replace (delay force)) -(define-record-type promise (make-promise val) promise? - (val promise-val promise-val-set!)) +(define (make-record-type "promise" '(val))) +(define make-promise (record-constructor )) +(define promise? (record-predicate )) +(define promise-val (record-accessor 'val)) +(define promise-val-set! (record-modifier 'val)) -(define-record-type value (make-value tag proc) value? - (tag value-tag value-tag-set!) - (proc value-proc value-proc-set!)) +(define (make-record-type "value" '(tag proc))) +(define make-value (record-constructor )) +(define value? (record-predicate )) +(define value-tag (record-accessor 'tag)) +(define value-tag-set! (record-modifier 'tag)) +(define value-proc (record-accessor 'proc)) +(define value-proc-set! (record-modifier 'proc)) (define-syntax lazy (syntax-rules () --d6Gm4EdcadzBjdND--