freenode/#lisp - IRC Chatlog
Search
17:13:36
tfb
shka: I repeatedly find myself having to *implement* dynamic binding in other languages.
17:17:23
shka
pagnol: if you are not using alexandria, quickload it, then (alexandria:curry #'identity x) will do the trick
17:20:21
sonologico
pagnol: the resulting function accepts more combinations of arguments than what you wrote, but it does the trick
17:40:58
dmiles
(so checking to see if anyone made clisp disable its readline and forced rlwrap to takeover or suppliment)
17:55:36
loli
the issue I run into is that I make a few structs to model the type, and I terminate the structure on a symbol
17:56:14
loli
but the issue is that symbols don't really play nice when trying to defmethod as other data structures end on a symbol and there would thus be a conflict
18:44:56
emaczen
SBCL from the debugger with SLIME won't find my sources with M-. or v -- what should I try?
19:01:47
beach
Lots of people just use the default values, and waste a lot of time trying to debug their code with insufficient information generated by the compiler.
19:02:38
emaczen
beach: I have been using CCL to debug since it seems to by default always give me a lot of information in the debugger haha
19:03:40
rumbler31
beach: how would you go about triggering a recompilation once you want to change those values?
19:30:28
pagnol
I've begun littering my code with check-type and assert... presumably this is a very unidiomatic style in cl?
19:33:59
pjb
pagnol: check-type is what you should use (instead of declare type), in ALL your public functions!
19:52:14
pjb
Of course. The post condition of check-type is that the place is bound to an object of the given type.
19:58:23
_death
I think with the python compiler one of the big things was also the converse, that type declarations can perform as type checks (forget safety 0)
20:00:34
Xach
pagnol: adding lots of checks makes it harder to change things in the future. sometimes that's not very important.
20:01:47
pjb
Also, (defmacro disable-assert (&body body) `(macrolet ((assert (&rest args) 'nil)) ,@body)) (#+want-assert progn #-want-assert disable-assert …)
20:04:09
pjb
You would have to use your own macro, not cl:assert. This allows you to globally enable or disable checks if you want that too.
20:04:55
makomo
pjb: lol, i thought for a second that string of numbers was a version number. phew...
21:06:12
_death
pagnol: mop = metaobject protocol, which gives a way of introspecting and extending CLOS
21:22:11
aeth
pagnol: Macros can easily cause problems and unreadable code, but imo there are three common patterns that are very safe to stick with: define-foo, do-foo, and with-foo. (There are some uncommon ones that are safe, too, like foof, similar to incf or decf, that can be defined trivially via define-modify-macro.)
21:23:07
aeth
Pretty much everyone should be able to read these, especially if you stay close to similar APIs.
21:24:53
aeth
If you're talking about a define-foo, that appears all of the time. Sometimes it appears as "deffoo" if foo is one word, but please don't do that. Tools like emacs only recognize define-* and built in def* like defun, so your form won't stand out as a define.
21:29:54
Bike
you could do a dynamic binding deal with setf and unwind-protect, though it would be dumb as hell and inconvenient besides.
21:42:44
shka
or at the very least don't write macros were function will do, or you will use it just a couple of times
21:48:25
fourier
or how to create a C file accompanying my lisp code (if I want to implement just one function in C)
22:43:06
fiddlerwoaroof
I generally like def* more than define-*, editors are programmable for a reason: you should bend the editor to your workflow, not your workflow to the editor.
22:45:04
Shinmera
I generally like define-* more than def* and feel it's easier to read and a better convention, so I'm perfectly fine with the editor pushing people in that direction.
22:51:37
fiddlerwoaroof
I generally don't find def* less easy to read, since prefixes are pretty normal in ordinary languages
22:51:56
fiddlerwoaroof
And, define- is a bit too verbose for the amount of work it does, to my taste
22:53:07
aeth
Common Lisp the standard has plenty of archaic styles because it does not break backwards compatibility. That doesn't mean that the older APIs should be emulated. e.g. if you're doing a sequence accessor, copy elt or aref, not nth (and the reason is because there might be more than one index, like in aref, which requires the sequence to come first)
22:57:06
aeth
(Sorry, I should clarify that aref is only a sequence accessor when it's a 1D array, but that was not really the point with my example.)
23:03:26
_death
fe[nl]ix: interesting observation.. but not sure I've seen evidence for the existence of such a convention.. if it did exist, I suppose CLOS authors found a loophole.. just shorten the term to one word and we can use defgeneric :)
23:06:01
pjb
In-extenso names are all nice and well, but it often occurs that you have to write formula and that you need concision there, to ease readability, just because it's very much harder to read a formula with a lot of references to the same names when they're long and furthermore, when they have common prefixes! This is why there is LET, FLET and MACROLET.
23:07:01
pjb
Said otherwise, when you define APIs, use long and explicit names. When you use APIs, wrap them around in your own short names.
23:08:05
pjb
aeth: it's not worse, again, it's historic: there are not 2 prefixes, but 3! DE DEF and DEFINE-
23:11:04
Shinmera
Just leave the define prefix out entirely, if it's a top-level form it's a definition anyway :^)
23:27:48
fe[nl]ix
_death: it's an old-time Lisp convention, it doesn't surprise me that they didn't think necessary to document it
23:48:15
aeth
It has the same issue, though. You can't teach tools that "foop" is supposed to be handled the same as "foo-p" or "foo?" instead of like a word "foop".
23:59:41
phoe
since decompressing 600kB worth of archives probably shouldn't cons half a gigabyte of memory
0:08:13
aeth
What I try to do is convert while doing a useful operation. So, e.g. I can multiply two CL-native matrices *into* a foreign C matrix rather than having a translation step.
0:11:24
_death
ugh, performing computation on a 512M RAM droplet's live image isn't such a good idea.. unless you like meeting the oomkiller
0:12:30
aeth
_death: Sounds like a good use case for preallocating literally everything. It's hard, though.
0:13:56
_death
in this case it's as simple as running it on my machine and pushing the resulting database
0:15:44
phoe
aeth: my case is dead simple, I have a wrapper around a LZMA library that does (de)compression. It needs raw chunks of uchars to operate on. I need to provide these chunks to it in the cheapest way possible.
1:16:35
jmercouris
Can someone explain why write-to-string for my object results in extra quote symbols? https://gist.github.com/d0a026f36d315d36f0c42787216714a7
1:26:16
jmercouris
It is a GTK type of issue, basically I can't add things to a GTK list store (model part of mvc for gtk tree view) that are not strings, therefore I have to maintain two lists, one of my actual objects in my model, and one of their string representation
1:26:39
jmercouris
So I know what I need to do, it's just kinda a dumb limitation to the way GTK works, I never thought I'd be glad for cocoa delegate model
1:28:24
jmercouris
p_l: Not that I am aware of, I'm using cl-cffi-gtk, which seems to be a very thin layer over C
1:31:43
jmercouris
It is okay though, it's just for the first release of GTK, I'm sure when some GTK users use it, they'll submit some PRs, at least I hope :D
1:35:46
jmercouris
Apparently you can also pass pointers to the model, interesting: https://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/Tree_Models
1:36:20
jmercouris
I can't imagine how they would render a pointer as a column in a GTK Tree view though
1:41:11
p_l
jmercouris: http://www.crategus.com/books/cl-cffi-gtk/pages/gtk_class_gtk-tree-model.html ?
1:51:52
p_l
jmercouris: yes, and the library provides you with an interface to subclass something that acts as GObject
1:54:04
jmercouris
p_l: I didn't see that actually, but the issue is that I need to display any kind of arbitrary object within the tree view
1:54:50
jmercouris
p_l: It is for my minibuffer completions, they are just the lisp objects passed to the view to be rendered, in cocoa I do (write-to-string object) and it'll show that object representation for any arbitrary object I add into the model
1:59:29
p_l
hard to say, but I suspect it might just as well be possible to subclass and override the list-store one
1:59:48
p_l
also, just found confirmation that you can subclass GObjects in cl-cffi-gtk: http://www.crategus.com/books/cl-gtk/gtk-tutorial_16.html#SEC201
2:00:47
jmercouris
but I don't want to alter the completions by having to make them be a subclass of GObjects, because it has to work for both Cocoa and GTK
2:02:36
jmercouris
At any rate, the completion will eventually pass back the original object to the c
2:05:07
aeth
pagnol: You probably want to use helper functions within an eval-when when macros get really complicated.
2:05:20
p_l
jmercouris: you could probably subclass a GtkLabel or something like that, as a wrapper around any random CL object, then put it into list-model
2:06:01
jmercouris
p_l: That's a creative approach, make like a subclassed gobject container object?
2:06:32
jmercouris
Why not just something like gojbect-container-object with a slot for a lisp object
2:07:09
p_l
jmercouris: yeah, subclass gtk-label, adding an extra slot (reference to CL object) and applying an afer method on initialize-instance that sets up the label to be stringified form of the passed in object
2:08:00
pagnol
aeth, I have set up a macro that defines a class and would like to have another macro that lets me operate on instances of the class defined by the first macro
2:08:56
pagnol
the second macro would like some knowledge that the first macro had... so I'm wondering if I can store something globally for the second macro to pick up?
2:10:07
aeth
pagnol: You could create functions instead of macros, and ideally put that knowledge within the defun you're generating. The general advice in this channel is "Does that have to be a macro or can an inline function work?"
2:10:34
p_l
jmercouris: hmm, it looks like you can't just put a widget reference in TreeModel, but you can put in any random crap and write your own renderer
2:11:45
pagnol
it's probably possible... probably since I just learned how to use macros I'm trying to apply them a bit overzealously
2:12:32
jmercouris
p_l: I think I'll do things the hacky way for now, I don't really care to become a GTK expert, it'll take time anyway for me to learn it
2:12:35
aeth
You could even put a closure around the function instead of making that information global, e.g. `(let ((foo ,vital-information)) (defun ,generated-function-name (x) (some-function-call foo 42)))
2:12:56
p_l
jmercouris: well, if you're willing to go a bit crazy, there's always the option of using cocoa on other platforms
2:15:22
jmercouris
p_l: Oh yeah, definitely, I've seen +cocotron inside the CCL sources, but I wouldn't get any benefits of cocoa, because I don't believe cocoa webkit is ported to Linux :P
2:15:49
jmercouris
I'll actually eventually even have to change the completion model because I would like to make the interface effectively like a server
2:16:07
jmercouris
where the Lisp code is the client/model, and the GUI is the server, and just contains EXTREMELY minimal code
2:18:09
jmercouris
this means if servo comes out tomorrow, I could adapt nEXT to use servo, with basically one or two weeks worth of work
2:18:59
aeth
pagnol: Just as a rule of thumb: macros deal with bindings and places (I hope I'm using the correct terminology). So: define-foo, let-foo, do-foo, with-foo, etc., or any use of define-modify-macro such as inc-foo-f.
2:49:25
jmercouris
p_l: You're not wrong, in general, but the API is extremely small, and IPC can happen over sockets in the worst case scenario
4:09:00
pjb
jmercouris: (symbol-name '\") #| --> "\"" |# (character (symbol-name '\")) #| --> #\" |#
4:13:59
pjb
STRING takes a string designator, which is either a character, a string or a symbol, and returns the corresponding string.
4:15:20
pjb
CHARACTER takes a character designator (which is a character, a string with 1 character or a symbol whose name is a string with 1 character) and returns the corresponding character.
4:15:54
pjb
So those functions let you go between character, string (of 1 character) and symbols (whose names are string of 1 character).
4:54:14
fiddlerwoaroof
The most annoying thing to me about the CL standard, is there isn't anything in it besides READ-FROM-STRING and PARSE-INTEGER for converting strings to numbers
4:54:30
fiddlerwoaroof
So, you have to use something like the PARSE-NUMBER package to parse arbitrary numbers
4:56:52
beach
I don't understand this argument. So many people are using languages that don't even have a standard. Why is it a disadvantage to have at least SOME features standardized?
4:58:24
fiddlerwoaroof
I'm just saying that it's a bit awkward to have PARSE-INTEGER but not PARSE-FLOAT or similar
4:58:59
aeth
fiddlerwoaroof: We should keep a list of things that should be added to the standard one day.
4:59:09
Bike
but it would be nice if it was in the standard, since the implementation has to have it anyway
4:59:12
beach
All those people who use non-standardized languages use features that are not standardized all the time.
4:59:33
aeth
beach: I think the general argument is that there should be additions to the standard, not that there should be no standard.
4:59:36
p_l
well, by now, we have an unofficial living standards as well, could be nice if it was somehow codified
5:00:35
fiddlerwoaroof
It's more a matter of aesthetics: there seem to be a couple lacunae in the standard that are a bit surprising
5:01:16
fiddlerwoaroof
I'm perfectly happy, though, with the way, say, threadings and sockets are standardized.
5:01:23
aeth
p_l: A good starting point would probably be de facto minimum sizes. The size minimums (e.g. for maximum array lengths or fixnum bit sizes) in the standard are tiny and afaik 16-bit-friendly. It would be enlightening to see what the actual minimum sizes are for actual 32-bit and 64-bit implementations, especially if there is a de facto standard that most follow.
5:02:01
aeth
p_l: e.g. A de facto minimum fixnum size for 64-bit implementations should be 60-bit, since that afaik safely covers all of them except clisp.
5:02:25
aeth
If non-conforming implementations can be patched to obey de facto minimums, library authors can make more assumptions.
5:02:50
aeth
Bike: Right now, any string longer than 1024 might not run on a conforming CL implementation.
5:02:59
beach
I personally think that there are more urgent things to do than to attempt to improve the standard. We need programming tools and libraries.
5:03:01
p_l
aeth: fossilizing ASDF a bit and including it in said standard would cover a pretty big hole left by politics and even worse reasons
5:03:28
Bike
the whole idea of things being declared fixnum instead of unsigned-byte whatever is kind of unfortunate imo
5:04:02
aeth
Bike: strings are just character arrays, so afaik array-total-size-limit of 1024 would apply. This could even make some longer docstrings not fully portable. http://www.lispworks.com/documentation/HyperSpec/Body/v_ar_tot.htm
5:04:28
aeth
Bike: If nothing else, it would be nice to know what array-total-size-limit's actual practical minimums are in 32-bit and 64-bit
5:05:02
fiddlerwoaroof
I used that at one point, but it's a bit annoying because I gather that the GTK developers are a bit inconsiderate of non-Gnome users of GTK