On 1 Aug 2017, at 17:08, Sam Steingold <sds@gnu.org> wrote:

* Faré <snuerr@tznvy.pbz> [2017-08-01 10:07:33 -0400]:

To mark a generic function as user-extendable, one can now use a
declaration:

--8<---------------cut here---------------start------------->8---
(defgeneric perform (...)
 (declare #+clisp (dynamically-modifiable))
 ...)
(defgeneric operation-done-p (...)
 (declare #+clisp (dynamically-modifiable))
 ...)
--8<---------------cut here---------------end--------------->8---

The declaration is now in `hg tip` (but has not been released yet).

Will that declaration cause a warning or error on older versions of
clisp? If yes, what read-time conditional more precise than #+clisp
can I use to only enable on recent enough versions of clisp?

My first reaction was

--8<---------------cut here---------------start------------->8---
(declaim (declaration dynamically-modifiable))
--8<---------------cut here---------------end--------------->8---

but for some reason it does not work with defgeneric.
Sorry.


1- when naming an implementation-specific declaration, we need to know what package it comes from!
   (Now, an implementation could use only the symbol-name of the declaration so it would accept with the same semantics any package, but this would be a problem if the program uses the same symbol name in a different package to mean something else, so I would advise implementations to avoid using symbol-names for declarations, and instead to specify a specific package).

2- indeed the correct way to use implementation specific declarations is to declaim them.

    #-clisp (defpackage “EXT” #| be careful with those 💣🔪🔫 smart quotes! |#
               (:use)
               (:export “DYNAMICALLY-MODIFIABLE”))

    (declaim (declaration ext:dynamically-modifiable))

    (defgeneric foo (bar)
       (declare ext:dynamically-modifiable)))


It works perfectly, but on clisp, since DYNAMICALLY-MODIFIABLE doesn’t come from EXT.  
Where does it come from???



[pjb@despina :0.0 ~]$ clall '(compile-file "/tmp/d.lisp")'



Armed Bear Common Lisp:
========================================================================
Implementation: Armed Bear Common Lisp 1.4.0
    on Mac OS X 10.12.6
    on X86_64 NIL (despina.home)

Reading of: "(compile-file \"/tmp/d.lisp\")"
signaled no error

Evaluation of: (COMPILE-FILE "/tmp/d.lisp")
signaled the following error:
  #<READER-ERROR {2D87B142}>
  The symbol "DYNAMICALLY-MODIFIABLE" was not found in package EXT.
wrote nothing on *ERROR-OUTPUT*
wrote nothing on *TRACE-OUTPUT*
wrote the following *STANDARD-OUTPUT* (lines excluded):
------------------------------------------------------------------------
; Compiling /private/tmp/d.lisp ...
; (DEFPACKAGE "EXT" ...)
------------------------------------------------------------------------
returned no value


Clozure Common Lisp:
--> #P"/private/tmp/d.dx64fsl", NIL, NIL


CLISP:
========================================================================
Implementation: CLISP 2.49 (2010-07-07) (built 3704439585) (memory 3704439775)
    on 
/usr/bin/clang -arch x86_64 -pipe -Wl,-no_pie -arch x86_64 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -O -DUNIX_BINARY_DISTRIB -DENABLE_UNICODE -DDYNAMIC_MODULES -I. -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64  -lintl -Wl,-framework -Wl,CoreFoundation -lreadline -lncurses  -liconv -L/opt/local/lib -lsigsegv  libgnu_cl.a -L/opt/local/lib
SAFETY=0 HEAPCODES STANDARD_HEAPCODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.11
libiconv 1.15
libreadline 7.0 GNU C 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)
    on X86_64 X86_64 (despina.home [192.168.7.10])

Reading of: "(compile-file \"/tmp/d.lisp\")"
signaled no error

Evaluation of: (COMPILE-FILE "/tmp/d.lisp")
signaled the following error:
  #<SYSTEM::SIMPLE-PACKAGE-ERROR #x000000020023FE91>
  
READ from #<CLOSED INPUT BUFFERED FILE-STREAM CHARACTER #P"/tmp/d.lisp" @5>: #<PACKAGE
  EXT> has no external symbol with name "DYNAMICALLY-MODIFIABLE"

wrote the following *ERROR-OUTPUT* (lines excluded):
------------------------------------------------------------------------
0 errors, 0 warnings
------------------------------------------------------------------------
wrote nothing on *TRACE-OUTPUT*
wrote the following *STANDARD-OUTPUT* (lines excluded):
------------------------------------------------------------------------
;; Compiling file /tmp/d.lisp ...
------------------------------------------------------------------------
returned no value


ECL:
========================================================================
Implementation: ECL 16.1.2
    on Darwin 16.7.0
    on x86_64 NIL (despina.home)

Reading of: "(compile-file \"/tmp/d.lisp\")"
signaled no error

Evaluation of: (COMPILE-FILE "/tmp/d.lisp")
signaled the following error:
  #<a C:COMPILER-NOTE>
  Note:
  Invoking external command:
  gcc -I. -I/usr/local/include/ -g -O2 -fPIC -fno-common -D_THREAD_SAFE -Ddarwin -O2 -c /private/tmp/d.c -o /private/tmp/d.o 
wrote nothing on *ERROR-OUTPUT*
wrote nothing on *TRACE-OUTPUT*
wrote the following *STANDARD-OUTPUT* (lines excluded):
------------------------------------------------------------------------
;;; Loading #P"/usr/local/lib/ecl-16.1.2/cmp.fas"
;;;
;;; Compiling /tmp/d.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;;
;;; Compiling (DEFGENERIC FOO ...).
;;; End of Pass 1.
------------------------------------------------------------------------
returned no value


SBCL:; compiling file "/private/tmp/d.lisp" (written 01 AUG 2017 05:19:58 PM):
; compiling (DEFPACKAGE "EXT" ...)
; compiling (DECLAIM (DECLARATION EXT:DYNAMICALLY-MODIFIABLE))
; compiling (DEFGENERIC FOO ...)

; /tmp/d.fasl written
; compilation finished in 0:00:00.003
--> #P"/private/tmp/d.fasl", T, T

========================================================================

[pjb@despina :0.0 ~]$ 


-- 
__Pascal J. Bourguignon__