Re: [fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread Waldek Hebisch
On Sun, Mar 05, 2023 at 07:08:19PM +0800, Qian Yun wrote:
> 
> What we did before: "(do-symbols (x "FRICAS-LISP") (export (list x)))"
> This line basically exports every symbol from "COMMON-LISP" again in
> "FRICAS-LISP".
> 
> This is highly unusual, because normally a package will only export its
> new definitions.

Not at all unusual.  Basically, we want all Common Lisp symbols,
except for few that we do not want (we probably could do with a subset
of Common Lisp symbols.  So we create package that
contains exactly symbols that we need, re-using "COMMON-LISP".

>  And this is where sbcl-2.3.2 breaks: it doesn't export
> the updated "in-package" definition somehow.

Solution for problem should be simple, we need to split 'do-symbols'
loop into two parts, one that creates list of symbols, other that
exports all symbols on the list.  Single loops looks more elegant,
but since sbcl folks do not want to support such use we will change
our code.  There is a little tricky part: normally variables in Lisp
code use new symbols, but we do not want to add symbols before the
'export' loop.

Note: ATM problem showed up when we used 'in-package', but in principle
it could affect other symbols too.

-- 
  Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20230305162218.hfhhw6wh7nxf55ns%40fricas.math.uni.wroc.pl.


Re: [fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread Waldek Hebisch
On Sun, Mar 05, 2023 at 02:33:20PM +, Peter Broadbery wrote:
> > Aldor generates non-standard Lisp -- "in-package" with :use keyword.
> 
> What should be generated?  I'm happy to change it to something more standard.
> I don't really know lisp, so I'd rather implement other peoples ideas
> in this area..

Just 'in-package' without extra stuff, like:

(in-package "BOOT")

-- 
  Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20230305160818.odtfek3il3k7un66%40fricas.math.uni.wroc.pl.


Re: [fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread Peter Broadbery
> Aldor generates non-standard Lisp -- "in-package" with :use keyword.

What should be generated?  I'm happy to change it to something more standard.
I don't really know lisp, so I'd rather implement other peoples ideas
in this area..

Peter

On Sun, 5 Mar 2023 at 13:26, oldk1331  wrote:
>
> As Waldek said in the github comment:
>
> "IIRC redefined 'in-package' was added for Aldor. I do not know
> if Aldor still need it."
>
> Aldor generates non-standard Lisp -- "in-package" with :use keyword.
>
> - Qian
>
> On Sun, Mar 5, 2023, 9:14 PM Ralf Hemmecke  wrote:
>>
>> > So, what we intend to do: (due to still existed issue on the Aldor side)
>>
>> What exactly do you mean here?
>>
>> At least I am relieved that your patch does seemingly not break the
>> fricas-aldor interface.
>>
>> Ralf
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "FriCAS - computer algebra system" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to fricas-devel+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/fricas-devel/601f3797-8bfd-088d-a67e-9a1d1b68ad61%40hemmecke.org.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to fricas-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/fricas-devel/CAGBJN92z-YcU4WvOxiWaCpKws7wLQ%3DznufzWvSBHvWC_kBFbuQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAK%3DmBN-dbux8azK5n2OZyE670roN7v2xskG79MQHC6mWFegH%2Bw%40mail.gmail.com.


Re: [fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread oldk1331
As Waldek said in the github comment:

"IIRC redefined 'in-package' was added for Aldor. I do not know
if Aldor still need it."

Aldor generates non-standard Lisp -- "in-package" with :use keyword.

- Qian

On Sun, Mar 5, 2023, 9:14 PM Ralf Hemmecke  wrote:

> > So, what we intend to do: (due to still existed issue on the Aldor side)
>
> What exactly do you mean here?
>
> At least I am relieved that your patch does seemingly not break the
> fricas-aldor interface.
>
> Ralf
>
> --
> You received this message because you are subscribed to the Google Groups
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fricas-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/fricas-devel/601f3797-8bfd-088d-a67e-9a1d1b68ad61%40hemmecke.org
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAGBJN92z-YcU4WvOxiWaCpKws7wLQ%3DznufzWvSBHvWC_kBFbuQ%40mail.gmail.com.


Re: [fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread Ralf Hemmecke

So, what we intend to do: (due to still existed issue on the Aldor side)


What exactly do you mean here?

At least I am relieved that your patch does seemingly not break the 
fricas-aldor interface.


Ralf

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/601f3797-8bfd-088d-a67e-9a1d1b68ad61%40hemmecke.org.


[fricas-devel] about sbcl-2.3.2 (package related) compile error

2023-03-05 Thread Qian Yun

OK, after some trying with small code examples and reading (obscure)
Common Lisp documentation, I finally understand the context of this bug.

So, what we intend to do: (due to still existed issue on the Aldor side)
we want to "shadow" definition of "in-package" from Lisp implementation,
and use our version instead.  We want this updated definition of
"in-package" to be used in "FRICAS-LISP" package and any packages that
derive from it.

What we did before: "(do-symbols (x "FRICAS-LISP") (export (list x)))"
This line basically exports every symbol from "COMMON-LISP" again in
"FRICAS-LISP".

This is highly unusual, because normally a package will only export its
new definitions.  And this is where sbcl-2.3.2 breaks: it doesn't export
the updated "in-package" definition somehow.

Putting the sbcl "bug" aside, the "do-symbols" line looks like a hack
to me, and the proper solution comes from documentation:

http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_use-package.html

"A name conflict in use-package between two external symbols inherited
by the using package from other packages may be resolved in favor of
either symbol by importing it into the using package and making it a
shadowing symbol."

Again, rephrasing the problem:

We'd like to simply use
(make-package "BOOT" :use '("COMMON-LISP" "FRICAS-LISP"))
But we can't because of symbol conflict on "in-package".
So the proper solution is this:

(defmacro make-package-with-fricas-lisp (package)
`(progn
(make-package ,package)
(import 'FRICAS-LISP:IN-PACKAGE ,package)
(shadow "IN-PACKAGE" ,package)
(use-package '("COMMON-LISP" "FRICAS-LISP") ,package)))

Fist, make an empty package.  Then, import the symbol we want to use.
Then shadow it and use "use-package" after that.

Full patch attached.

- Qian

diff --git a/src/lisp/fricas-package.lisp b/src/lisp/fricas-package.lisp
index c0dfc4ef..da8eb442 100644
--- a/src/lisp/fricas-package.lisp
+++ b/src/lisp/fricas-package.lisp
@@ -34,12 +34,10 @@
 #+gcl
 (shadow "QUIT")

-(do-symbols (x "FRICAS-LISP") (export (list x)))
-
 (export '(quit chdir |getEnv| |getCLArgs| |load_quietly| 
get-current-directory

   trim-directory-name pad-directory-name
   file-kind makedir fricas_compile_file fricas_compile_fasl
-  |fricas_probe_file|
+  |fricas_probe_file| IN-PACKAGE
   DEFCONST exit-with-status MEMQ |quiet_load_alien|
   |handle_input_file| |handle_output_file| |maybe_delete_file|
   |remove_directory| |writeablep| |openServer| |sockGetInt|
@@ -61,13 +59,28 @@
 (eval-when (:execute :compile-toplevel :load-toplevel)
   (setf *features* (delete :CCL *features*)))

+(defmacro make-package-with-fricas-lisp (package)
+`(progn
+(make-package ,package)
+(import 'FRICAS-LISP:IN-PACKAGE ,package)
+(shadow "IN-PACKAGE" ,package)
+(use-package '("COMMON-LISP" "FRICAS-LISP") ,package)))
+
 ;;; Package containing Shoe to Lisp translator
-(make-package "BOOTTRAN" :use '("FRICAS-LISP"))
+(make-package-with-fricas-lisp "BOOTTRAN")
+
+;;; Package containing support routines for code generated
+;;; by Aldor compiler.
+(make-package-with-fricas-lisp "FOAM")
+
+;;; Package for code output by Aldor.
+(make-package-with-fricas-lisp "FOAM-USER")
+(use-package '("FOAM") "FOAM-USER")

 ;;; Main FriCAS package.  The interpreter and the algebra are run
 ;;; after switching to the boot package (in-package "BOOT") so any
 ;;; symbol that the interpreter or algebra uses has to appear here.
-(make-package "BOOT" :use '("FRICAS-LISP"))
+(make-package-with-fricas-lisp "BOOT")

 (in-package "BOOT")

@@ -78,10 +91,3 @@

 (import '(BOOT::MAKE_HASHTABLE BOOT::QSETVELT BOOT::SETELT_BVEC
   BOOT::STR_ELT))
-
-;;; Package containing support routines for code generated
-;;; by Aldor compiler.
-(make-package "FOAM" :use '("FRICAS-LISP"))
-
-;;; Package for code output by Aldor.
-(make-package "FOAM-USER" :use '("FRICAS-LISP" "FOAM"))

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/82a5c89c-16fd-ce89-696e-0f0c24d99c02%40gmail.com.
diff --git a/src/lisp/fricas-package.lisp b/src/lisp/fricas-package.lisp
index c0dfc4ef..da8eb442 100644
--- a/src/lisp/fricas-package.lisp
+++ b/src/lisp/fricas-package.lisp
@@ -34,12 +34,10 @@
 #+gcl
 (shadow "QUIT")
 
-(do-symbols (x "FRICAS-LISP") (export (list x)))
-
 (export '(quit chdir |getEnv| |getCLArgs| |load_quietly| get-current-directory
   trim-directory-name pad-directory-name
   file-kind makedir fricas_compile_file fricas_compile_fasl
-  |fricas_probe_file|
+  |fricas_probe_file| IN-PACKAGE
   DEFCONST exit-with-status MEMQ