Created
January 16, 2020 18:49
-
-
Save dnaeon/5018d1e5ebbc22a59f67a8e1b6a6ef35 to your computer and use it in GitHub Desktop.
CL packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Path: ~/quicklisp/local-projects/foo/src/bar.lisp | |
(defpackage foo.bar | |
(:nicknames :foo.bar) | |
(:use :cl) | |
(:export :my-function)) | |
(in-package :foo.bar) | |
;; :arrows is not imported, but I can still access it | |
;; | |
;; What is the point of :USE'ing or :IMPORT-FROM it in that case??? | |
(defun my-function () | |
(arrows:-> 2 (+ 40))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; | |
;;;; Consider that we have the following system in our Quicklisp's local-project (e.g. ~/quicklisp/local-projects) | |
;;;; | |
;;;; Path: ~/quicklisp/local-projects/foo/foo.asd | |
(defpackage :foo-system | |
(:use :cl :asdf)) | |
(in-package :foo-system) | |
(defsystem :foo | |
:name "foo" | |
:description "Foo system" | |
:version "0.1.0" | |
:author "John Doe <john.doe@example.org>" | |
:maintainer "John Doe <john.doe@example.org>" | |
:licence "BSD 2-Clause" | |
:long-description "" | |
:homepage "" | |
:bug-tracker "" | |
:source-control "" | |
:long-name "" | |
:depends-on (:arrows) | |
:components ((:module "src" | |
:components | |
((:file "bar"))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CL-USER> (ql:register-local-projects) | |
NIL | |
CL-USER> (ql:quickload :foo) | |
To load "foo": | |
Load 1 ASDF system: | |
foo | |
; Loading "foo" | |
To load "arrows": | |
Load 1 ASDF system: | |
asdf | |
Install 1 Quicklisp release: | |
arrows | |
; Fetching #<URL "http://beta.quicklisp.org/archive/arrows/2018-10-18/arrows-20181018-git.tgz"> | |
; 4.95KB | |
================================================== | |
5,067 bytes in 0.00 seconds (4948.24KB/sec) | |
; Loading "arrows" | |
[package arrows]. | |
To load "foo": | |
Load 1 ASDF system: | |
foo | |
; Loading "foo" | |
[package foo.bar] | |
(:FOO) | |
CL-USER> (foo.bar:my-function) | |
42 | |
CL-USER> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When
ql:quickload
'ing the:foo
system the:arrows
dependency is being downloaded, built and loaded, which in turn makes it readily available for ourfoo.bar
package to use without having to:use
or:import-from
it.What is the point of of using
:use
or:import-from
within thedefpackage
definition, if the dependencies are already loaded and available?