From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tristan Colgate Newsgroups: gmane.lisp.guile.user Subject: Re: Does anyone have an applicable struct example Date: Mon, 28 Jun 2010 11:06:16 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1277719590 24138 80.91.229.12 (28 Jun 2010 10:06:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Jun 2010 10:06:30 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 28 12:06:29 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 1OTBES-0005lT-Bc for guile-user@m.gmane.org; Mon, 28 Jun 2010 12:06:28 +0200 Original-Received: from localhost ([127.0.0.1]:34177 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTBER-0000Hd-Sy for guile-user@m.gmane.org; Mon, 28 Jun 2010 06:06:27 -0400 Original-Received: from [140.186.70.92] (port=57462 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTBEK-0000Gi-Df for guile-user@gnu.org; Mon, 28 Jun 2010 06:06:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTBEJ-0006OF-00 for guile-user@gnu.org; Mon, 28 Jun 2010 06:06:20 -0400 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:42348) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTBEI-0006O7-Qz for guile-user@gnu.org; Mon, 28 Jun 2010 06:06:18 -0400 Original-Received: by wyb39 with SMTP id 39so3295539wyb.0 for ; Mon, 28 Jun 2010 03:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=rJd7oANptPHNca5mLffUKcOYhfNPXoZiXzOjsaz/Azs=; b=cCsRXt2JMFjH5yBBW3pS4E0wHslaJcHbM4lUT7+7GKeeW/800l7e0QMpLlm65XfSR6 Y5pLLvqiVWyCiE/lHngKEG1u6TljnCB3OCOpwYrcE8aVX/TukpXf+a1QifjMM/nrvMRH JSuhH5VgjeoqRUK5nh59e8gnkOCwy1cCbcrpk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=vvlo8+x911gB9/58naHxeHcxx2bKr/EJhq3MJTGk2A0MgTwuP93pquzAxdVehp5QK4 V0U5kkQ7gKsEM6cenahjOEdtUXHV/toIXSW1z0BCBDLp7SK1JfuoWFrXyvUDplsLSAqB VyWFvwAlqSwHcphhFLj6NQSH/+wEmh56mPreE= Original-Received: by 10.216.85.74 with SMTP id t52mr3464478wee.99.1277719577067; Mon, 28 Jun 2010 03:06:17 -0700 (PDT) Original-Received: by 10.216.154.6 with HTTP; Mon, 28 Jun 2010 03:06:16 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:7929 Archived-At: I've had a further play and read around the source, and got things working via goops atleast (still not sure how to use the applicable structs directly). The following code works.... (define-class () (a)) (make ) (slot-set! $1 'procedure (lambda()(...))) ($1) (slot-set! $1 'a 1) etc... This plays nice with write and display method overrides too (which is what I was after). On 25 June 2010 10:14, Tristan Colgate wrote: > Hi all, > > =A0I'd like to make use of the applicable structs feature but am > running into problems. > > From what I can gather from the release note that mentions it, the > following should work, > instead, I get a segfault. > > scheme@(guile-user)> (define (make-struct > 0)) > scheme@(guile-user)> (define mything (make-struct 0 > (lambda()(display "some code")(newline)))) > Segmentation fault (core dumped) > > Looking around goops.scm I can see some classes for applicable structs > that look a bit nicer, but these seem > to use set-object-procedure! which isn't exported (and I can't find a > definition).... > > scheme@(guile-user)> (use-modules (oop goops)) > scheme@(guile-user)> (define-class ()) > scheme@(guile-user)> (make #:procedure (lambda()(display > "some code")(nelwine))) > :5:58: warning: possibly unbound variable `nelwine' > Throw to key `unbound-variable': > ERROR: In procedure module-lookup: > ERROR: Unbound variable: set-object-procedure! > > I tried using a generic instead but it didn't make much difference. > > What am I doing wrong? > > -- > Tristan Colgate-McFarlane > ---- > =A0"You can get all your daily vitamins from 52 pints of guiness, and a > glass of milk" > --=20 Tristan Colgate-McFarlane ---- "You can get all your daily vitamins from 52 pints of guiness, and a glass of milk"