all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (require 'cl) problem
@ 2004-09-23 16:24 It's me FKtPp ;)
  2004-09-23 18:08 ` Jesper Harder
  2004-09-23 20:49 ` Pascal Bourguignon
  0 siblings, 2 replies; 13+ messages in thread
From: It's me FKtPp ;) @ 2004-09-23 16:24 UTC (permalink / raw



The Emacs Lisp Programing Standard said:
,----
| 
|    * Please don't require the `cl' package of Common Lisp extensions at
|      run time.  Use of this package is optional, and it is not part of
|      the standard Emacs namespace.  If your package loads `cl' at run
|      time, that could cause name clashes for users who don't use that
|      package.
| 
|      However, there is no problem with using the `cl' package at compile
|      time, for the sake of macros.  You do that like this:
| 
|           (eval-when-compile (require 'cl))
`----

But when i test this piece of code (byte-compile and restart emacs and
load the elc)

,----[ test.el ]
| ;; just want to test cl
| 
| ;;; Code:
| 
| (eval-when-compile (require 'cl))
| 
| (defun fktpp-test-case ()
|   "test cl library"
|   (interactive)
|   (message (if (oddp 22)
| 	       "yes it's odd"
| 	     "no it isn't")))
| 
| (provide 'test)
| ;;; test.el ends here
`----

it always tell me the symbol oddp didn't defined. why ? Is there any
thing illegal in my code?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-23 16:24 (require 'cl) problem It's me FKtPp ;)
@ 2004-09-23 18:08 ` Jesper Harder
  2004-09-24  4:58   ` It's me FKtPp ;)
  2004-09-23 20:49 ` Pascal Bourguignon
  1 sibling, 1 reply; 13+ messages in thread
From: Jesper Harder @ 2004-09-23 18:08 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

> |      However, there is no problem with using the `cl' package at
> |      compile time, for the sake of macros.
                                       ^^^^^^
> But when i test this piece of code (byte-compile and restart emacs
> and load the elc) it always tell me the symbol oddp didn't
> defined. why ?

The magic word is "macros".  `oddp' is a function not a macro.

-- 
Jesper Harder                                <http://purl.org/harder/>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-23 16:24 (require 'cl) problem It's me FKtPp ;)
  2004-09-23 18:08 ` Jesper Harder
@ 2004-09-23 20:49 ` Pascal Bourguignon
  1 sibling, 0 replies; 13+ messages in thread
From: Pascal Bourguignon @ 2004-09-23 20:49 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

> The Emacs Lisp Programing Standard said:
> ,----
> | 
> |    * Please don't require the `cl' package of Common Lisp extensions at
> |      run time.  Use of this package is optional, and it is not part of
> |      the standard Emacs namespace.  If your package loads `cl' at run
> |      time, that could cause name clashes for users who don't use that
> |      package.
> | 
> |      However, there is no problem with using the `cl' package at compile
> |      time, for the sake of macros.  You do that like this:
> | 
> |           (eval-when-compile (require 'cl))
> `----

This should only apply to emacs sources themselves!  Not to your user
code.  You are free to use common-lisp.
 
> But when i test this piece of code (byte-compile and restart emacs and
> load the elc)
> 
> ,----[ test.el ]
> | ;; just want to test cl
> | 
> | ;;; Code:
> | 
> | (eval-when-compile (require 'cl))
> | 
> | (defun fktpp-test-case ()
> |   "test cl library"
> |   (interactive)
> |   (message (if (oddp 22)
> | 	       "yes it's odd"
> | 	     "no it isn't")))
> | 
> | (provide 'test)
> | ;;; test.el ends here
> `----
> 
> it always tell me the symbol oddp didn't defined. why ? Is there any
> thing illegal in my code?

Nothing illegal, but use (require 'cl) instead of (eval-when-compile
(require 'cl)), or even better, forget emacs and use true Common-Lisp
and the Hemlock editor! ;-)

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

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-23 18:08 ` Jesper Harder
@ 2004-09-24  4:58   ` It's me FKtPp ;)
  2004-09-24  6:40     ` Pascal Bourguignon
                       ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: It's me FKtPp ;) @ 2004-09-24  4:58 UTC (permalink / raw


Jesper Harder <harder@myrealbox.com> writes:

> "It's me FKtPp ;)" <m_pupil@163.com> writes:
> 
> > |      However, there is no problem with using the `cl' package at
> > |      compile time, for the sake of macros.
>                                        ^^^^^^
> > But when i test this piece of code (byte-compile and restart emacs
> > and load the elc) it always tell me the symbol oddp didn't
> > defined. why ?
> 
> The magic word is "macros".  `oddp' is a function not a macro.

Then, if I want load this function, but don't want to (require
'cl). what should I do?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  4:58   ` It's me FKtPp ;)
@ 2004-09-24  6:40     ` Pascal Bourguignon
  2004-09-24  6:47       ` David Kastrup
  2004-09-24  8:01     ` John Paul Wallington
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Pascal Bourguignon @ 2004-09-24  6:40 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

> Jesper Harder <harder@myrealbox.com> writes:
> 
> > "It's me FKtPp ;)" <m_pupil@163.com> writes:
> > 
> > > |      However, there is no problem with using the `cl' package at
> > > |      compile time, for the sake of macros.
> >                                        ^^^^^^
> > > But when i test this piece of code (byte-compile and restart emacs
> > > and load the elc) it always tell me the symbol oddp didn't
> > > defined. why ?
> > 
> > The magic word is "macros".  `oddp' is a function not a macro.
> 
> Then, if I want load this function, but don't want to (require
> 'cl). what should I do?

Concentrate and pray very strongly until a miracle occurs and oddp
becomes defined without loading the file cl.el where it's declared.

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

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  6:40     ` Pascal Bourguignon
@ 2004-09-24  6:47       ` David Kastrup
  2004-09-24 10:00         ` It's me FKtPp ;)
  0 siblings, 1 reply; 13+ messages in thread
From: David Kastrup @ 2004-09-24  6:47 UTC (permalink / raw


Pascal Bourguignon <spam@mouse-potato.com> writes:

> "It's me FKtPp ;)" <m_pupil@163.com> writes:
>
>> Jesper Harder <harder@myrealbox.com> writes:
>> 
>> > "It's me FKtPp ;)" <m_pupil@163.com> writes:
>> > 
>> > > |      However, there is no problem with using the `cl' package at
>> > > |      compile time, for the sake of macros.
>> >                                        ^^^^^^
>> > > But when i test this piece of code (byte-compile and restart emacs
>> > > and load the elc) it always tell me the symbol oddp didn't
>> > > defined. why ?
>> > 
>> > The magic word is "macros".  `oddp' is a function not a macro.
>> 
>> Then, if I want load this function, but don't want to (require
>> 'cl). what should I do?
>
> Concentrate and pray very strongly until a miracle occurs and oddp
> becomes defined without loading the file cl.el where it's declared.

(defsubst oddp (x) (/= 0 (mod x 2)))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  4:58   ` It's me FKtPp ;)
  2004-09-24  6:40     ` Pascal Bourguignon
@ 2004-09-24  8:01     ` John Paul Wallington
  2004-09-24 10:02       ` It's me FKtPp ;)
  2004-09-24 13:16     ` Barry Margolin
  2004-09-24 17:27     ` Stefan Monnier
  3 siblings, 1 reply; 13+ messages in thread
From: John Paul Wallington @ 2004-09-24  8:01 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

>> The magic word is "macros".  `oddp' is a function not a macro.
>
> Then, if I want load this function, but don't want to (require
> 'cl). what should I do?

If you want to use such functions at compile-time you can define them
as inline functions (see `defsubst') or define a companion compiler
macro (see `define-compiler-macro' in cl-macs).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  6:47       ` David Kastrup
@ 2004-09-24 10:00         ` It's me FKtPp ;)
  2004-09-24 11:49           ` Pascal Bourguignon
  0 siblings, 1 reply; 13+ messages in thread
From: It's me FKtPp ;) @ 2004-09-24 10:00 UTC (permalink / raw


David Kastrup <dak@gnu.org> writes:

> Pascal Bourguignon <spam@mouse-potato.com> writes:
> 

[...]

> >> Then, if I want load this function, but don't want to (require
> >> 'cl). what should I do?
> >
> > Concentrate and pray very strongly until a miracle occurs and oddp
> > becomes defined without loading the file cl.el where it's declared.
> 
> (defsubst oddp (x) (/= 0 (mod x 2)))

Thank you. But I'm not sure if there are any other *functions* (not
macros) were used in the program -_-

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  8:01     ` John Paul Wallington
@ 2004-09-24 10:02       ` It's me FKtPp ;)
  2004-09-24 11:53         ` Pascal Bourguignon
  0 siblings, 1 reply; 13+ messages in thread
From: It's me FKtPp ;) @ 2004-09-24 10:02 UTC (permalink / raw


John Paul Wallington <jpw@gnu.org> writes:

> "It's me FKtPp ;)" <m_pupil@163.com> writes:
> 
> >> The magic word is "macros".  `oddp' is a function not a macro.
> >
> > Then, if I want load this function, but don't want to (require
> > 'cl). what should I do?
> 
> If you want to use such functions at compile-time you can define them
> as inline functions (see `defsubst') or define a companion compiler
> macro (see `define-compiler-macro' in cl-macs).

thanks, but I think I will need them at run-time. :P

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24 10:00         ` It's me FKtPp ;)
@ 2004-09-24 11:49           ` Pascal Bourguignon
  0 siblings, 0 replies; 13+ messages in thread
From: Pascal Bourguignon @ 2004-09-24 11:49 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

> David Kastrup <dak@gnu.org> writes:
> 
> > Pascal Bourguignon <spam@mouse-potato.com> writes:
> > 
> 
> [...]
> 
> > >> Then, if I want load this function, but don't want to (require
> > >> 'cl). what should I do?
> > >
> > > Concentrate and pray very strongly until a miracle occurs and oddp
> > > becomes defined without loading the file cl.el where it's declared.
> > 
> > (defsubst oddp (x) (/= 0 (mod x 2)))
> 
> Thank you. But I'm not sure if there are any other *functions* (not
> macros) were used in the program -_-

Yes, that why you should really consider my proposed solution:

Concentrate very very stronlgy, and pray very very fervently, until a
miracle occurs and oddp becomes defined without loading the file cl.el
where it's declared.

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

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24 10:02       ` It's me FKtPp ;)
@ 2004-09-24 11:53         ` Pascal Bourguignon
  0 siblings, 0 replies; 13+ messages in thread
From: Pascal Bourguignon @ 2004-09-24 11:53 UTC (permalink / raw


"It's me FKtPp ;)" <m_pupil@163.com> writes:

> John Paul Wallington <jpw@gnu.org> writes:
> 
> > "It's me FKtPp ;)" <m_pupil@163.com> writes:
> > 
> > >> The magic word is "macros".  `oddp' is a function not a macro.
> > >
> > > Then, if I want load this function, but don't want to (require
> > > 'cl). what should I do?
> > 
> > If you want to use such functions at compile-time you can define them
> > as inline functions (see `defsubst') or define a companion compiler
> > macro (see `define-compiler-macro' in cl-macs).
> 
> thanks, but I think I will need them at run-time. :P

Ok. I'll give you some emacs lisp:

    (while (not (fboundp 'oddp))
        (concentrate :how-strong '(very very strong))
        (pray :deity "God"
              :how-fervently '( very very fervently)
              :pledge "Please, may oddp be known to thy servant."))

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

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  4:58   ` It's me FKtPp ;)
  2004-09-24  6:40     ` Pascal Bourguignon
  2004-09-24  8:01     ` John Paul Wallington
@ 2004-09-24 13:16     ` Barry Margolin
  2004-09-24 17:27     ` Stefan Monnier
  3 siblings, 0 replies; 13+ messages in thread
From: Barry Margolin @ 2004-09-24 13:16 UTC (permalink / raw


In article <uisa46z6v.fsf@163.com>,
 "It's me FKtPp ;)" <m_pupil@163.com> wrote:

> Jesper Harder <harder@myrealbox.com> writes:
> 
> > "It's me FKtPp ;)" <m_pupil@163.com> writes:
> > 
> > > |      However, there is no problem with using the `cl' package at
> > > |      compile time, for the sake of macros.
> >                                        ^^^^^^
> > > But when i test this piece of code (byte-compile and restart emacs
> > > and load the elc) it always tell me the symbol oddp didn't
> > > defined. why ?
> > 
> > The magic word is "macros".  `oddp' is a function not a macro.
> 
> Then, if I want load this function, but don't want to (require
> 'cl). what should I do?

Either copy the function definitions out of cl.el, or ignore the advice 
in the manual.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: (require 'cl) problem
  2004-09-24  4:58   ` It's me FKtPp ;)
                       ` (2 preceding siblings ...)
  2004-09-24 13:16     ` Barry Margolin
@ 2004-09-24 17:27     ` Stefan Monnier
  3 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2004-09-24 17:27 UTC (permalink / raw


> Then, if I want load this function, but don't want to (require
> 'cl). what should I do?

Reconsider the premises.  E.g. you probably want to ignore the advice in the
manual, unless you intend to submit your code for inclusion as part
of Emacs.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-09-24 17:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-23 16:24 (require 'cl) problem It's me FKtPp ;)
2004-09-23 18:08 ` Jesper Harder
2004-09-24  4:58   ` It's me FKtPp ;)
2004-09-24  6:40     ` Pascal Bourguignon
2004-09-24  6:47       ` David Kastrup
2004-09-24 10:00         ` It's me FKtPp ;)
2004-09-24 11:49           ` Pascal Bourguignon
2004-09-24  8:01     ` John Paul Wallington
2004-09-24 10:02       ` It's me FKtPp ;)
2004-09-24 11:53         ` Pascal Bourguignon
2004-09-24 13:16     ` Barry Margolin
2004-09-24 17:27     ` Stefan Monnier
2004-09-23 20:49 ` Pascal Bourguignon

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.