From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Bruce Korb Newsgroups: gmane.lisp.guile.devel Subject: Re: How to detect a procedure Date: Mon, 29 Apr 2002 17:36:13 -0700 Organization: Home Sender: guile-devel-admin@gnu.org Message-ID: <3CCDE6FD.762240DA@pacbell.net> References: <0204291900310F.10649@locke.free-expression.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT X-Trace: main.gmane.org 1020130414 17770 127.0.0.1 (30 Apr 2002 01:33:34 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 30 Apr 2002 01:33:34 +0000 (UTC) Cc: bitwize@wizards-of-source.org, guile-devel@gnu.org Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 172MWL-0004cV-00 for ; Tue, 30 Apr 2002 03:33:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 172MVw-00056G-00; Mon, 29 Apr 2002 21:33:08 -0400 Original-Received: from mta6.snfc21.pbi.net ([206.13.28.240]) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 172MUe-00049x-00 for ; Mon, 29 Apr 2002 21:31:48 -0400 Original-Received: from pacbell.net ([64.170.154.165]) by mta6.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GVC00B82XKZOY@mta6.snfc21.pbi.net> for guile-devel@gnu.org; Mon, 29 Apr 2002 18:31:47 -0700 (PDT) Original-To: Lynn Winebarger X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.4.18 i686) X-Accept-Language: en Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:563 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:563 Lynn Winebarger wrote: > I don't think this captures the spirit of the original question. If you do this, > you rely on the evaluator checking for the existence of the binding - procedure? > gets the actual object (it never sees the name). Or, if the name hasn't been > bound it will error out (if the lookup throws an exception, that might be used). How about adding this procedure. I confess to being uncertain if it actually works, I get lost trying to decipher the maze of macros. SCM_DEFINE (scm_defined_as_p, "defined-as?", 2, 1, 0, (SCM sym, SCM class, SCM env), "Return @code{#t} if @var{sym} is defined of class @var{class} in " "the lexical environment @var{env}. When @var{env} is not " "specified, look in the top-level environment as defined by the " "current module.") #define FUNC_NAME s_scm_defined_as_p { SCM var; SCM_VALIDATE_SYMBOL (1,sym); if (SCM_UNBNDP (env)) var = scm_sym2var (sym, scm_current_module_lookup_closure (), SCM_BOOL_F); else { SCM frames = env; register SCM b; for (; SCM_NIMP (frames); frames = SCM_CDR (frames)) { SCM_ASSERT (SCM_CONSP (frames), env, SCM_ARG2, FUNC_NAME); b = SCM_CAR (frames); if (SCM_NFALSEP (scm_procedure_p (b))) break; SCM_ASSERT (SCM_CONSP (b), env, SCM_ARG2, FUNC_NAME); for (b = SCM_CAR (b); SCM_NIMP (b); b = SCM_CDR (b)) { if (SCM_NCONSP (b)) { if (SCM_EQ_P (b, sym)) return SCM_BOOL_T; else break; } if (SCM_EQ_P (SCM_CAR (b), sym)) return SCM_BOOL_T; } } var = scm_sym2var (sym, SCM_NIMP (frames) ? SCM_CAR (frames) : SCM_BOOL_F, SCM_BOOL_F); } if (SCM_FALSEP (var) || SCM_UNBNDP (SCM_VARIABLE_REF (var))) return SCM_BOOL_F; if (scm_class_of (SCM_VARIABLE_REF (var)) == class) return SCM_BOOL_T; return SCM_BOOL_F; } #undef FUNC_NAME == Bruce Korb AG URL: http://autogen.sourceforge.net _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel