ASDF?

13 views
Skip to first unread message

starseeker

unread,
Jan 5, 2008, 4:29:50 PM1/5/08
to Qilang
Sorry if this is a question which as been asked before, but has anyone
considered making Qi an asdf loadable system for Lisp?

Cheers,
CY

Mark Tarver

unread,
Jan 6, 2008, 2:22:42 PM1/6/08
to Qilang
I don't believe anybody has suggested or done this as of yet.

Mark

brian

unread,
Jan 7, 2008, 6:45:39 AM1/7/08
to Qilang


On 7 Jan, 04:22, Mark Tarver <dr.mtar...@ukonline.co.uk> wrote:
> I don't believe anybody has suggested or done this as of yet.
>
> Mark
>

-- qi.asd --

(in-package :cl-user)

(defclass qi-source-file (asdf:cl-source-file) ())

(defvar *qi-readtable* (copy-readtable))

(defmethod asdf:perform :around ((o asdf:compile-op) (f qi-source-
file))
; force it to load before compiling.
(let ((*readtable* *qi-readtable*))
(load (asdf:component-pathname f))
(call-next-method)))

(defmethod asdf:perform :around ((o asdf:load-op) (f qi-source-file))
(let ((*readtable* *qi-readtable*))
(call-next-method)
; we already can't do anything without accepting the GPL.
; this allows us to avoid dumping cores and so on, and just
; call (|qi|::|qi|) to get into the qi repl.
; we can't write |qi|::|*licence*| because there is no "qi"
package yet.
(set (intern "*licence*" (find-package "qi")) t)))

(asdf:defsystem :qi
:serial t
:version 9.1
:default-component-class qi-source-file
:components ((:file "package")
(:file "qi")))

-- package.lisp --

(defpackage "qi")

(in-package "qi")

(cl:defvar *saved-readtables* cl:nil)
(cl:defvar *saved-packages* cl:nil)

(cl:defun cl-user::in-qi ()
; we need this to set up the reader, although on reflection, perhaps
we don't ...
(cl:push cl:*readtable* *saved-readtables*)
(cl:setf cl:*readtable* cl-user::*qi-readtable*)
(cl:push cl:*package* *saved-packages*)
(cl:setf cl:*package* (cl:find-package "qi")))

(cl:defun |out-qi| ()
; we need this to set up the reader, although on reflection, perhaps
we don't ...
(cl:setf cl:*readtable* (cl:pop *saved-readtables*))
(cl:setf cl:*package* (cl:pop *saved-packages*)))

-- qi.lisp --

link "Qi 9.1.txt" (a very silly name) to qi.lsp

----

The above is something that I put together the other day to load qi
via asdf.
It is not particularly well tested, and may be wrong in part.
The fully qualified symbols are mainly there to make it clearer which
language we're dealing with.
Also, it needs to stop polluting cl-user -- probably a "QI" package
which handled the CL side would
work better, but this should get you started.

Once you've done that, you can start qi with (require 'qi) (in-qi) (|
qi|::|qi|).

I'm trying to set it up so that (in-qi) and (out-qi) work cleanly, but
qi's doesn't seem to use the read-table for syntax such as [1 2 3]. It
will probably take some horrible readtable hackery to achieve.

The part that seems most difficult at the moment is getting qi to
translate to CL properly.

Emulating (dump file-name) doesn't seem too bad, but it doesn't
actually work fully.

If you have a file such as

-- print.qi --
(print qi)

then (load "print.qi") works, but (dump "print.qi") produces an empty
file called "print.qi.lsp") ...

It looks like there's no compilation support for expressions rather
than definitions for compilation to CL, which makes (in-qi) and (out-
qi) tricky, since you really want to get those expressions to
translate too.

Anyhow, I haven't looked at it deeply yet, so it's likely that I'm
doing something stupid or overlooking something.

Please correct any misconceptions that I may have.

Regards,
Brian.

C Y

unread,
Jan 8, 2008, 5:31:49 PM1/8/08
to Qil...@googlegroups.com
brian wrote:

> The above is something that I put together the other day to load qi
> via asdf.

Thanks!

> It is not particularly well tested, and may be wrong in part.
> The fully qualified symbols are mainly there to make it clearer which
> language we're dealing with.
> Also, it needs to stop polluting cl-user -- probably a "QI" package
> which handled the CL side would work better, but this should get you
> started.
>
> Once you've done that, you can start qi with (require 'qi) (in-qi) (|
> qi|::|qi|).

Just curious - why the explicit requirement of accepting the GPL? I've
never encountered that before, and I don't think the GPL itself requires
it - certainly not when the usage doesn't involve distribution.

CY

Mark Tarver

unread,
Jan 10, 2008, 6:52:36 AM1/10/08
to Qilang
> Just curious - why the explicit requirement of accepting the GPL? I've
> never encountered that before,

Its not unusual for software to require assenting to the licence
before installation.

Mark

Slobodan Blazeski

unread,
Jan 15, 2008, 4:26:36 PM1/15/08
to Qilang
Thanks for the asdf brian, does it allow to use Qi in a *normal* REPL
and program in qi , than switch to lisp, back and forth. Also what
implementation / platform is working on ?

Slobodan

Brian Spilsbury

unread,
Jan 16, 2008, 10:43:36 AM1/16/08
to Qil...@googlegroups.com
> Thanks for the asdf brian, does it allow to use Qi in a *normal* REPL
> and program in qi , than switch to lisp, back and forth. Also what
> implementation / platform is working on ?

The original one posted doesn't.
Assuming that attachments work with groups, the attached code does.

You'll still need to link or rename "Qi 9.1.txt" to qi.lisp.

The code is quite horrible and only very briefly tested (since I just hacked
it together). I don't understand Qi in any deep way yet, so it's probably
doing things more stupidly than necessary. Use at your own risk :)

Hopefully this can be made more civilized and integrated into Qi proper.
I'm thinking that switching from (in-qi) ... (out-qi) to (qi ...) and
(prolog ...) might be a better approach. What do people think?

There is also (qi:repl) which drops you into the normal qi environment with
no easy means of escape -- you might break out using catch/throw.

Ah, one thing that I haven't shown here is turning on type checking mode.
In this case, when (in-qi), you'll receive back two values for each top-level
evaluation -- the first is the result, the second the type, so that you can
capture both with multiple-value-bind if you want to.

* (map (* 7) [1 2 3])

(7 14 21)
(list number)

Here's a transcript which is the best documentation at the moment.
Also see test.lisp which shows how to switch to prolog and back.

---

* (require 'qi)

NIL
* (compile-file "test")

; compiling file "/home/zhivago/lisp/qi/Qi 9.1/test.lisp" (written 16
JAN 2008 11:36:07 PM):

; /home/zhivago/lisp/qi/Qi 9.1/test.fasl written
; compilation finished in 0:00:00
#P"/home/zhivago/lisp/qi/Qi 9.1/test.fasl"
NIL
NIL
* (load "test")
======> Warning: the following variables are free in test: X; Y;

T
* (qi::test)

(1 2)
* (qi:in-qi)

NIL
* (map (* 7) [1 2])

(7 14)
* (test)

(1 2)
* (out-qi)

NIL
* *package*

#<PACKAGE "COMMON-LISP-USER">
*
----

qi-asd2.tgz
Reply all
Reply to author
Forward
0 new messages