freenode/#lisp - IRC Chatlog
Search
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
16:48:11
flip214
If I need a function on the host and in javascript, how can I tell Parenscript to provide both?
16:48:26
flip214
a (PS (DEFUN ...)) results in a string that's to be sent to the client only, right?
16:50:55
flip214
Bike: well, things like (AREF) and (1+) etc. are the same, for many practical purposes.
16:51:43
Bike
or do some nonsense with #. or macros to avoid actually having it twice in the text, yeah
16:52:12
Bike
i mean, if you have (defun foo (x) x), that's fine in both parenscript and the host, but they go through different compilers, no?
16:52:20
flip214
well, of course I can read the source file at compile time to get the javascript string, and let it be read via ASDF as usual
16:52:43
flip214
Bike: I've got some functions (and a few constants etc.), and I need to have them both in the server and the client.
16:53:14
Bike
just have the code twice, i think. there's like, hardly any relation to having code in parenscript and having it in the host.
18:42:59
fiddlerwoaroof
I believe there's a surprising amount of overlap between parenscript/lisp that makes it somewhat feasible to share code between the languages
18:44:18
fiddlerwoaroof
flip214: one thing you could do is put all the common functions into their own files, include them with asdf and then serve them with a handler that loads them at runtime (or compile-time via macros)
18:45:54
fiddlerwoaroof
something like: (ps:ps (asdf:find-component (asdf:find-system :fwoar-lisputils) "hash-functions"))
18:46:19
fiddlerwoaroof
you'd have to make sure that you have defined a JS "runtime" that conforms to your expectations, though
19:33:27
borodust
hi Xach, any news about PGP support for quicklisp dists? are there a rough ETA around?
20:16:57
buffergn0me
flip214: it me, new nick, but it's true I have only started hanging out on IRC again recently
20:18:43
buffergn0me
You can have a macro that takes a defun (or a body of code) and returns it as-is for CL, and generates the appropriate code to say "also compile these forms with PS and put the result wherever JS is supposed to go"
20:20:53
buffergn0me
Or you can have a separate file(s) for shared code, that just goes in the ASDF definition, and then also gets compiled with PS with whatever tooling you have set up to compile/concatenate/serve etc JS
20:32:36
Grue`
sharing code between Lisp and Javascript? Sounds like the job for cl-clojure-template ;)
20:38:14
Grue`
ecraven: https://stackoverflow.com/questions/44698426/how-do-setf-works-under-the-hood
20:39:51
Grue`
interestingly setq also uses setf expansions, because a symbol-macro can expand into a generalized reference
20:40:35
ecraven
hm.. so defsetf "just" associates the setter with a getter, and the macro expansion of setf then uses that setter?
20:45:34
flip214
buffergn0me: do you have an example? didn't see that kind of code sharing in the docs.
20:46:43
Bike
ecraven: defsetf and define-setf-expander and so on fundamentally just define how setf forms macroexpand
20:47:23
flip214
in ITERATE, can I have some more variables stepped with a generator automatically? something like this:
20:48:00
flip214
(ITERATE (generate element in list and el-car = (car element) and el-cdr = (cdr element)) ... (next element))?
20:48:58
Grue`
ecraven: there can be "setf expanders" defined for various functions, and also there exist functions named "(setf foobar)" that are also used by setf