all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: What is the best way to navigate #ifdef and #endif in C program
Date: Fri, 06 Aug 2010 01:46:26 +0200	[thread overview]
Message-ID: <87zkx0vd0t.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: i3f9co$gss$1@news.eternal-september.org

Peter Keller <psilord@cs.wisc.edu> writes:

> In comp.lang.lisp Elena <egarrulo@gmail.com> wrote:
>> On 4 Ago, 17:09, Peter Keller <psil...@cs.wisc.edu> wrote:
>>> Specifically:http://letoverlambda.com/index.cl/guest/chap5.html#sec_4
>>>
>>> Would show you how to write a macro such that it adds Scheme's tail call
>>> optimized "named let" into Common Lisp. ?This goes beyond the concept
>>> of syntactic sugar and enters the domain of pure code transformation.
>> 
>> Indeed, code transformation is what sets CL's macros apart. However,
>> TCO is much more than that. Read here:
>> 
>> http://stackoverflow.com/questions/2181852/tail-call-elimination-in-clojure
>
> After reading that, I assert that I don't know how to take base CL
> and make it tail recursive since redefining things like defun and
> whatnot lead to package lock errors. Even things like define-compiler-macro
> can't redefine any of the CL macros or functions.
>
> One probably could have success if they created forms like defun-tco,
> labels-tco, flet-tco, etc which kept track of their code expansions
> and rewrote them to be tco. But at that point you've implemented a
> tco enforced lisp dialect on top of CL.

It is almost trivial to provide a package (possibly even named
"COMMON-LISP") which is like the "COMMON-LISP" package, but that is
not the implementation's "COMMON-LISP" package.

See for example:
http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/

The trick is in defining a defpackage form such as:

(defmacro defpackage (name &rest options)
  `(cl:defpackage ,name
     ,@(mapcar
        (lambda (option)
          (if (listp option)
              (case (first option)
                ((:use) 
                 (substitute "IBCL" "COMMON-LISP"
                             (substitute "IBCL" "CL" option)))
                ((:shadowing-import-from :import-from)
                 (if (member (string (second option))
                             '("CL" "COMMON-LISP")
                             :test (function string=))
                     (list* (first option)
                            "IBCL"
                            (cddr option))
                     option))
                (otherwise option))))
        options)))

where you substitute the "COMMON-LISP" package for your own.  (You
also need to define your own reader and loader, but these components
are available too).


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


  reply	other threads:[~2010-08-05 23:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-03  0:31 What is the best way to navigate #ifdef and #endif in C program Daniel (Youngwhan)
2010-08-04  4:45 ` [OT] " Fren Zeee
2010-08-04 10:27   ` Pascal J. Bourguignon
2010-08-04 10:38     ` Alessio Stalla
2010-08-04 11:57       ` Pascal J. Bourguignon
2010-08-04 14:37     ` Elena
2010-08-04 14:59       ` Arzobispo Andante
2010-08-04 15:09       ` Peter Keller
2010-08-04 15:35         ` Peter Keller
2010-08-05 19:04         ` Elena
2010-08-05 21:10           ` Peter Keller
2010-08-05 23:46             ` Pascal J. Bourguignon [this message]
     [not found]           ` <8c27aoFij2U1@mid.individual.net>
2010-08-06 11:17             ` Elena
2010-08-06 13:55               ` Pascal J. Bourguignon
2010-08-04 16:20   ` Elena
2010-08-04 16:23   ` Elena
2010-08-05 18:00   ` Emmy Noether
2010-08-06  4:59   ` [OT] " Aaron W. Hsu
2010-08-05 17:30 ` Johan Bockgård
2010-08-06 17:03 ` Alan Mackenzie

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

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

  git send-email \
    --in-reply-to=87zkx0vd0t.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.