From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Re: Does anyone have an applicable struct example Date: Sun, 29 Aug 2010 11:48:33 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1283107532 19507 80.91.229.12 (29 Aug 2010 18:45:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 29 Aug 2010 18:45:32 +0000 (UTC) Cc: guile-user@gnu.org To: Tristan Colgate Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 29 20:45:31 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Opmsj-0005hr-2E for guile-user@m.gmane.org; Sun, 29 Aug 2010 20:45:29 +0200 Original-Received: from localhost ([127.0.0.1]:34124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Opmsi-0001Ws-Jd for guile-user@m.gmane.org; Sun, 29 Aug 2010 14:45:28 -0400 Original-Received: from [140.186.70.92] (port=43145 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Opmsd-0001WQ-F1 for guile-user@gnu.org; Sun, 29 Aug 2010 14:45:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Opmsc-0000ah-5u for guile-user@gnu.org; Sun, 29 Aug 2010 14:45:23 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:44531 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Opmsc-0000aY-27 for guile-user@gnu.org; Sun, 29 Aug 2010 14:45:22 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 66997D1F8F; Sun, 29 Aug 2010 14:45:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=XboVUaPy9OODZ6XUU5pDYxXwE5Y=; b=bQ4bmu RTNOVZ7GX0K6i4+fSxd2l/fO1ZAI9VWQQMGv35JC1aMV8aNa2UPAjUU1XRyArjSD jMM2byKp3UHNirTBbq0Sa9ZWHysCQgKalU+took2lpvJbnPhTjNmkDHczJSLfgF8 Ue1tVmTQza/qBVYWWPDYkdmz7UA4fQxiI2NRU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=YUi6JtuYme63/UqvenFvRpGlqxBQkE0T DHIAwhUYGIpeBFqmB9Uo6MaKCugcTIogqcrujsAzeP7pc25lVUfpG09p9DZ19+h2 E0HNv1qtNI8OTZpyBctc3Nn7rg2cBQkV5BLDuR9dbKvETaNTtjULWJCk7GDzS82I 1fQo/46vm8U= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 50DFCD1F8E; Sun, 29 Aug 2010 14:45:19 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [75.28.21.123]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id B2582D1F8C; Sun, 29 Aug 2010 14:45:17 -0400 (EDT) In-Reply-To: (Tristan Colgate's message of "Fri, 25 Jun 2010 10:14:06 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 9277D0D4-B39D-11DF-9067-030CEE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8116 Archived-At: Hi Tristan, On Fri 25 Jun 2010 02:14, Tristan Colgate writes: > scheme@(guile-user)> (define (make-struct > 0)) > scheme@(guile-user)> (define mything (make-struct 0 > (lambda()(display "some code")(newline)))) > Segmentation fault (core dumped) Thanks for the report. I have fixed Guile so that it now does this: scheme@(guile-user)> (define (make-struct 0)) scheme@(guile-user)> (make-struct 0) :2:1: In procedure struct-vtable?: :2:1: vtable has invalid layout: #f Indeed you didn't specify a layout when making . Try this: scheme@(guile-user)> (define (make-struct 0 'pw)) scheme@(guile-user)> (make-struct 0) $1 = # scheme@(guile-user)> (make-struct 0 (lambda () 10)) $2 = #:4:32 ()>> scheme@(guile-user)> ($2) $3 = 10 You see, 'pw is the "minimum layout" for an applicable struct: scheme@(guile-user)> (define (make-struct 0 'pr)) :1:26: In procedure %inherit-vtable-magic: :1:26: invalid applicable struct layout To add fields you add them after the 'pw. Like 'pwpwpw, for two user fields. This whole thing is very low-level though, and needs proper documentation. It would be nice to clean up the "layout" to not be a symbol, but that's a job... Andy -- http://wingolog.org/