freenode/#lisp - IRC Chatlog
Search
20:40:34
aeth
This actually is cool because I do type-checking from the initialize-instance, so it type checks at compile time, but not when calling the function at runtime, at least in SBCL.
20:41:22
aeth
CCL behaves the same way, except provides less information to verbose. I get a bunch of "Hello"s when compiling, and not at runtime.
20:42:17
aeth
This is actually cool, though, because assuming that it's safe, it does compile time type checking
20:43:06
Bike
if make-load-form is being invoked, there's an actual object you're passing to the compiler.
20:43:24
Bike
so, at one point you initialized that, and of course it did your initialize-instance method that does type checks or whatever.
20:43:32
aeth
Right, that object, generated in a macro at compile time, already had its initailize-instance called and its types checked, just at compile time
20:44:46
Bike
this is kind of an odd ontological question. the object has already been initialized in the building image, but not necessarily in the loading image
20:46:04
whoman
i think this having a standards thing, is making things a bit more rough than they have to be
20:46:04
Bike
the way it's described it can definitely not call initialize-instance, and in fact it probably shouldn't.
20:46:48
whoman
a lot of bandwidth spent on dealing with different implementations, may as well write in anything else that isnt portable
20:47:17
Bike
and the implementation i work on is the same, i just didn't notice because argleblargle
20:47:33
whoman
i dont understand, most lisp chat here on irc is about sbcl internals, how this implementation is etc.. only "CL" when it comes to other languages. hmmm, feels like my footing is suddenly in mud
20:48:03
aeth
If I can generate a CLOS object or struct at compile time (or even more elaborate combinations! the CLOS object I'm talking about is filled with simple structs!) using this trick, then maybe I should.
20:48:03
Bike
we're talking about how this behavior is actually universal across implementations, whoman, leave your musery for another day
20:48:46
Bike
aeth: make-load-form-saving-slots is defined more vaguely than i thought, is the deal- "Returns forms that, when evaluated, will construct an object equivalent to object, without executing initialization forms. The slots in the new object that correspond to initialized slots in object are initialized using the values from object. Uninitialized slots in object are not initialized in the new object."
20:49:10
whoman
phoe: thats where i have been for the last few months, until i guess this week when i switched irc clients.
20:49:58
aeth
whoman: I often ask in here to see just how universal some behavior I observed in SBCL, or SBCL and CCL, is.
20:51:42
Bike
it's an obscure bit of the standard, but it makes perfect sense within the fasl model, so i'd expect it to work everywhere fine
20:54:25
aeth
What's the best way to make sure that the object stays valid? I verify it in a function that I call from initialize-instance (it's in a separate function so I can verify it at any time outside of that, too, and it's a function instead of a method because I want check-foo to tell me it's a valid foo, not a valid object)
20:55:05
aeth
Not every implementation respects :type (and not everything can be encoded in a type, anyway) and it can even vary depending on debug level.
20:55:34
Bike
assuming "validity" means some invariant among the slot values, depends on what you wanna let users do
20:55:45
Bike
for normal purposes, your after method and maybe some checks in the accessors seems fine
20:56:04
Bike
disallow slot-value and standard-instance-access and reinitialize-instance (or you could put your method in shared-initialize :after instead)
20:58:12
aeth
(defmethod (setf foo) :before ...) or something? Or are the setters called something different?
20:58:15
Bike
for my "traitlets" thing i ended up writing this whole crappy validator pattern but it basically amounts to :around methods
21:22:19
jack_rabbit
How many projects (if any) use generated documentation? I would imagine it wouldn't be too difficult to write a decent doc generator for CL.
21:22:52
Shinmera
There's at least a brazillion if by "generated" you mean things that gather docstrings and put them in one place.
21:23:55
hjudt_
i solved my issue with dexador using wireshark to inspect packets: the solution is to add another header "Accept-Encoding: gzip" in addition to "Accept: application/json".
21:24:11
sjl
There's also several sites that do it automatically for all projects in quicklisp, which annoys those of us that write more documentation and now have to compete with them in search results.
21:25:07
aeth
Sounds like a nightmare if you're one of the rare people to actually do things the right way with documentation.
21:25:23
jack_rabbit
I imagine a solution to that may be to include a link to the actual documentation it a place those sites will render.
21:26:53
sjl
They render the README, so at least there's a chance the user will see the actual docs if you link it there. Still not ideal.
21:27:25
_death
the other day someone mentioned gigamonkey's manifest.. played with it a little https://github.com/death/manifest
21:28:28
Shinmera
Staple also has a server component. (ql:quickload :staple-server) (staple-server:start)
21:29:30
sjl
I render to plain HTML and host it with bitbucket's pages thingy. But yeah, there are a bunch of people who generate docs based on some prose + docstrings.
22:10:24
phaul
few years back I watched a write yourself a scheme ( I think ) on youtube, which was very entertaining, all I remember that it was very pink, and lots of hello kitty etc and maybe it was done in c-lisp. I tried to google it but couldn;t find it. Does anybody have a link?
22:13:51
whoman
https://stackoverflow.com/questions/5093513/how-to-see-docstrings-and-other-symbol-information-in-common-lisp-repl
22:15:50
aeth
Well, that was strange. I had a type error in a macro. I changed the code. It worked, but wasn't what I wanted. I then changed it back to the original, and it worked. I guess C-c C-c doesn't always work if something in the same file is recompiled because the of compilation unit optimization stuff.
22:17:23
pjb
phaul: Have a look at Lisp in Small Pieces http://pagesperso-systeme.lip6.fr/Christian.Queinnec/WWW/LiSP.html http://pagesperso-systeme.lip6.fr/Christian.Queinnec/Books/LiSP-2ndEdition-2006Dec11.tgz
22:25:52
phaul
nope. but thanks anyways. It was a cool video I would watch it again. also I saw it many years ago probalby it's gone and lost for ever
22:34:12
_death
emaczen: (mapcar #'documentation (list (find-method #'class-name '() (list (find-class 'class))) #'car (find-class 'class)) '(t t t))
22:37:33
Nouv
How does `eval` work at a low level? Where is the parsed function placed in memory? In the stack?
22:42:19
Bike
(defun eval (form) (typecase form (symbol (symbol-value form)) (cons (apply (first form) (mapcar #'eval (rest form)))) (t form))) handles function calls, self evaluating object,s and special variables
22:42:32
|3b|
however it wants... could be anywhere from looking at each form and directly calling a function to do whatever that form says, to compiling it to native code and running the result, to writing out a file, calling a C compiler on it, loading result as a shared object, and calling a function from that
22:43:43
|3b|
sbcl for example usually compiles to native code, but directly evaluates some simple forms
22:44:55
|3b|
it is common to include something resembling "an assembler" in the compiler of implementations that generate native code
22:45:10
|3b|
(usually just as a bunch of functions in the image, same as the compiler though, not a separate program)
22:46:23
|3b|
at the point where you want to go from "a piece of data on the heap" (the output of the compiler/assembler) to "running function", there might need to be some interaction with the processor/OS, for example changing page permissions or flushing caches
22:47:10
|3b|
assuming you are compiling something too large to fit in a register, which is generally pretty much anything :)
22:48:01
|3b|
parts of it might be on the stack during processing, like any other data, but generally the end result and most of the larger parts during processing will live in the heap
22:48:12
Nouv
My questions are because I want to understand how to write (and eventually actually write) a lisp compiler, just as a learning experience
22:48:28
pmc_
Nouv you might want to consider reading Chapters 4 and 5 of Structure and Interpretation of Computer Programs.
22:48:34
Nouv
I'm a CS student but can't take programming theory modules until next semester and I'm slightly impatient
22:50:06
pjb
Nouv: and really the books you will study beyond your courses will be the ones you remember the best! Take your time to study as many as you want of them!
22:58:26
phaul
ok, I think I've found what i was looking for. all I can say is that never take off those beer googles. :D
23:10:08
Nouv
Does that mean every compiled lisp program (at least from sbcl and other lisps that support eval) has a mini compiler in it?
23:13:55
Nouv
Why would they do that? Isn't it required for macros, and macros are a fundamental part of lisp?
23:15:04
aeth
I think that they use a tree-shaker to provide exactly the subset that the program needs, and nothing more. And macro expansion is (usually?) done at compile time, so if the macro isn't *called* at runtime... they can probably tree shake that away in the actual compiled binaries of the program.
23:23:13
|3b|
some people object to the extra size of carrying around a compiler when you don't need one, so some lisps let you remove it
23:37:07
Nouv
Are there any compilers written in lisp that turn lisp into assembly? Any as in available somewhere like github?
23:42:22
pillton
Nouv: SBCL, CCL, CMUCL, LispWorks and AllegroCL all do. ECL outputs C code which is compiled and loaded in to the run time environment.
23:43:23
Colleen
Bike: drmeister said 12 minutes, 14 seconds ago: - we figured out the problem frgo is experiencing - calling foreign clbind methods with more than three arguments (and probably functions with more than four arguments) has a problem.
0:14:38
borei
hmm, i have delimma. i have function, in some cases argument is just number, but in some cases - list of numbers. passing list of one number - will work but doesn't look good. on the other hand doing type parsing inside function - also not elegant solution. generic function and methods on top of it ?
0:19:42
attila_lendvai
if you want to wander that way, then get alexandria, preferably using quicklisp.org
0:21:38
pjb
Of course, you have the choice to write it in your program, or to depends on tens of unspecified libraries.
0:26:27
pjb
(defgeneric ensure-list (x) (:method ((x cons)) x) (:method ((x null)) x) (:method ((x t)) (list x)))
0:27:32
pjb
Notice, you may want: (defgeneric ensure-list (x) (:method ((x cons)) x) (:method ((x null)) x) (:method ((x t)) (list x)) (:method ((x vector)) (coerce x 'list)))
0:31:24
borei
(defgeneric myfun (args)) --> (defmethod myfun ((fixnum arg)), (defmethod myfun ((cons arg)) ?
0:32:15
pjb
borei: one thing you have to consider with CLOS also, is that method dispatching can be done on multiple arguments.
0:32:45
pjb
(defgeneric f (x y)) (defmethod f ((x integer) (y string)) …) (defmethod ((x string) (y real)) …) etc.
0:33:11
pjb
Now the point is that you would gather together (perhaps in the same file), functions or methods that are logically related.
0:33:32
pjb
You don't have to put everything related to a class in the same file. Or everything related to a generic function in the same file.
0:35:04
pjb
Sometimes you just want to define a function with all its methods already defined. Using defgeneric with :method is a nice way to do it.
0:35:24
pjb
Other times, you want to keep the methods close to a class. A file per class with a defclass and all the defmethod in it.
0:35:45
pjb
Other times, you want to add a mechanism, so you will have a file with defmethod for all the classes in your system.
0:38:07
pjb
If you realize that when you have to implement a user story, you must modify all the files in your project, then perhaps something is wrong.
0:38:22
pjb
Perhaps you should just add a new file gathering all the methods implementing this user story.
0:44:07
borei
for &optional arguments can i specify type, something like (defmethod xyz ((x single-float)(y single-float) &optional (y single-float)) ?
0:46:14
pjb
(defmethod xyz ((x single-float) (y single-float) &optional z) (check-type z (or null single-float)))
0:48:00
specbot
Generic Function Lambda Lists: http://www.lispworks.com/reference/HyperSpec/Body/03_db.htm
1:12:55
whoman
https://stackoverflow.com/questions/5093513/how-to-see-docstrings-and-other-symbol-information-in-common-lisp-repl
1:14:05
emaczen
Thanks Bike, I was confused because emacs doc made it look like documentation only for class slots
1:59:41
Bike
(remove-if-not (lambda (method) (find class (method-specializers method))) methods), i think
2:52:09
goreye
Hi, I'm trying to do `(write-byte (char-code #\A) *standard-output*)` which works fine on SBCL but fails on SLIME.
2:54:35
goreye
Any way I can test write-bytes on stdout? Though I'm writing the function for generic streams, but I'm testing it on standard output
3:35:39
nydel
at sdf.org pubnix we try to build sbcl for all users on netbsd8. if there is any special bsd unix instructions, the system op wants me to pass them on. thanks in advance if you know anything!
4:39:06
Guest16495
pjb, sjl, Shinmera: thank you for the answers about ctrl-c in cl-charms/curses development. `stty intr undef` was the magic i needed!
6:33:42
nydel
jack_rabbit: thanks for asking! we got 1.4.1 up on the meta-array which is a red-hat-like linux 2.2 kernel. all my programs work!
6:34:05
nydel
but the cluster (the main place - about 5 or 6 machines with a shared user filesystem) runs NetBSD8
6:34:48
nydel
in fact we're the only live beta of netbsd8. the developers are working on the kernel from 7 on our system. so i guess it is proving difficult to easily install SBCL on the bsd system for all users
6:35:12
nydel
i'm hoping to find some existing documentation on bsd-specific sbcl building or to begin creating such a thing as we go
6:35:39
jack_rabbit
I know clisp is currently running there. Having an updated version of that might be easier?
6:36:32
jack_rabbit
The clisp there is (oddly) new enough that I was able to load asdf3 into it and actually compile stuff from quicklisp, which I was not able to do with the old SBCL on MA.
6:36:41
nydel
savvy jack_rabbit ! i guess clisp can be used to build sbcl. so that's exactly what we're trying, to update clisp (we have a version from 2010! woof.) then the sbcl hopefully will follow
6:37:03
nydel
there is a pkgsrc entry for sbcl 1.3.1 and that is plenty current enough for the general SDF population to be using.
6:38:19
nydel
a package i used to rely on called cl-daemonize i guess is no longer listed in quicklisp repository. it's how i backgrounded my hunchentoot-behind-apache webserver (then my sdf website would fetch sdf.org:9903, an arbitrary port running my server)
6:40:38
jack_rabbit
nydel, You can try loading my little gopher client there. https://github.com/knusbaum/cl-gopher
6:41:44
jack_rabbit
That one's different than the one I showed you before. That one is text based and the other is built on McClim, so it's graphical.
6:43:04
jack_rabbit
Although, actually, the main branch there won't work there, since I can't load iolib on the cluster.
6:43:40
nydel
in an ideal world, a person simply does ./cl-gopher-start.sh from the command line yes?
6:44:21
jack_rabbit
This thing is super alpha, though. I haven't made much effort to make it portable yet.
6:44:50
jack_rabbit
however I haven't been able to get slime working with the current clim on the cluster.
6:45:35
jack_rabbit
cl-gopher:text-browser is the function to start the interactive browser, though.
6:45:40
nydel
right away the lsh script gives "system cl-gopher not found" a quicklisp error ... huh
6:47:03
nydel
yes quicklisp is up to date and asdf3 & 2 ... let me get cl-gopher in my quicklisp local real quick
6:49:26
jack_rabbit
Not sure. That might work! It doesn't matter where you place it if you manually load the .asd file.
6:51:06
nydel
that was the idea. and the script progressed quite a ways before running into a very long foreign interface problem that i'm just now looking into
6:52:27
jack_rabbit
Yes. iolib requires libfixposix. Instead, check out the 'iolib->usocket+flexi-streams' branch.
6:53:10
dundee
If I were to make a purely functional lisp, would it still be possible to read in code from imperative languages like C via macros?
6:53:56
phoe
functional paradigm is equivalent to the imperative one, everything computable in one is computable in the other and vice versa.
6:54:19
phoe
so you can write C-reading macros in either of them and compile them into something that you can execute.
6:54:36
nydel
i'm trying on my local machine (not part of SDF) in a slime. having put cl-gopher in quicklisp local-projects, i get a halt at iolib. so i must need to install iolib, with which i am not familiar.
6:54:58
nydel
this is a debian machine, should iolib be something i retrieve by hand, with a lisp, from linux repo?
6:55:02
phoe
so you can do even the blasphemy of grabbing a purely imperative language like C and compile it into a purely functional language like your hypothetical Lisp.
6:56:25
jack_rabbit
nydel, No, iolib is a common-lisp library. However, it depends on libfixposix, which you should be able to install with 'apt-get libfixposix'
6:57:13
dundee
phoe: but you can do all sorts of data mutation in C functions, for loops, and other control structures. I'm sure any sufficiently smart compiler could optimize a naive translation (see: GHC, Stalin Scheme), but would a set of naive translations consistently produce legal lisp?
6:57:55
phoe
dundee: it doesn't matter. in imperative programmming, mutable state is contained everywhere; in functional programming, functional state is isolated and contained in function arguments.
6:58:23
nydel
let's try that then first. i feel like since i haven't used iolib it is probably something i need to spend an hour or two getting learned on.
6:58:24
phoe
in imperative programming, you mutate this global state; in functional programming, you change the arguments passed from function to function.
6:59:13
phoe
functions are directly translatable to functional programming, loops can be transformed into recursion, other control structures, like switches, can be turned into pattern matching.
6:59:37
phoe
and right now I consider only the *possibility* - yes, it is possible. I do not consider whether it's *feasible*.
7:01:02
phoe
and in new-state, a functional data structure, the alist or whatever now contains a mapping from var to new-value.
7:01:34
dundee
I suppose passing continuations from new state object returns are a way to consistently achieve what I'm thinking of.
7:06:17
nydel
jack_rabbit: i clone the other branch (and put it in quicklisp/local-projects for good measure) ... in a slime environment, should i asdf load cl-gopher.asd, or some other action e.g. evaluate cl-gopher.lisp & client.lisp etc?
7:06:44
jack_rabbit
If it's in local-projects, all you should need to do is (ql:quickload 'cl-gopher)
7:08:57
nydel
the same type of error (this is the newer branch not master) condition of type iolib/grovel:grovel::grovel-error ... which happens when apparnetly a call is made to g++
7:10:01
jack_rabbit
Check the .asd file and make sure it matches https://github.com/knusbaum/cl-gopher/blob/iolib-%3Eusocket%2Bflexi-streams/cl-gopher.asd
7:11:01
nydel
oh here is the problem (my fault) - i am not sure how to clone this branch with git. i didn't read what i coppied, it suggest the main cranch
7:13:57
nydel
jack_rabbit: right i had to do clone -b "io.... you get it. i got it, quicklisp loaded and evaluated it, all set! what do i run to get going (cl-gopher:.....)?
7:15:46
jack_rabbit
Oh! and if you want to allow it to download files, you can add the keyword :allow-downloads (cl-gopher:text-browser :allow-downloads t)
7:18:26
jack_rabbit
There's currently no 'quit' option, so you just have to interrupt it with C-c C-c and return to toplevel to get out.
7:20:41
nydel
this is great jack_rabbit i'm reading new phlog entries from today and not in a "hey this a fun novelty" way but in a "this is how i prefer to do this" way
7:21:50
jack_rabbit
It still needs quite a bit of work. Honestly, the browser was mostly an afterthought. cl-gopher's main intention is to be a protocol library that I'm going to put into clim-gopher and my yet-to-be-named gopher server.
7:23:24
nydel
i haven't seen a good clim project in a while so i'm excited to try that. there (AFAIK) aren't a lot of good true gopher GUI browsers. there are proxies and extensions for firefox etc
7:24:10
jack_rabbit
It's available and working now, if you wanted to try it out. It does need iolib currently, but I could switch that over real quick.
7:25:13
nydel
i'm right now working on getting iolib working locally (and understanding what it is/does for myself) ... just give me a little bit to poke around, i feel like this is something i should know how/why it works
7:29:46
nydel
it's probably for the best especially for software that can work on multiuser systems without a lot of hassle
7:32:08
nydel
the meta-array allows for x11 forwarding. i run 'links2 -g' on it often and sometimes firefox. tomorrow i will try to get your clim client running that way
7:33:06
nydel
oh the possibilities. if a commonlisp gopher server, you can have a multi-user repl or version control repo. what fun!
7:35:15
jack_rabbit
nydel, Yeah! My server currently is translating news articles to plaintext, but the possibilities are large.