From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Issac Trotts" Newsgroups: gmane.lisp.guile.user Subject: Re: Guile Introspection Date: Sat, 7 Jul 2007 17:18:08 -0700 Message-ID: References: <266326.97925.qm@web37913.mail.mud.yahoo.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1260196502==" X-Trace: sea.gmane.org 1183861168 31905 80.91.229.12 (8 Jul 2007 02:19:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 Jul 2007 02:19:28 +0000 (UTC) Cc: Guile User To: "Mike Gran" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 08 04:19:25 2007 connect(): Connection refused 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.50) id 1I7MMr-0001ib-8B for guile-user@m.gmane.org; Sun, 08 Jul 2007 04:19:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I7MMq-0001HL-Ik for guile-user@m.gmane.org; Sat, 07 Jul 2007 22:19:20 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I7KTd-0008Ow-GF for guile-user@gnu.org; Sat, 07 Jul 2007 20:18:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I7KTd-0008Od-0D for guile-user@gnu.org; Sat, 07 Jul 2007 20:18:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I7KTc-0008OW-Gm for guile-user@gnu.org; Sat, 07 Jul 2007 20:18:12 -0400 Original-Received: from wa-out-1112.google.com ([209.85.146.179]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I7KTc-00060Z-1q for guile-user@gnu.org; Sat, 07 Jul 2007 20:18:12 -0400 Original-Received: by wa-out-1112.google.com with SMTP id k34so781308wah for ; Sat, 07 Jul 2007 17:18:08 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=UNPj0sfKuKL6xvyjrFXMyI/g4djEva5IXxl2mJv+VRVWKuOqrTcjtr5yJw9AtmymfhJ8BRYbW1lgAt8xOBDaxxK8fVb/w0YkXj33OLBysILeCx/XpFrikgHk/Qh9j05XeLiAsmRGtXjQ/GZ5FtHfaVPPE48j3S0O3PyL/7S8tnI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=eoAjcLuujQnZESlfE0zXqWs5V5/ymh59x8A7y9jWAc6r43nIu3s69jj0sQnOeEtBYgg//6us2VEml90BsgP+Ijq53rBu5dJLkiNV707R7fhOUtQVF+zFaXGPMygAADOV04LvTVVSpYO25PiwHmMXrO/fvwFaVJigh3xqgANdNUE= Original-Received: by 10.115.60.1 with SMTP id n1mr1890460wak.1183853888269; Sat, 07 Jul 2007 17:18:08 -0700 (PDT) Original-Received: by 10.115.95.17 with HTTP; Sat, 7 Jul 2007 17:18:08 -0700 (PDT) In-Reply-To: <266326.97925.qm@web37913.mail.mud.yahoo.com> X-detected-kernel: Linux 2.6 (newer, 2) X-Mailman-Approved-At: Sat, 07 Jul 2007 22:19:16 -0400 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:6026 Archived-At: --===============1260196502== Content-Type: multipart/alternative; boundary="----=_Part_146875_18822580.1183853888250" ------=_Part_146875_18822580.1183853888250 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/7/07, Mike Gran wrote: > > Hi- > > Is it possible to get introspection information out of Guile > (preferably without having to load GOOPS)? > > For example, how can I write a function that prints its own name? You can define a macro to make this happen: (defmacro define-named (name-and-args . body) (let ((name (car name-and-args)) (args (cdr name-and-args))) `(define (,name ,@args) (let ((--function-- ',name)) ,@body)))) Here is an example of how to use it, analogous to using __FUNCTION__ in gcc: (define-named (some-fun) (display --function--) (newline)) Or, what is the scheme version of the following C code > > printf("%s %d\n", __FILE__, __LINE__); I don't know if there's a way to do this in Guile. Issac ------=_Part_146875_18822580.1183853888250 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/7/07, Mike Gran <spk121@yahoo.com> wrote:
Hi-

Is it possible to get introspection information out of Guile
(preferably without having to load GOOPS)?

For example, how can I write a function that prints its own name?

You can define a macro to make this happen:

(defmacro define-named (name-and-args . body)
  (let ((name (car name-and-args))
        (args (cdr name-and-args)))
    `(define (,name ,@args)
      (let ((--function-- ',name))
        ,@body))))

Here is an example of how to use it, analogous to using __FUNCTION__ in gcc:

(define-named (some-fun)
  (display --function--)
  (newline))

Or, what is the scheme version of the following C code

printf("%s %d\n", __FILE__, __LINE__);

I don't know if there's a way to do this in Guile.

Issac

------=_Part_146875_18822580.1183853888250-- --===============1260196502== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user --===============1260196502==--