From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Thompson, David" Newsgroups: gmane.lisp.guile.user Subject: MOP issues with Date: Fri, 29 Jan 2021 08:29:08 -0500 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32770"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Jan 29 14:35:04 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l5TvU-0008Nv-GV for guile-user@m.gmane-mx.org; Fri, 29 Jan 2021 14:35:04 +0100 Original-Received: from localhost ([::1]:46766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5TvT-0004Z4-EU for guile-user@m.gmane-mx.org; Fri, 29 Jan 2021 08:35:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5Tq4-0000NC-Qi for guile-user@gnu.org; Fri, 29 Jan 2021 08:29:32 -0500 Original-Received: from mail-vk1-xa35.google.com ([2607:f8b0:4864:20::a35]:35851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5Tpx-0001fU-MU for guile-user@gnu.org; Fri, 29 Jan 2021 08:29:27 -0500 Original-Received: by mail-vk1-xa35.google.com with SMTP id d23so2151568vkf.3 for ; Fri, 29 Jan 2021 05:29:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=worcester-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=w2ucIYzs3+VOCPz9HcKYbAmyiXVZISx457F/DMLJQxc=; b=1GCHez6gmwha2FCty7NiJbaEIdVTSHjyeYgjZrEs0WLk9bd9vYAusRw4hQJG6O7uzK 41Oab6gzEHR4ffkk0C3S7TDcAlw1Bi7t6vHQmYqYC3KwX3vr5MHikhnBMhKrv4yAqzPm bDdzr6iOG8hW+8ZkWkCj2VXT7JkIr7b6ItyUmFWp+6xH6tbcTL/szWtnNVwx4RjCv+f/ TnVs1SCipkQj9MxJ0PB1ljVXKs3qVcy5TJS79D9ZDhHucPqKJdPECvmgfGfeJkPk68y8 b0aEc+S3ToVxDs1fMVtDFMS7RB1SjptZvV4uV7ScQ1QREDh8iHMSIDBA6Jbz6bH4DJ3L f1VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=w2ucIYzs3+VOCPz9HcKYbAmyiXVZISx457F/DMLJQxc=; b=BvzqJGx1kAGww/vTuFqxRmVA5igogkbd1q3Ssh3U4IrnZtjm2SFQkZ6WobcfyIHYRs wzQN5XP5oO9hRgDFeWHRnHViGiQKUnvM4T+1iG8vmjSASuKUMT9RPfpa8YrE6m6fw5HQ xvCTU94WfKJHMz3UgW4VZx8MP9Fh14rpmM1E6IOXgCUfrYyb+S4A0tbPE4D0agOgatc7 Z2suPIC1YVowjGYDkrNXfpthv3Pq+HlG7olBwtNRthDYU41xqukaG7L+vhqDvI+4HRYN 8chyD1ZWQNvGoCKc0TceEVRf8CJPMmdalWZvlZFZcgvblhzJ+q43jQ8PlIJo3fGiYMf5 HeVg== X-Gm-Message-State: AOAM532LzSSW31Gt050emgZEAtryvouZjqebtmg+vqwMdSsamVUsfOy6 aReYKzpQKB0GXNGEofdAQAmcSpbhTa6m6K7HJW2mvhspJcYcVw== X-Google-Smtp-Source: ABdhPJyF4VsYMvT76npiUlx6wlYKNpSSrOSKJu7jywbZK6KZq8aLOmcsx/xbIdEHyiAr2iywUhz7V3A+kq/Ptsb3bqU= X-Received: by 2002:a1f:1c4c:: with SMTP id c73mr2848695vkc.22.1611926959413; Fri, 29 Jan 2021 05:29:19 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::a35; envelope-from=dthompson2@worcester.edu; helo=mail-vk1-xa35.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17196 Archived-At: I've been playing around with GOOPS and the metaobject protocol lately. It has been fun, but I've hit a snag with redefinable classes. Here's a contrived example program that demonstrates my problem: (use-modules (oop goops) (srfi srfi-111)) (define-class ()) (define (boxed-slot? slot) (get-keyword #:box? (slot-definition-options slot))) (define-method (compute-getter-method (class ) slot) (if (boxed-slot? slot) (make #:specializers (list class) #:procedure (let ((slot-name (slot-definition-name slot))) (lambda (obj) (unbox (slot-ref obj slot-name))))) (next-method))) (define-method (compute-setter-method (class ) slot) (if (boxed-slot? slot) (make #:specializers (list class ) #:procedure (let ((slot-name (slot-definition-name slot))) (lambda (obj value) (set-box! (slot-ref obj slot-name) value)))) (next-method))) (define-class () (bar #:accessor bar #:box? #t #:init-form (box 123)) #:metaclass ) (define-class () (bar #:accessor bar #:box? #t #:init-form (box 123)) #:metaclass ) ;; This works: (pk (+ (bar (make )) 456)) ;; This throws an error: (pk (+ (bar (make )) 456)) The above code introduces a metaclass, , that supports a special slot option: #:box? The metaclass arranges for boxed slots to be boxed/unboxed transparently via the slot's accessor methods when it detects the presence of #:box? #t in the slot options. However, the redefinable class implementation does a transformation of the slot definitions in its compute-slot method and discards all non-standard slot options, so the final line throws an error because the bar method returns a box, not a number. I see two possibilities: 1) Slots are not designed to be extended with custom options, but it just happens to work in the case of 2) There's a bug in compute-slots for Is this a bug or as-designed? Thanks, - Dave