From: budden
Subject: portable disabling of cl package lock
Date: 
Message-ID: <da59b852-b7f5-4ea9-8305-4fadaa95254e@p20g2000yqi.googlegroups.com>
Hi there!
I'd like to define new macro in cl package silently.
How I'll do that? For now I have:

(
#+sbcl
sb-ext:without-package-locks
#+allegro
excl::without-package-locks
#+lispworks
let
#+lispworks
((lw:*handle-warn-on-redefinition* :warn)
 (*packages-for-warn-on-redefinition* nil))

#-(or allegro lispworks sbcl)
progn

;; reusing cl symbols to avoid interning to cl
(defmacro let1 (variable + &body progn)
  "Shortcut for (let ((a b)) . c) or (destructuring-bind a b . c)"
  (if (atom variable)
      `(let ((,variable ,+)) ,@progn)
    `(destructuring-bind ,variable ,+ ,@progn)))
(export 'let1)
)

What about other implementations?

From: ·············@gmail.com
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <fea03692-f9ea-45a4-8ee5-bdaaf36e6930@p13g2000yqc.googlegroups.com>
On Feb 19, 7:50 pm, budden <···········@mail.ru> wrote:
> Hi there!
> I'd like to define new macro in cl package silently.
> How I'll do that? For now I have:
>
> (
> #+sbcl
> sb-ext:without-package-locks
> #+allegro
> excl::without-package-locks
> #+lispworks
> let
> #+lispworks
> ((lw:*handle-warn-on-redefinition* :warn)
>  (*packages-for-warn-on-redefinition* nil))
>
> #-(or allegro lispworks sbcl)
> progn

In clisp there is (EXT:WITHOUT-PACKAGE-LOCK () ...) described in
http://www.clisp.org/impnotes.html#without-pack-lock

saludos

Karsten
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <fb30731e-0889-463c-8d3c-a3d9464daefb@u13g2000yqg.googlegroups.com>
Well, thanks, now it looks like

(defmacro portably-without-package-locks (&body body)
`(#+sbcl sb-ext:without-package-locks
#+allegro excl::without-package-locks
#+lispworks let #+lispworks
#+clisp ext:without-package-lock ()
((lw:*handle-warn-on-redefinition* :warn)
 (*packages-for-warn-on-redefinition* nil))
#-(or allegro lispworks sbcl clisp)
progn
,@body))

More implementations please (especially ccl)?
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <35323239-5b94-43d5-92eb-90b6546f86e5@u13g2000yqg.googlegroups.com>
Oops, the code is wrong :)
This looks to be better, but it still needs to be tested on all
implems.
(defmacro portably-without-package-locks (&body body)
`(#+sbcl sb-ext:without-package-locks
#+allegro excl::without-package-locks
#+lispworks let
#+lispworks
((lw:*handle-warn-on-redefinition* :warn)
 (*packages-for-warn-on-redefinition* nil))
#+clisp ext:without-package-lock #+clisp ()
#-(or allegro lispworks sbcl clisp)
progn
,@body))
From: Thomas A. Russ
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <ymi8wo0etal.fsf@blackcat.isi.edu>
budden <···········@mail.ru> writes:

> Well, thanks, now it looks like
> More implementations please (especially ccl)?

(let ((ccl:*warn-if-redefine-kernel* nil))
  ...)


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Raymond Toy
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <sxdiqn1fcvf.fsf@rtp.ericsson.se>
>>>>> "budden" == budden  <···········@mail.ru> writes:

    budden> Well, thanks, now it looks like
    budden> (defmacro portably-without-package-locks (&body body)
    budden> `(#+sbcl sb-ext:without-package-locks
    budden> #+allegro excl::without-package-locks
    budden> #+lispworks let #+lispworks
    budden> #+clisp ext:without-package-lock ()
    budden> ((lw:*handle-warn-on-redefinition* :warn)
    budden>  (*packages-for-warn-on-redefinition* nil))
    budden> #-(or allegro lispworks sbcl clisp)
    budden> progn
    budden> ,@body))

Don't know about others, but I never thought code sprinkled with
reader conditionals as being portable....

Ray
From: Pascal J. Bourguignon
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <7cbpstyz56.fsf@pbourguignon.anevia.com>
Raymond Toy <···········@stericsson.com> writes:

>>>>>> "budden" == budden  <···········@mail.ru> writes:
>
>     budden> Well, thanks, now it looks like
>     budden> (defmacro portably-without-package-locks (&body body)
>     budden> `(#+sbcl sb-ext:without-package-locks
>     budden> #+allegro excl::without-package-locks
>     budden> #+lispworks let #+lispworks
>     budden> #+clisp ext:without-package-lock ()
>     budden> ((lw:*handle-warn-on-redefinition* :warn)
>     budden>  (*packages-for-warn-on-redefinition* nil))
>     budden> #-(or allegro lispworks sbcl clisp)
>     budden> progn
>     budden> ,@body))
>
> Don't know about others, but I never thought code sprinkled with
> reader conditionals as being portable....

Indeed.  It's a portability layer, but is not in itself portable.  
It is ported to some implementations.

-- 
__Pascal Bourguignon__
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <e7aa9435-af5f-400f-ab47-db7b3272fa58@v38g2000yqb.googlegroups.com>
Ok. Does it matter.
From: Pascal J. Bourguignon
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <873ae4bp63.fsf@galatea.local>
budden <···········@mail.ru> writes:

> Ok. Does it matter.

If race at mattress.

-- 
__Pascal Bourguignon__
From: Kaz Kylheku
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <20090302231318.691@gmail.com>
On 2009-02-20, budden <···········@mail.ru> wrote:
> Well, thanks, now it looks like
>
> (defmacro portably-without-package-locks (&body body)
> `(#+sbcl sb-ext:without-package-locks
> #+allegro excl::without-package-locks

What you are doing is inherently nonportable. Mucking around within the CL
package is undefined behavior. This is not a ``user serviceable'' part of
Common Lisp.

Package locking helps to diagnose that something nonportable is happening in a
program. Without package locking, programs could accidentally redefine
functions and macros in the the COMMON-LISP package.

I.e. you're asking for a /portable/ way to defeat a commonly implemented
mechanim whose purpose is to guard against something /nonportable/ from
happening, which is irrational nonsense.

Even if you defeat the lock, the action that you intend to take, which is
prevented by that lock, still leaves your code nonportable. It's not the lock
guard which makes it nonportable!

For instance if you break the lock on the CL package and rewrite the function
LIST, you don't know whether a macro like LOOP will use your LIST, or continue
to using the original LIST.

Stop being a twit already.
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <c259e8e6-e57a-45f7-ae2c-512692fadd9b@j8g2000yql.googlegroups.com>
lol
From: Michael Weber
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <5d7a53d3-edf5-4ce8-a10a-d8732786159b@a12g2000yqm.googlegroups.com>
On Feb 19, 7:50 pm, budden <···········@mail.ru> wrote:
> Hi there!
> I'd like to define new macro in cl package silently.

Just out of curiosity, why don't you use some variation of:

(defpackage #:budden-lisp
  (:nicknames #:bl)
  (:use #:cl)
  (:export . #.(let ((cl-symbols '()))
                 (do-external-symbols (sym :cl cl-symbols)
                   (push (make-symbol (symbol-name sym))
                         cl-symbols))))
  (:export #:let1))
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <6652debc-ac30-4dc0-b3d5-6640110e72a8@q35g2000vbi.googlegroups.com>
> (defpackage #:budden-lisp
Because I'm redefining find-symbol and intern to alter default package
system behaviour.
Let1 was for example only.
From: Michael Weber
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <a13a2b34-be2a-4f3d-bdf4-3fedaac4caab@f11g2000vbf.googlegroups.com>
On Feb 20, 2:05 pm, budden <···········@mail.ru> wrote:
> > (defpackage #:budden-lisp
>
> Because I'm redefining find-symbol and intern to alter default package
> system behaviour.
> Let1 was for example only.

(defpackage #:budden-lisp
  (:nicknames #:bl)
  (:use #:cl)
  (:export . #.(let ((cl-symbols '()))
                 (do-external-symbols (sym :cl cl-symbols)
                   (push (make-symbol (symbol-name sym))
                         cl-symbols))))
  (:shadow #:find-symbol #:intern))

(in-package #:budden-lisp)

(defun find-symbol (&rest args)
  (princ "Mine!" *trace-output*)
  (apply #'cl:find-symbol args))

(defun intern (&rest args)
  (princ "Mine!" *trace-output*)
  (apply #'cl:intern args))

As you noted, LET1 was for example only.

Of course, your versions are not used by functions and macros in the
CL package (and neither should they), but then again just overriding
the package lock does not guarantee that either.  An implementation is
free to do a lot of things behind your back.

For a reliable solution you probably have to identify the functions
using your new features and extend/replace them.  If it's the reader,
Pascal Bourguignon has done the exercise, and IIRC, there's also one
in SACLA.
From: Pascal J. Bourguignon
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <87bpsxgrdg.fsf@galatea.local>
budden <···········@mail.ru> writes:

>> (defpackage #:budden-lisp
> Because I'm redefining find-symbol and intern to alter default package
> system behaviour.
> Let1 was for example only.

You don't need to override CL to do that.
Have a look at: http://www.informatimago.com/develop/lisp/small-cl-pgms/ibcl/
Check the ibcl:defpackage macro.

Notice that overriding operators in the package CL doesn't make the
other operators in this package use the overriden operators: an
implementation is free to open-code any of its functions (and of
course its macros will have been expanded long ago).  Therefore you
will have to provide new functions anyways, therefore there's no point
in putting them in CL.

-- 
__Pascal Bourguignon__
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <742a58b1-bc9d-44fb-aa86-afffa9934230@p13g2000yqc.googlegroups.com>
> Notice that overriding operators in the package CL doesn't make the
>other operators in this package use the overriden operators: an
>implementation is free to open-code any of its functions (and of
>course its macros will have been expanded long ago).
Yes, but sometimes it does use overriden operators (at least,
lispworks does so for
intern and find-symbol).

Overall idea of what I want is here http://groups.google.com/group/comp.lang.lisp/msg/4c73d159bfcd7f16
,
code is here http://paste.lisp.org/display/75852 .

Thanks for references to alternative readers, for now I think the best
one comes from ccl. I can hook it up
and use it instead standard reader portably, but it needs to be
abstracted from ccl kernel functions,
they are to be replaced with common lisp functions. I'm too lazy to do
that.
From: Pascal J. Bourguignon
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <874oypgncn.fsf@galatea.local>
budden <···········@mail.ru> writes:

>> Notice that overriding operators in the package CL doesn't make the
>>other operators in this package use the overriden operators: an
>>implementation is free to open-code any of its functions (and of
>>course its macros will have been expanded long ago).
> Yes, but sometimes it does use overriden operators (at least,
> lispworks does so for
> intern and find-symbol).

So you write programs that work sometimes...


-- 
__Pascal Bourguignon__
From: Rob Warnock
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <b8-dnXg6E8GOPwPUnZ2dnUVZ_gaWnZ2d@speakeasy.net>
budden  <···········@mail.ru> wrote:
+---------------
| I'd like to define new macro in cl package silently.
| How I'll do that? For now I have:
...
| #+sbcl sb-ext:without-package-locks
...
| What about other implementations?
+---------------

CMUCL:

  #+cmu ext:without-package-locks


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: budden
Subject: Re: portable disabling of cl package lock
Date: 
Message-ID: <a93f12d2-f0a9-4d58-927d-5aa762508591@n20g2000vba.googlegroups.com>
>   #+cmu ext:without-package-locks
Thanks!