quickproject [newbie]

Discussion of Common Lisp

quickproject [newbie]

Postby chocolait » Fri Oct 14, 2011 10:07 pm

Hi Lispers,

I use the excellent quicklisp and have just tried using Lisp for trivial stuff at the moment but I am planning to use them more in serious projects.
I came across Zach's post and I want to use quickproject as a base for new project template. (e.g. quickproject:make-project "~/src/lisp/newproject/" :depends-on '(skippy))
Quickproject creates 4 files inside : package.lisp, newproject.lisp, newproject.asd, README.txt

Here's package.lisp:
(defpackage #:newproject
(:use #:cl)
(:shadowing-import-from #:skippy))

I can use skippy from REPL without using the package prefix but I can't seem to write code in newproject.lisp without using the package prefix.
What do I miss here?

Thanks for your answers.
chocolait
 
Posts: 3
Joined: Sat Sep 27, 2008 12:09 am
Location: Indonesia

Re: quickproject [newbie]

Postby Ramarren » Sat Oct 15, 2011 12:33 am

You should probably read Practical Common Lisp, in particular chapter on packages for more in depth explanation.

chocolait wrote:I can use skippy from REPL without using the package prefix


I don't really see how that is possible, unless you either changed the REPL package or imported skippy independently of quickproject. The package created by quickproject creates a shadowing-import-from template, which allows importing symbols one by one, which is in many cases preferable to importing a package a whole, but the template doesn't actually import any symbols into the new package.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: quickproject [newbie]

Postby chocolait » Sat Oct 15, 2011 7:33 am

Thanks for your answer Ramarren.

I am seeing the light now about importing the symbols.
Now my next question is:
What is the standard practice in Lisp for importing libraries? Do you import the symbols one by one? Or you can import the whole symbols in a library?
Which one is desirable?

Thanks for your answers.
chocolait
 
Posts: 3
Joined: Sat Sep 27, 2008 12:09 am
Location: Indonesia

Re: quickproject [newbie]

Postby nuntius » Sun Oct 16, 2011 11:45 pm

This is a style issue. Major influences in the decision are convenience, clarity (highlight rarely used packages at their use, frequently used packages in the defpackage), and potential conflict (same symbol name in multiple packages).

For only a couple uses, it makes sense just to specify the package name directly as package:symbol. For several uses of just a couple symbols, import is the cleanest solution. If the list of imported symbols grows, it often good to just (:use :package) and get the whole lot.

(The same issues come up in languages like C++ and Java, with roughly the same advice.)
User avatar
nuntius
 
Posts: 500
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 4 guests