[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Detect code issue when build through asdf

james

7/25/2015 7:36:00 AM

I think there should be a way to detect code issue in programming but don't know how.

Here is what I did. I am using asdf to organize my project. (Not sure this is the best way)


I create three file cow.asd, t1.lisp, t2.lisp

==========cow.asd=============
(defpackage :cow-asd (:use :cl :asdf))
(in-package :cow-asd)
(defsystem cow
:name "cow"
:components( (:file "t2" :depends-on ("t1"))
(:file "t1")
))

==========t1.lisp=============
(defpackage :t1 (:use :cl) (:export :add))
(in-package :t1)
(defun add ()
't1.add)

==========t2.lisp=============
(load "~/t1.lisp")
(t1:add)
(defun t2add()
't2.add)

CL-USER> (asdf:operate 'asdf:compile-op 'cow)

Every thing is ok

Consider the following case. If i changed the t1.lisp to the following one by mistake
(defpackage :t1 (:use :cl) (:export :add))
(in-package :t1)
(defun addXXXXXX ()
't1.add)

Then I try to rebuild the whole system through
CL-USER> (asdf:operate 'asdf:compile-op 'cow)

There is not error could be detected by this because t1:add are already loaded.

I expected the REPL report the error to me that t1:add can't be found. Am i doing the right way?

Thanks
8 Answers

Dimitri Fontaine

7/25/2015 11:05:00 AM

0

james <dinglei2008@gmail.com> writes:
> (defun addXXXXXX ()
> 't1.add)
>
> Then I try to rebuild the whole system through
> CL-USER> (asdf:operate 'asdf:compile-op 'cow)
>
> There is not error could be detected by this because t1:add are already loaded.
>
> I expected the REPL report the error to me that t1:add can't be found. Am i doing the right way?

I know two ways to catch that early:

- when you change the name of the function, make the previous name
undefined (see C-c C-u in SLIME, or the fmakunboud function).

- when you change the name of the function, restart your lisp and
start afresh, in SLIME use ,restart-inferior-lisp for that.

Then if you recompile the whole projet you will get the expected error.

Also note that once ASDF knows how to load your project, so does
Quicklisp so you could (ql:quickload 'cow :verbose t) too.

Regards,
--
dim

Pascal J. Bourguignon

7/25/2015 3:25:00 PM

0

Dimitri Fontaine <dim@tapoueh.org> writes:

> james <dinglei2008@gmail.com> writes:
>> (defun addXXXXXX ()
>> 't1.add)
>>
>> Then I try to rebuild the whole system through
>> CL-USER> (asdf:operate 'asdf:compile-op 'cow)
>>
>> There is not error could be detected by this because t1:add are already loaded.
>>
>> I expected the REPL report the error to me that t1:add can't be found. Am i doing the right way?
>
> I know two ways to catch that early:
>
> - when you change the name of the function, make the previous name
> undefined (see C-c C-u in SLIME, or the fmakunboud function).

And a third one, intermediate: delete the package:

(delete-package "T1")
(ql:quickload "cow")

> - when you change the name of the function, restart your lisp and
> start afresh, in SLIME use ,restart-inferior-lisp for that.

--
__Pascal Bourguignon__

james

7/27/2015 1:52:00 AM

0

On Saturday, July 25, 2015 at 7:04:18 PM UTC+8, Dimitri Fontaine wrote:
> james <dinglei2008@gmail.com> writes:
> > (defun addXXXXXX ()
> > 't1.add)
> >
> > Then I try to rebuild the whole system through
> > CL-USER> (asdf:operate 'asdf:compile-op 'cow)
> >
> > There is not error could be detected by this because t1:add are already loaded.
> >
> > I expected the REPL report the error to me that t1:add can't be found. Am i doing the right way?
>
> I know two ways to catch that early:
>
> - when you change the name of the function, make the previous name
> undefined (see C-c C-u in SLIME, or the fmakunboud function).
>
> - when you change the name of the function, restart your lisp and
> start afresh, in SLIME use ,restart-inferior-lisp for that.
>
> Then if you recompile the whole projet you will get the expected error.
>
> Also note that once ASDF knows how to load your project, so does
> Quicklisp so you could (ql:quickload 'cow :verbose t) too.
>
> Regards,
> --
> dim

Thanks, restart lisp is the simplest way I think. I just though why dosen't asdf supply a option to do the same things in re-compile like (clean up current context and re-build).

james

7/27/2015 3:13:00 AM

0

On Saturday, July 25, 2015 at 11:25:29 PM UTC+8, informatimago wrote:
> Dimitri Fontaine <dim@tapoueh.org> writes:
>
> > james <dinglei2008@gmail.com> writes:
> >> (defun addXXXXXX ()
> >> 't1.add)
> >>
> >> Then I try to rebuild the whole system through
> >> CL-USER> (asdf:operate 'asdf:compile-op 'cow)
> >>
> >> There is not error could be detected by this because t1:add are already loaded.
> >>
> >> I expected the REPL report the error to me that t1:add can't be found. Am i doing the right way?
> >
> > I know two ways to catch that early:
> >
> > - when you change the name of the function, make the previous name
> > undefined (see C-c C-u in SLIME, or the fmakunboud function).
>
> And a third one, intermediate: delete the package:
>
> (delete-package "T1")
> (ql:quickload "cow")
>
> > - when you change the name of the function, restart your lisp and
> > start afresh, in SLIME use ,restart-inferior-lisp for that.
>
> --
> __Pascal Bourguignon__

Thanks, I think (ql:quickload 'cow :verbose t) will call (asdf:operate 'asdf:load-op 'cow) right?
And Why you prefer use (ql:quickload "cow") instead of asdf ? The less typing?

taruss

7/27/2015 5:59:00 PM

0

On Sunday, July 26, 2015 at 6:52:07 PM UTC-7, james wrote:

> Thanks, restart lisp is the simplest way I think. I just though why dosen't asdf supply a option to do the same things in re-compile like (clean up current context and re-build).

This isn't really an ASDF issue, but more one of the way lisp systems work.
Unless you take actions to clear up the previous state, the run-time system will retain the results of things you have previously done in that session.

I would expect that there would be the potential for bad results if ASDF were to try to "clean up" before operating, since it would be hard to know what, exactly, to clean up, especially if there are a large number of systems loaded.

The simplest solution is, as you have discovered, to just restart the lisp run time if you want to have a really clean environment to work with.


taruss

7/27/2015 6:01:00 PM

0

On Saturday, July 25, 2015 at 12:36:27 AM UTC-7, james wrote:

> Here is what I did. I am using asdf to organize my project. (Not sure this is the best way)
>
>
> I create three file cow.asd, t1.lisp, t2.lisp
>
> ==========cow.asd=============
> (defpackage :cow-asd (:use :cl :asdf))
> (in-package :cow-asd)
> (defsystem cow
> :name "cow"
> :components( (:file "t2" :depends-on ("t1"))
> (:file "t1")
> ))
>
> ==========t1.lisp=============
> (defpackage :t1 (:use :cl) (:export :add))
> (in-package :t1)
> (defun add ()
> 't1.add)
>
> ==========t2.lisp=============
> (load "~/t1.lisp")
^^^^^^^^^^^^^^^^^^
You will not want to do this in an ASD system.
The point of ASD is to manage the dependencies of your system design, and if
you put explicit LOAD commands into your code, then you are subverting the idea
behind the system building tool that you are using.


> (t1:add)
> (defun t2add()
> 't2.add)

james

7/28/2015 1:47:00 AM

0

On Tuesday, July 28, 2015 at 2:01:20 AM UTC+8, tar...@google.com wrote:
> On Saturday, July 25, 2015 at 12:36:27 AM UTC-7, james wrote:
>
> > Here is what I did. I am using asdf to organize my project. (Not sure this is the best way)
> >
> >
> > I create three file cow.asd, t1.lisp, t2.lisp
> >
> > ==========cow.asd=============
> > (defpackage :cow-asd (:use :cl :asdf))
> > (in-package :cow-asd)
> > (defsystem cow
> > :name "cow"
> > :components( (:file "t2" :depends-on ("t1"))
> > (:file "t1")
> > ))
> >
> > ==========t1.lisp=============
> > (defpackage :t1 (:use :cl) (:export :add))
> > (in-package :t1)
> > (defun add ()
> > 't1.add)
> >
> > ==========t2.lisp=============
> > (load "~/t1.lisp")
> ^^^^^^^^^^^^^^^^^^
> You will not want to do this in an ASD system.
> The point of ASD is to manage the dependencies of your system design, and if
> you put explicit LOAD commands into your code, then you are subverting the idea
> behind the system building tool that you are using.
>
>
> > (t1:add)
> > (defun t2add()
> > 't2.add)

Oh yes, a rookie mistake :)

Pascal J. Bourguignon

7/28/2015 2:16:00 PM

0

james <dinglei2008@gmail.com> writes:
> Thanks, I think (ql:quickload 'cow :verbose t) will call (asdf:operate 'asdf:load-op 'cow) right?
> And Why you prefer use (ql:quickload "cow") instead of asdf ? The less typing?

Mostly, the automatic downloading of dependencies not yet installed.

--
__Pascal Bourguignon__ http://www.informat...
â??The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.� -- Carl Bass CEO Autodesk