From: Captain Obvious on 18 Jun 2010 11:27 ??>> On some implementations, REQUIRE will do something approximately like ??>> calling ASDF:OOS (if asdf.lisp is loaded). On others, it ??>> doesn't. LispWorks is one of those others. HB> But I already loaded them with asdf:oos. HB> Why I cannot require them with require ? Basically, you do not need to. That is, the problem is not the lack of REQUIRE, but something else. HB> If I make (defpackage ...) and include all the above packages HB> it always complains that variable LET is unbound, even just HB> for the simplest hunchentoot page ? That's because you wrote defpackage in the wrong way. HB> Someone mentioned in some previous post that this is maybe because HB> I didn't require 'cl package. HB> How do I require cl, is it cl, cl-user or common-lisp ? It was USE-PACKAGE, not REQUIRE. E.g. (use-package :cl) (You don't need to do it explicitly -- just write (:use ...) part in your defpackage form.) A lot CL beginners confuse packages and modules/systems. Packages are merely namespaces. Modules/systems are pieces of code. They are not directly related, as a piece of code might use or define more than one package (namespace). REQUIRE and ASDF operate on systems/modules. defpackage and use-package operate on packages.
From: Jorge Gajon on 18 Jun 2010 12:49 On 2010-06-18, Haris Bogdanovi� <fbogdanovic(a)xnet.hr> wrote: > (asdf:oos 'asdf:load-op 'hunchentoot) > (asdf:oos 'asdf:load-op 'parenscript) > (asdf:oos 'asdf:load-op 'cl-who) > > Evaluation of the above three lines goes without a problem. > If I try to require any of the above modules I get the error unknown module. > Even if I try "(require 'cl)" I get the same error. > Where is the problem ? > I use lispworks on windows. > The others have already explained the problem and misunderstandings you had. Once you have loaded a module using 'asdf:load-op, there's nothing else you need to do. When you define a package you can specify the packages from which you want to import their symbols. This is only needed if you don't want to fully qualify access to them. $ ./sbcl This is SBCL 1.0.34, an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. CL-USER(1): (asdf:oos 'asdf:load-op 'hunchentoot) CL-USER(2): (asdf:oos 'asdf:load-op 'parenscript) CL-USER(3): (asdf:oos 'asdf:load-op 'cl-who) CL-USER(4): (defpackage #:test (:use #:cl #:hunchentoot #:parenscript #:cl-who)) #<PACKAGE "TEST"> CL-USER(5): (in-package #:test) CL-USER(6): (with-html-output-to-string (*standard-output*) (:h1 "This is Working") (:script (str (ps (alert "I hope so"))))) "<h1>This is Working</h1><script>alert('I hope so');</script>" But you could create a package without importing the external symbols of other packages and still refer to them by fully qualifying them. CL-USER(7): (defpackage #:other-test (:use #:cl)) #<PACKAGE "OTHER-TEST"> CL-USER(8): (in-package #:other-test) CL-USER(9): (cl-who:with-html-output-to-string (*standard-output*) (:h1 "Other test") (:script (cl-who:str (parenscript:ps (alert "yes it is"))))) "<h1>Other test</h1><script>alert('yes it is');</script>" Well I'm not sure if "fully qualifying" is the correct term in Common Lisp land. One document to read: http://www.flownet.com/ron/packages.pdf Regards.
From: Haris Bogdanovi� on 18 Jun 2010 15:50 Thanks, it works now. ------------------------------------------------------------------------------ (asdf:oos 'asdf:load-op 'hunchentoot) (asdf:oos 'asdf:load-op 'parenscript) (asdf:oos 'asdf:load-op 'cl-who) (hunchentoot:start (make-instance 'hunchentoot:acceptor :port 5000)) (push (hunchentoot:create-prefix-dispatcher "/" 'start-page) hunchentoot:*dispatch-table*) (defun start-page () (cl-who:with-html-output-to-string (*standard-output*) (:html (:body (dotimes (x 10) (cl-who:htm (:p "Some text"))))))) (setf hunchentoot:*message-log-pathname* "c:/log.txt") ------------------------------------------------------------------------------
From: Jorge Gajon on 20 Jun 2010 13:47 On 2010-06-18, Haris Bogdanovi� <fbogdanovic(a)xnet.hr> wrote: > Thanks, it works now. > > ------------------------------------------------------------------------------ > (asdf:oos 'asdf:load-op 'hunchentoot) > (asdf:oos 'asdf:load-op 'parenscript) > (asdf:oos 'asdf:load-op 'cl-who) > > (hunchentoot:start (make-instance 'hunchentoot:acceptor :port 5000)) > > (push (hunchentoot:create-prefix-dispatcher "/" 'start-page) > hunchentoot:*dispatch-table*) > > (defun start-page () > (cl-who:with-html-output-to-string (*standard-output*) > (:html > (:body > (dotimes (x 10) > (cl-who:htm > (:p "Some text"))))))) > > (setf hunchentoot:*message-log-pathname* "c:/log.txt") > ------------------------------------------------------------------------------ > > Hello Haris, I'm experimenting with my first Common Lisp web application, using Hunchentoot and CL-WHO as well. The data is stored and queried from a CouchDB database using the library CLOUCHDB. I have my code at the following Mercurial repo, it may be of interest to you. http://bitbucket.org/gajon/tomate It's still a very early application, I'm still trying to find a style, and I'm no expert. As I said it's my very first attempt at a web application with Common Lisp (although I've done several web apps with other languages.) To give you a rough guide; the interesting files are inside the `src` folder. The file `tomate.lisp` contains the two classes that I'm using to represent the objects in my application (users and tasks). These objects are queried from the backend database with the functions defined in the file `data.lisp`. These functions also do the job of making instances of new objects with the data obtained from the database, and saving new objects back to it. The file `web.lisp` contains the definitions of the visible web pages that the user of the application interacts with. Here you'll see all the calls to the data retrieval functions. This file also uses functions and macros defined in the `utils.lisp` file. Again I repeat that I'm no expert at this, so please be critical of what you see, and always ask yourself if something can be done better. And of course, if you'd like to ask me something about the code I'll be happy to explain it. Regards.
From: D Herring on 21 Jun 2010 01:01 On 06/18/2010 10:58 AM, Raffael Cavallaro wrote: > On 2010-06-18 10:25:10 -0400, Haris Bogdanovi� said: > >> But I already loaded them with asdf:oos. >> Why I cannot require them with require ? > > because the behavior of require is defined by the ANSI Common Lisp > Standard: > > <http://www.lispworks.com/documentation/HyperSpec/Body/f_provid.htm> > > ASDF, OTOH, is not part of the standard. > > specifically, require's semantics are: "If the pathname-list is nil, an > implementation-dependent mechanism will be invoked in an attempt to load > the module named module-name" > > You're invoking require without a pathname argument, so you're invoking > implementation-dependent behavior which is generally not a good idea > unless you're absolutely certain what that implementation-dependent > behavior is. > > Require had this standard semantics before asdf ever existed, so it's no > surprise that some implementations, with their own system definition > facilities (e.g., LispWorks) that predate Another System Definition > Facility, don't have a require that hooks into asdf. FWIW, CL impls generally have one of two methods for extending require. 1) Install a function that gets called to look for and load a module. 2) Install paths that get searched for files having the module's name. Some ASDF libraries actually push their name to *modules* in an attempt to make require happy. Not sure that's a good idea. - Daniel
First
|
Prev
|
Pages: 1 2 Prev: Jewish Pirates of the Mediteranean Next: So this seems vaguely lisp machine-y |