2

I am new to Common Lisp. Even more when the topic is packages and systems. I am working with a program and something intrigues me. Btw, I am using SBCL and Slime (Emacs).

Being on the top-level (CL-USER) I can do:

CL-USER> (application-name/file-name::%function-on-parenscript)

This works! Then, I change to be inside the package:

CL-USER> (in-package :application-name)

Ok. So, I thought that after being inside the application name:

APPLICATION-NAME>

I would be able to do just:

APPLICATION-NAME> (file-name::%function-on-parenscript)

However, this does not work. It just works if I do:

APPLICATION-NAME> (application-name/file-name::%function-on-parenscript)

1 - Why is the application-name necessary if I am inside application-name?

2 - Why sometimes I need to use :: and other times I use just : to call things?

Common Lisp packages are there to solve namespaces problems. But they really intrigue me.

Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30

1 Answers1

5

application-name/file-name and application-name are two distinct packages that are similar in names only for human readers but are otherwise unrelated.

Symbols are either written with a package prefix or not. The package is the part on the left of the colon or double-colon when there's a package prefix.

The double colon is a way to refer to symbols that are not exported from the package (they are private).

A single colon is for symbols that are exported.

If the symbol you want to refer is "accessible" in the current package, for example because you are "using" it's package and it is exported, then you can write the symbol without a package prefix

See Programming in the Large: Packages and Symbols for details

coredump
  • 37,664
  • 5
  • 43
  • 77