unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Ian Price <ianprice90@googlemail.com>
To: Jordy Dickinson <jordy.dickinson@gmail.com>
Cc: 15691@debbugs.gnu.org
Subject: bug#15691: ,br doesn't work for generic functions
Date: Thu, 24 Oct 2013 05:53:12 +0100	[thread overview]
Message-ID: <877gd3xoav.fsf@Kagami.home> (raw)
In-Reply-To: <CAHRGAYuwbViMVNJ=9NwrR4aZDcJgXDUYFe4PKr28jKdEOrL8eA@mail.gmail.com> (Jordy Dickinson's message of "Wed, 23 Oct 2013 01:51:25 -0400")

[-- Attachment #1: Type: text/plain, Size: 1876 bytes --]


Jordy Dickinson <jordy.dickinson@gmail.com> writes:

> # What I expected:
>
> I wasn't sure what to expect, given that generic functions can have
> many implementations, but since there was no error and a "generic"
> object appeared in the output of ",traps", I expected at least that
> when _some_ initialize method was called I would be put into a
> debugging prompt.

Indeed, there are two reasonable behaviours here.

1. We stop before method specialisation in the "top level" of the
function returned by (procedure <some-generic>). This is the behaviour I
would expect for an arbitrary applicable struct.

2. We stop after method specialisation. This requires goops specific
hackery, but is probably more helpful if we could pull it off.

>
> # What actually happened:
>
> When I called a function that called the initialize method ("make" in
> this particular case), it completed successfully, without any debug
> prompt.

The reason this happens is that in the procedure `frame-matcher' in
(system vm traps), it tests for the equivalence of the procedure passed
in, with the procedure in the frame with eq?. In the first instance, the
procedure is an applicable struct, the latter however is the function
returned by (procedure that-applicable-struct).

We could either fix this a bit further up the stack, by making sure that
we extract the procedure from applicable structs, we could extract it
in `frame-matcher'.

I think `frame-matcher' is the right place to fix this, rather than
further up the stack. Various procedures in (system vm traps) are
documented as taking a procedure, which IMO should include applicable
structs.

I've attached a patch which handles this, implementing behaviour (1)
above.

-- 
Ian Price -- shift-reset.com

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"


[-- Attachment #2: ,br fix --]
[-- Type: #("text/x-patch" 2 3 (face ido-hacks-flex-match) 7 8 (face ido-hacks-flex-match) 8 9 (face ido-hacks-flex-match) 9 10 (face ido-hacks-flex-match) 10 11 (face ido-hacks-flex-match)), Size: 1703 bytes --]

From 3a117b22b10c9577868fd22f88d1cad2e2ec32a0 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Thu, 24 Oct 2013 05:51:47 +0100
Subject: [PATCH] Fix trap handlers to handle applicable structs.

Reported by Jordy Dickinson <jordy.dickinson@gmail.com>.
Fixes <http://bugs.gnu.org/15691>.

* module/system/vm/traps.scm (frame-matcher): Extract procedure when
  proc is an applicable struct.
---
 module/system/vm/traps.scm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/module/system/vm/traps.scm b/module/system/vm/traps.scm
index cccd6ea..b65e034 100644
--- a/module/system/vm/traps.scm
+++ b/module/system/vm/traps.scm
@@ -109,15 +109,18 @@
   ((new-disabled-trap vm enable disable) frame))
 
 (define (frame-matcher proc match-objcode?)
-  (if match-objcode?
-      (lambda (frame)
-        (let ((frame-proc (frame-procedure frame)))
-          (or (eq? frame-proc proc)
-              (and (program? frame-proc)
-                   (eq? (program-objcode frame-proc)
-                        (program-objcode proc))))))
-      (lambda (frame)
-        (eq? (frame-procedure frame) proc))))
+  (let ((proc (if (struct? proc)
+                  (procedure proc)
+                  proc)))
+    (if match-objcode?
+        (lambda (frame)
+          (let ((frame-proc (frame-procedure frame)))
+            (or (eq? frame-proc proc)
+                (and (program? frame-proc)
+                     (eq? (program-objcode frame-proc)
+                          (program-objcode proc))))))
+        (lambda (frame)
+          (eq? (frame-procedure frame) proc)))))
 
 ;; A basic trap, fires when a procedure is called.
 ;;
-- 
1.7.11.7


  reply	other threads:[~2013-10-24  4:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23  5:51 bug#15691: ,br doesn't work for generic functions Jordy Dickinson
2013-10-24  4:53 ` Ian Price [this message]
2013-10-24  4:59   ` Ian Price
2014-01-09  4:07     ` Ian Price

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gd3xoav.fsf@Kagami.home \
    --to=ianprice90@googlemail.com \
    --cc=15691@debbugs.gnu.org \
    --cc=jordy.dickinson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).