freenode/#lisp - IRC Chatlog
Search
16:33:27
pjb
graphviz is perhaps too general. There are web services to draw easily from some textual description UML diagrams, including sequence diagrams.
16:43:19
shrdlu68
I've been testing cl-tls with a modified version of dex, and everything appears to work as it should. I can put the modded dex up somewhere is anyone is interested.
16:54:17
emaczen
In what ways does lisp allow you to control memory consumption? Or is this implementation specific?
16:57:11
White_Flame
there is "consing up memory" which just means allocation, vs reuse of data structures. That's generally the level of control in any GC language
16:57:39
White_Flame
in some implementations, allocating typed arrays can compact them, but they're not required to
17:00:07
emaczen
I have a data-structure which I am converting to a serialized one that I can work with on disk. I keep running out of memory. I'm serializing several of these data structures, I think that my program should finish if it would just garbage collect immediately after every serialization
17:00:25
White_Flame
in general, you can think in count of "slots" if you're going to micro-optimize how large a footprint your data structures are going to hold
17:00:52
White_Flame
you can usually force garbage collection, but the system already is doing that if you're running out
17:02:23
emaczen
White_Flame: I'm not sure why it would hold onto this data structure once it is serialized
17:03:36
White_Flame
are you successfully completing output for some of the structures, and it dies later on, or does it die processing the first one?
17:04:10
emaczen
White_Flame: It successfully completes serialization of at least one of the data structures.
17:05:16
emaczen
I have some unused slots in the data structure because they are utility classes that I use everywhere for convenience. Is there some kind of operator or declaration that will get the compiler to forget about them?
17:07:49
emaczen
What is strange about this problem in general is that it is a prefix-tree, before I was using a hash-table and so the prefix-tree I thought should be more space-efficient since it will re-use prefixes but I can't get it to work out that way...
17:09:19
emaczen
shka: I actually did convert my prefix-tree class of nodes to a pure list representation and it still used more memory than my hash-table
17:10:01
emaczen
shka: The pure list representation used WAY less than my class implementation though
17:11:44
emaczen
There is no doubt I could implement a pure-list implementation, but my hope was that I could just get around that and write some declarations or learn something about memory consumption in general.
17:14:38
emaczen
Bike: The fix would just be creating and merging some classes like "valued-node" and "named-node"
17:15:12
emaczen
It sounds all fine and simple, but I don't feel like breaking it. I think I would rather implement the pure list solution
17:15:42
emaczen
Bike: I'm not so familiar at the moment with that class hierarchy or "valued-node" and "named-node"
18:26:01
alphor
what other capabilities besides conditional evaluation does being a special form provide?
18:35:42
jackdaniel
aeth: your assertion is very harmful, because it is untrue – # is a dispatching macro character - there are #. for evaluation, #- read-time conditional, #o octal etc
18:36:12
aeth
jackdaniel: generally when it's #...(...) the elements inside the list are quoted is probably a better way of phrasing it
18:41:50
jackdaniel
I think the point is that it's not literal either, but rather undefined macro character
18:50:03
shrdlu68
Is it possible to use open with :element-type '(unsigned-byte n) and read only n-bit integers. where n is not a multiple of 8?
18:50:55
_death
shrdlu68: depends on the implementation.. offhand I think on sbcl you can use 16/32/64 as well, but not sure
18:59:22
shrdlu68
"...a library for accessing binary format files with fixed bit-length code-words..." Seems to be what I need.
20:04:49
gnuhurd
hello, in my function in Common Lisp, I iterate throught a 2-dimensional list and try to set each element to a random boolean with (setf (nth i (nth j grid)) (random-boolean))
20:05:43
gnuhurd
but this returns a list like this: ((T NIL T T T) (T NIL T T T) (T NIL T T T) (T NIL T T T) (T NIL T T T))
20:07:24
pjb
gnuhurd: (let ((w 3) (h 2)) (map-into (make-list w) (lambda () (make-list h :initial-element T)))) #| --> ((t t) (t t) (t t)) |#
20:07:44
Bike
since all the sublists are the same list, when you alter one of the rows you alter all the rest
20:09:16
pjb
gnuhurd: (let ((w 3) (h 2)) (map-into (make-list w) (lambda () (map-into (make-list h) (lambda () (zerop (random 2))))))) #| --> ((nil nil) (t nil) (t t)) |#
20:10:47
pjb
So: (let ((w 3) (h 2)) (let ((table (make-array (list w h)))) (map-into (make-array (* w h) :displaced-to table) (lambda () (zerop (random 2)))) table)) #| --> #2A((t t) (t nil) (nil nil)) |#
20:18:27
stylewarning
Never tell someone a data structure to use unless you're sure you know what they're doing
20:25:20
Devon
Interesting article about another indentation-heavy languace at https://StackOverflow.blog/2017/09/14/python-growing-quickly
21:25:20
phoe
is there some kind of reduce-collect function? if I have (1 2 3 4 5), I'd like to collect 1+2, then (1+2)+3, then ((1+2)+3)+4, ...
21:32:58
Devon
(reverse (maplist (lambda (args) (apply #'+ args)) (reverse (list 1 2 3 4 5)))) => (1 3 6 10 15)
21:36:35
Devon
(loop for n in (list 1 2 3 4 5) for sum = n then (+ sum n) collect sum) => (1 3 6 10 15)
21:41:35
phoe
I want to get a rendered GIF, as it would appear on screen, preferably in form of sequence of arrays which contain the respective RGB values.
21:42:38
phoe
And from what I see, SKIPPY is a library for handling GIF data and not for rendering GIF files.
22:00:46
|3b|
or for functional style, (defun foo (f) (let ((s (funcall f))) (lambda (a) (setf s (funcall f s a))))) (mapcar (foo #'+) (list 1 2 3 4 5)) => (1 3 6 10 15)
22:01:36
_death
for series style, (series:collecting-fn t (constantly 0) #'+ (series:scan-range :from 1 :upto 5))
22:21:05
phoe
https://github.com/dym/closure/blob/52c00f48d9eac73a8c0207b8174e8317224c5bc0/src/imagelib/gif.lisp#L43
22:23:55
phoe
XachX: https://github.com/dym/closure/blob/52c00f48d9eac73a8c0207b8174e8317224c5bc0/src/imagelib/gif.lisp#L45
22:24:57
XachX
phoe: I am not particularly interested in adding rendering I skippy. But I am open to persuasion.
22:26:13
phoe
XachX: given this function that I found there, I see that it only renders the last image of a stream.
22:26:50
phoe
XachX: if you're not interested in that, then I guess you'll soon find yourself with another project pushed into quicklisp, called "skippy-renderer" or something like that.
22:34:49
jasom
anyone have a good way to cause sbcl to unwind the stack on SIGINT with --disable-debugger?
22:38:54
phoe
":UNSPECIFIED - Do not erase the image from the display when displaying the next frame. This is the default value if disposal-method is not supplied."
22:39:23
phoe
http://cs.nyu.edu/courses/fall10/V22.0004-002/animatedGifs.pdf tells me that :UNSPECIFIED actually *erases* the previous image.
22:53:19
didi
How do you protect against infinite loops with `condition' and `restart'? e.g. I call function FN1, it signals condition CON1. I handle it and invoke restart RES1, that calls FN1 again, that signals CON1 again, and the cycle goes on. The reason for restart RES1 calling FN1 is because it tries to change the input of FN1 so FN1 can do its job. Is there a common idiom?
23:10:21
vtomole
(setq my-num 3). `(q,my-num) = (Q 3). Is it possible to get rid of the space between q and 3?
23:18:58
|3b|
space is just part of how it prints, the actual object is a list containing the symbol Q and number 3, no spaces
23:21:12
|3b|
by the type the ` form is evaluated, the READ is already done, so it is too late to do things that would depend on interpretation of space characters, like deciding which characters are part of a particular symbol
23:23:04
|3b|
so if you want a symbol that depends on runtime values, you need to create it (or find an existing one) manually, in which case INTERN as suggested (assuming you want a symbol accessible from code you write, or that you can generate again)
23:23:57
|3b|
if you don't need those properties, there are other options like make-symbol and gensym depending on what you are trying to do
23:26:13
pjb
or (gentemp "G") #| --> g0 |# you don't have to deal with the counter when you use gensym and gentemp.
23:39:55
|3b|
usually you don't want to create a new interned symbol though. gentemp won't return an existing symbol, for example any that you tried to use from already loaded code
23:40:48
|3b|
and at the point where you are generating code, usually it won't be READ, so doesn't matter if it is interned
23:43:08
|3b|
gensym also has predictable names, since you can access (or override) the counter, while gentemp might skip numbers to avoid existing symbols. not usually a feature that matters though :)
23:49:56
aeth
gentemp is deprecated. http://www.lispworks.com/documentation/HyperSpec/Body/f_gentem.htm
23:50:32
aeth
It'll never be removed because there'll never be another spec, but it's still worth noting that it's the older method to gensym
0:04:47
ralt
given that there's no replacement, and (remove-if (lambda (x) (not (foo x)) list) is more painful than (remove-if-not #'foo list)
0:05:37
aeth
All the -if-nots were deprecated. It might not have been clear at the time that remove-if-not is the more basic operation, equivalent to filter
0:06:06
aeth
By the spec, complement is apparently supposed to be used, but the implementors don't optimize it.
0:06:27
aeth
That is, remove-if-not will produce more efficient code than remove-if (complement in most if not all implementations
0:08:42
phoe
Are there any portable CL libraries for interfacing with any sort of English dictionary?
0:09:17
phoe
Like, anything that will evaluate (dictionary "virtue") to some kind of object that is a dictionary entry for word "virtue"?
0:09:54
aeth
ralt: filter is a basic functional higher order function. It exists, it's just awkwardly called remove-if-not in CL.
0:10:18
aeth
It's possible remove-if-not will be undepricated in the very unlikely event that there's a new standard.
0:11:10
aeth
The problem with not using -if-not functions are (1) everyone uses them while the complement style is very rare and (2) because of 1, the complement style is slower rather than producing identical code
0:12:18
ralt
I already know I'm not getting the best optimization when using higher order functions anyway, that's an acceptable compromise
0:12:53
aeth
When this discussion was last in here, it was brought up that SBCL could potentially optimize the remove-if (complement ...) style if it's "open coded", but I'm not sure if anyone has bothered to do so in the year or so since then
0:14:45
|3b|
shouldn't be too hard to do it with a compiler macro even (at implementation level, user code isn't supposed to do that)
0:29:52
fiddlerwoaroof
I'm not sure why you'd say that filter is more fundamental than remove-if-not: they're equivalent, afaict
0:33:45
fiddlerwoaroof
I yeah, that's what I meant to say: I don't see why remove-if-not/filter is any more fundamental than remove-if
0:35:16
stylewarning
The second you're generating a closure with weird argument passing (likely an APPLY)
0:35:52
fiddlerwoaroof
complement is pure, so the compiler can just transform it into an additional NOT in assembly
0:36:18
|3b|
only trivial if you see the complement, (defun foo (f) (remove-if f ...)) is harder to optimize even for compilers
0:36:23
stylewarning
No, it's that in the end optimizing (REMOVE-IF-NOT #'F) can be inlined and all that jazz
0:36:55
stylewarning
(REMOVE-IF (COMPLEMENT #'F)) will probably heap allocate a closure, have to re-pass arguments from the closure to F, etc
0:37:12
fiddlerwoaroof
|3b|: but then the compiler can just apply the optmization when it sees (foo (complement g))
0:37:33
|3b|
fiddlerwoaroof: probably easier to transform the remove-if (complement) to remove-if-not
0:38:23
|3b|
transforming complement to asm-level negation might be harder (especially on sbcl with extensible sequences)
0:39:19
fiddlerwoaroof
At the very least, COMPLEMENT is trivial to optimize because there is no reason to actually allocate a closure for it
0:39:49
stylewarning
If by trivial you mean you can write out a way to do it absent of any other framework, I agree
0:40:02
_death
personally when I think of FILTER, I think of something different from REMOVE-IF-NOT.. FILTER returns a list of the non-null values returned by the semipredicate
0:40:05
stylewarning
If by trivial you mean it's a trivial thing to add to a given lisp compiler, I disagree
0:41:36
|3b|
without a compiler macro or special form or similar, it has no way to know it has been removed
0:41:46
fiddlerwoaroof
|3b|: Can't you optimize away the closure if it doesn't introduce any new bindings?
0:42:41
stylewarning
You may be able to stack allocate the closure but idk of any compiler that would do that
0:43:38
|3b|
can't stack-allocate complement in general, so again would have to be a compiler-macro or similar to do so for functions where it is known to be valid
0:43:41
fiddlerwoaroof
marvin2: in python remove(None, list) removes all the falsey values from the list
0:44:39
marvin2
fiddlerwoaroof yes. and filter in python does exactly the same thing as remove-if-not in CL
0:45:29
stylewarning
The problem with _death's imo is the fact the final list will contain fn(x) in the result, not x
0:45:39
marvin2
not saying that there aren't languages where filter works right that, but python isn't one of them
0:45:58
_death
I don't know where I picked that up, but it was definitely not python :).. likely some old lisp dialect/discussion
0:48:46
_death
stylewarning: it's only a problem if you see filter as doing remove-if-not-like work..
0:51:50
stylewarning
Filter even in just the English meaning of the word usually means to sieve or sift, not transform
0:59:24
phoe
stylewarning: in the simplest form, just a string that contains the textual representation of a dictionary entry
0:59:59
phoe
in a less simple form, something that's already somewhat parsed - like, GCIDE contains things like
1:01:13
phoe
so this is split into two subprojects, 1) interfacing with the dictionary files, 2) parsing the entries from dumb strings into smarter Lisp objects
1:02:00
stylewarning
I'm just saying, in general, as a Lisp programmer, it would be nice if there were more data sets available to Lisp natively
1:02:24
fiddlerwoaroof
The nice thing is that it's fairly easy to write interfaces to things in lisp
1:02:47
stylewarning
fiddlerwoaroof: I thought that was true but I changed my opinion to "of mild difficulty"
1:02:53
phoe
So one can just use a combo of WITH-OPEN-FILE and FILE-POSITION to jump to the proper part in the file.
1:03:13
_death
aha... I picked it up from the first CL book I read.. ANSI Common Lisp: https://i.imgur.com/HfPmscR.png
1:03:24
fiddlerwoaroof
like, every once in a while I've wanted to wrap some rest api or something, and I've found it's fairly easy to wrap a huge amount of an api once you figure out the general shape of data access
1:03:37
White_Flame
vtomole: because macros happen at compile time, before any of those actual expanded bodies are ever runtime invoked
1:05:19
stylewarning
_death: its utility has been canceled out by its awful name. Should be (push x acc)
1:05:44
phoe
I'll write it first, and you can contribute later if you consider my way of doing it to be too much of a heresy.
1:06:20
phoe
as if a function for getting a dictionary entry is going to be called automatically multiple times per second
1:06:25
stylewarning
But if you're going to mmap it, just parse it out. Let me MAPCAR all words in the English language
1:06:56
fiddlerwoaroof
phoe: you might write something that transforms it into sexps and then write those out
1:07:01
phoe
but my use case is popping up a window with a dictionary entry for someone who wants to look up a word at most hundreds of times per day.
1:07:31
fiddlerwoaroof
I've done that a couple times for reference-style things, and it's pretty nice to just be able to read in all your structured data
1:07:32
stylewarning
phoe but writing a library has unintended consequences :D all of English at my lispy fingertips
1:07:59
phoe
stylewarning: "The consequences are undefined if a programmer decides to write a Lisp library."
1:10:01
phoe
minion: memo for beach: Do you have any code and/or libraries for accessing an English dictionary/thesaurus and spellchecking? I'm interested in portable Common Lisp code.
1:20:20
fiddlerwoaroof
the .dz format is interesting because it allows for "random" access to the compressed dictionary
3:00:22
aeth
"Lisp" can mean "the Lisp family of languages" or "the Lisp language". This channel uses the latter definition, so it's about Common Lisp. ##lisp uses the broader definition and #scheme is a channel for Schemes.