using external modules

Started by joejoe, September 08, 2009, 11:40:58 AM

Previous topic - Next topic

joejoe

hi -



im trying to use the web.lsp module:



http://static.artfulcode.net/newlisp/web.lsp.html">http://static.artfulcode.net/newlisp/web.lsp.html



i added the file



http://static.artfulcode.net/newlisp/web.lsp.src.html">http://static.artfulcode.net/newlisp/web.lsp.src.html



as web.lsp to the



/usr/share/newlisp/modules



directory on my debian squeeze i386 machine and went through the ./configure, make and make install again and tried to do a basic function call like this:


> (Web:parse-url http://www.newlisp.org)

ERR: invalid function : (Web:parse-url http://www.newlisp.org)
> (parse-url http://www.newlisp.org)

ERR: invalid function : (parse-url http://www.newlisp.org)
>


i know i am making a most basic error in trying this.



can anyone say what i am doing incorrectly? thanks very much!

cormullion

#1
This looks wrong:


(Web:parse-url http://www.newlisp.org)



What is the type of the http part? If it's a string, it should be:


(Web:parse-url "http://www.newlisp.org")

It works OK for me after by simply loading the module into a newLISP session:


> (load "/Users/me/code/dragonfly-framework/modules-active/web.lsp")
(lambda ((n 0))
 (when (zero? n)
  (Web:close-session))
 (sys-exit))
> (Web:parse-url "http://www.newlisp.org")
(("scheme" "http") ("user" ()) ("pass" ()) ("host" "www.newlisp.org") ("port" nil)
 ("path" "/")
 ("query" nil)
 ("fragment" nil))
>


I don't do any of that configure/make stuff... :)

joejoe

#2
thanks cormullion!



i thought that by re-installing newlisp w/ the module in place, this would let me not have to load the web.lsp module manually. am i correct about this? i even put it in the nL unpacked modules directory before i re-ran the config/make/make install.



this is what i get when i try to run the http as a string, as you pointed out: (thanks again!)


newLISP v.10.1.1 on Linux IPv4 UTF-8, execute 'newlisp -h' for more info.

> (Web:parse-url "http://www.newlisp.org")

ERR: invalid function : (Web:parse-url "http://www.newlisp.org")
>

m35

#3
Quote from: "joejoe"i thought that by re-installing newlisp w/ the module in place, this would let me not have to load the web.lsp module manually. am i correct about this?


newLISP doesn't automatically detect and load modules, you always have to include a (load) statement to use a module's code.



For example, this should theoretically work (untested)
> (load "/path-to-module/web.lsp")
> (Web:parse-url "http://www.newlisp.org")

xytroxon

#4
I think you are getting confused by how the load and module functions work...



From the newLISP manual:
QuoteEnvironment variable NEWLISPDIR



During startup, newLISP sets the environment variable NEWLISPDIR, if it is not set already. On Linux, BSDs, Mac OS X and other Unixes the variable is set to /usr/share/newlisp. On Win32 the variable is set to %PROGRAMFILES%/newlisp.



The environment variable NEWLISPDIR is useful when loading files installed with newLISP:



(load (append (env "NEWLISPDIR") "/guiserver.lsp"))



(load (append (env "NEWLISPDIR") "/modules/mysql.lsp"))



A predefined function module can be used to shorten the second statement loading from the modules/ directory:



(module "mysql.lsp")


-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

joejoe

#5
Quote from: "xytroxon"I think you are getting confused by how the load and module functions work...



From the newLISP manual:



[...]



-- xytroxon


understood. thank you xytroxon.



i appreciate you taking the time to point this out.

hilti

#6
Hi Joejoe



check out my attempt of "auto-loading" modules. Download Dragonfly framework. It's in the file dragonfly.lsp



Just a few lines of code.



Cheers

Hilti
--()o Dragonfly web framework for newLISP

http://dragonfly.apptruck.de\">http://dragonfly.apptruck.de

joejoe

#7
Quote from: "hilti"Hi Joejoe



check out my attempt of "auto-loading" modules. Download Dragonfly framework. It's in the file dragonfly.lsp



Just a few lines of code.



Cheers

Hilti


thanks for the help Hilti.



im refraining from using bsd/mit/non-copyleft code, so i am sticking to the core modules. i appreciate the insight, and if dragonfly every becomes gpl, you bet i will be all over it. :0)   --joejoe