PDA

View Full Version : how to use self-made packages?


Harry
04-20-2004, 01:06 AM
In file file_utils.lsp, I like to store all file utils I made.


### start contens of file_utils.lsp ###

(in-package :harry-file-util)
(use-package :oli)

;-----------------------------------------------------------------------------

(defun file-to-list (&key filename)
...
)
### end contens of file_utils.lsp ###


I have made a central lisp routine to start calling self made lisp code. I load this file (dev_central.lsp) from sd_customize.


### start contens of dev_central.lsp ###
;load lisp development functions

(use-package :oli :harry-file-util)

(setf central_dir "Z:/users/harry/lisp")

;collection of file utils
(load(format nil "~A/utils/file_utils.lsp" central_dir) )

(file-to-list :filename "Z:/users/harry/lisp/materials.txt")
### end contens of dev_central.lsp ###


When I run dev_central.lsp, I recieve this error:
The function BETA-FILE-TO-LIST is undefined.

Does anyone have any idea what I am overlooking?

dorothea
04-20-2004, 03:19 AM
Hi Harry,

You define the function file-to-list in the package harry-file-util. Then it is a symbol in this package. But when you call the function you didn't specify a in-package. So the system doesn't know where to look for the function. (Not sure, but I think in OSD it defaults to mei-package.)
You can now add the call to in-package in file dev_central.lsp or you add the package before the function call.
(harry-file-util::file-to-list .....)

Hope this helps.
Dorothea

Harry
04-20-2004, 04:01 AM
Originally posted by dorothea
...
You define the function file-to-list in the package harry-file-util. Then it is a symbol in this package. But when you call the function you didn't specify a in-package. So the system doesn't know where to look for the function.
...
[/B]

I always thought that by saying : (use-package :harry-file-util)
I declared this package to be read when I use a function.
Because i say: (use :oli) I can use all kind of sd functions without writing oli:: before them...

Or did I miss something completly?

Best regards Harry.

dorothea
04-20-2004, 04:10 AM
Hi,

You can use all functions from oli-package because the functions are exported. There exists a kind of two-level hierarchy in lisp: internal and external sysmbols. You can read more about it in all lisp books. When you write in-package xxx and there define a function then this function is internal to the package xxx.
Have you ever noticed that after the package name there are sometimes two : and sometimes a single : ? This is because of the logic with in-package/use-package and internal and external symbols.

Dorothea

Harry
04-20-2004, 04:20 AM
Originally posted by dorothea
Hi,

You can use all functions from oli-package because the functions are exported. There exists a kind of two-level hierarchy in lisp: internal and external sysmbols. You can read more about it in all lisp books. When you write in-package xxx and there define a function then this function is internal to the package xxx.
Have you ever noticed that after the package name there are sometimes two : and sometimes a single : ? This is because of the logic with in-package/use-package and internal and external symbols.

Dorothea

Thanks for the quick reaction and the clear answer!