freenode/#lisp - IRC Chatlog
Search
3:27:03
Ukari
but when I `:import-from :foo :bar`in package `foo-test`, and try to use method `(bar)`, it works?!
3:27:03
Ukari
I was thought that if a symbol `bar` is not export, it must needs to be import by `:import-from :foo ::bar`
3:32:14
gilberth
At times you only want to import a few symbols. But those use cases are. Usually, you export your "interface"/"API" and just use that package from another.
3:35:27
Ukari
I am used to use import-from to import a exported symbol from other packages, and only use (:use ) for package :cl, because it shows a clear dependency
3:36:20
gilberth
Well, that is not like most people do that. As you pointed out: exporting a symbol goes with using a package.
3:43:17
gilberth
Hacking is about communication with the next hacker, who will read the code, also. And that next hacker could as well be me in 20 years. When I see :import-from in a DEFPACKAGE, I wonder: Why?!
3:46:16
Ukari
if there is not a explicit :import-from in defpackage, the next hacker might don't know where a function he never seems before comes from, especially when he read the code in github
3:57:54
gilberth
Ukari: And then you do not use :import-from for the COMMON-LISP package and list all 978 symbols.
4:00:07
Ukari
yes, i use (:use :cl) for package 'common-lisp', and in package foo-test, i will also use (:use fiveam) for a test framework
6:30:55
slightlycyborg
Hello. I am doing serial stuff. I need to convert a Lisp int which represents a 2 byte signed short into a list of 2 lisp ints that represent the bytes
7:04:56
verisimilitude
What LDB lets you do is get a section of an INTEGER and have it right-justified.
7:05:12
verisimilitude
You should also look into MASK-FIELD, which doesn't right-justify the result.
10:05:11
adip
Hi, could you explain what's wrong with this example? https://ideone.com/1i1fEv Why does compiler complain about undefined variable n ?
10:26:01
adip
no-defun-allowed: I've learned some. What's wrong with that example other than wront variable in third line?
10:31:27
no-defun-allowed
And well, unless your goal is to make people retch, it's usually a good idea to make sure your code is formatted well. Not only is it a sign of politeness, it also makes people usually quicker to respond as they can read nicely formatted code easier.
10:32:11
makomo
adip: if you're using Emacs + SLIME, just run "slime-reindent-defun" to indent the top-level form you're currently in
10:33:53
no-defun-allowed
https://lisp-lang.org/style-guide/ is a little long, but has good examples.
10:38:52
adip
next serious question, Is there a step by step debug mode for sbcl or clisp? something similar to gdb?
10:48:38
adip
it kinda works :D. One last question, for now. How can I make my f function to actually return calculate value... https://ideone.com/hZ3zYc
13:13:56
jmercouris
so in a defpackage you can export a bunch of symbols, that's fine when you load a package
13:14:26
jmercouris
how can you export more symbols from a package when you've already loaded a package?
13:14:49
jmercouris
or for example, if you delete an export symbol in the defpackage it will complain
13:41:30
pjb
jmercouris: (in-package "BAR") (defpackage foo (:use cl) (:export foo1 foo2)) interns the symbols bar::foo, bar::cl, bar::foo1 bar::foo2. If you then (use-package "FOO"), then bar::foo1 and bar::foo2 collide with foo:foo1 and foo:foo2!
13:42:11
jmercouris
try this (defpackage :xyz (:export :fish)), then evaluate (defpackage :xyz (:export :salmon))
13:42:16
pjb
Indeed, it's easier. In defpackage, all the symbols are actually symbol name designators, ie. string designators, so you can use characters, symbols, keywords, or just strings!
13:45:06
pjb
For example, you could first (delete-package "XYZ"), but when doing so, you might get the debugger invoked with restarts about what to do for the packages that used the old package.
13:45:39
pjb
I have a com.informatimago.common-lisp.cesarum.package:delete-packages that recursively deletes a packages and all its dependent packages…
13:47:21
pjb
The point here is that you are mutating a lisp image. defpackage is not designed specifically for package mutation: using it on a package that already exists gives the implementation dependent effects you are seeing. Instead of using package macros, use package functions such as export import use-package unuse-package to mutate the lisp image.
13:47:51
pjb
OR, use asdf to load the packages.lisp file once to define the package once, and reboot a fresh lisp image when you change the package.
13:48:24
pjb
OR, wrap your second defpackage in a handler-bind that will select the right restarts automatically.
13:48:49
pjb
Note that you need either an AI, or using input to specify the right restarts to select automatically!
14:02:08
Xach
jmercouris: It would be nice to have something that did "make the package definition be exactly this"
14:05:08
jmercouris
swank does some stuff to the lisp image when it gets the idea of re-evaluating a form containing a defpackage