freenode/#lisp - IRC Chatlog
Search
5:03:26
parjanya
hi! how can "print" a standard-char as a simple string? like (print #\a) returning just "a"?
5:26:28
myrkraverk
What is the simplest way to print carriage-return in Lisp? To make an auto-updating status in a terminal, thing.
9:01:34
shrdlu68
I need a really huge octet vector and using sbcl with --dynamic-space-size seems to use swap and gobble up so much memory the system becomes unresponsive.
9:05:58
|3b|
and do you need to be able to use normal CL vector ops on it? (guessing not if you can replace it with file ops)
9:08:47
schweers
that sounds like --dynamic-space-size and a regular vector or array should do the job
9:09:08
|3b|
by N x 40 bits you mean you need that many values with at least that many bits? or a n*40 bitvector?
9:10:50
shrdlu68
Perhaps the mistake I made was to create an n-size array of elements each an array of 40bits (5 octets) rather than just one octet vector.
9:12:02
|3b|
(on 64 bit lisp, the pointer pointing to it is probably 8 bytes by itself, not including the actual array headers etc)
9:14:12
|3b|
also, you are using types arrays for the octets, right? :element-type '(unsigned-byte 8)
9:24:41
|3b|
yeah, 309319296 x 5-element octet vectors uses ~12GB, (* 5 309319296) element octet vector uses ~1.6GB
9:28:15
beach
I set *COMPILER* to be either EVAL, COMPILE, or COMPILE-FILE. But I am not sure that's the best solution.
9:31:23
|3b|
for first case, looks like ~2.4GB is the 8-byte pointers in the big array, 9.9GB is the 5-element arrays, so about 32 bytes per 5-octet array (i'm guessing 24 bytes of header + 3 bytes of padding to round data up to a whole word of space)
9:37:53
beach
dmiles: It is not a Boolean expression. It has to do with calling or not calling EVAL at compile-time, and generating or not generating code to be run at load time.
9:40:55
dmiles
it does mean though if :eval :compile or :compile-file in your case are found in *COMPILER* then to treat the code as there
9:42:25
specbot
Processing of Top Level Forms: http://www.lispworks.com/reference/HyperSpec/Body/03_bca.htm
9:43:50
beach
dmiles: When implementing a Common Lisp system, if you have a choice between doing it according to the Common Lisp HyperSpec and not doing it according to the Common Lisp HyperSpec, the first choice is always the best.
9:44:14
shrdlu68
|3b|: Didn't work, it was still gobling up memory for some reason, I've switched to CCL.
9:44:29
dmiles
i was reading eval-when and wasnt completely sure.. most of the time i match the examples
9:45:56
beach
The Common Lisp HyperSpec examples are not normative, though, and they sometimes contain errors.
9:47:03
dmiles
too bad http://www.lispworks.com/documentation/HyperSpec/Body/s_eval_w.htm#eval-when doesnt like the 3.2.3.1 section
9:52:56
pjb
shrdlu68: syscalls are way slower than function calls, which themselves are slower than inline native instructions to index an array.
9:57:23
dmiles
yep works for me to.. i was complaining that the eval-when page has great usefull links but everywhere but that page :P .. to have gotten there I would have had to stop at the top-level-forms glossary page first.. which then links to that page
10:03:18
schweers
dmiles: you’re implementing your own common lisp? for fun and education, or do you think you can do better than those implementations that are already out there?
10:06:36
dmiles
i mostly hope i can do as good as the top 40%.. i am writting it in Prolog for a few reasons.. one is to prove prolog is a general purpose programming language that makes things like creating lisp impls ultra easy. we already know it makes lisp interpretors in less lines than any other language.. but what i am interested in if it can do "as well"
10:08:48
dmiles
so the prolog sources can at the repl be evaluated or if its done in compile-file it can be compiled
10:09:42
dmiles
there are good and less developed prolog compilers for differnt platforms .. in several langauges
10:12:06
dmiles
source code shrdlu68 is at https://github.com/TeamSPoon/wam_common_lisp/tree/master/prolog/wam_cl
10:12:17
dmiles
this file https://github.com/TeamSPoon/wam_common_lisp/blob/master/prolog/wam_cl/sanity-test.lisp translated to this file: https://github.com/TeamSPoon/wam_common_lisp/blob/master/prolog/wam_cl/sanity-test.lisp.trans.pl
10:13:35
dmiles
the lisp_compile_to_prolog(pkg,..) is there more informationally like: https://github.com/TeamSPoon/wam_common_lisp/blob/master/prolog/wam_cl/sanity-test.lisp.trans.pl#L44-L59
10:15:07
dmiles
and to get the symbols interned ( packaged ) so the prolog code at https://github.com/TeamSPoon/wam_common_lisp/blob/master/prolog/wam_cl/sanity-test.lisp.trans.pl#L74-L88 can be understood
10:18:09
dmiles
to give an example of *normal* implementing of lisp in prolog, it looks like this: https://www.metalevel.at/lisprolog/lisprolog.pl
10:21:28
dmiles
so bonuses of the prolog system is it already has a decompiler, exe/dll maker, image load/save
10:22:34
dmiles
the drawbacks is the number developer that think implementing object systems on prolog as to be easy
10:24:40
dmiles
everyone that gets to or past phD level in computer science is forced into at least 2 miserable weeks of leanring proliog
10:26:41
schweers
jackdaniel: I imagine that to be the case, which is why I can see myself learning the language some day
10:26:44
jackdaniel
I suppose they are required to know at least some important programming paradigms
10:30:07
schweers
dmiles, jackdaniel: do you think free prolog implementations of today are usable or real world applications? Or is the language as it is today “only” useful to broaden the mind? Which would be totally fine if you ask me, that is still a very good reason to learn a language.
10:31:07
dmiles
definately very good for todays applications.. i think even more for future applications.. I have two applications that i would not even immagine using anthing other than prolog
10:31:22
schweers
on the other hand: if it were not, I guess you wouldn’t be writing a lisp implementation in it ;)
10:32:37
dmiles
so i immagine 95% of the world would use lisp for such apps and make a prolog interpretor but leverage the inteire lisp ecosystem
10:37:15
dmiles
those applicaitons: a general purpose problem solver/simulator that can learn and be taught
10:38:57
dmiles
and can make further applications for running on computers that are based on what it learns from the previous
10:40:19
dmiles
if one knew exactly how that was supposed to work.. lisp and prolog would be most natrual choices at that point
10:43:06
dmiles
neitehr languages are going to have what you need built.. what they offer is one the ability to design top down
10:49:55
dmiles
a huge project CYC made a prolog-like-system-in-lisp ... writting in their language has shown me incredicable ammounts of untility that prolog as a language is afraid to adopt
10:50:35
otwieracz
I've got some weird pthreads/bordeaux-threads/maybe-lparallel related issue https://gist.github.com/otwieracz/d88dfc0d8b726f2610dda310e2b1e406
10:51:33
otwieracz
TL;DR - I've got a case where binary build with both CCL and SBCL lacks mutex fairness on certain machines.
10:51:56
otwieracz
Like, CentOS 7 in Google Cloud Platform. But not Ubuntu on GCP or CentOS on proxmox on bare metal.
10:52:57
jackdaniel
lparallel and bt seem like a bad fit, since they build abstraction on top of threads provided by the implementation
10:53:10
jackdaniel
since problem bites both sbcl and ccl it is not these implementations problem either (most probably)
10:53:30
jackdaniel
so it is either something in pthread implementation on the machine, or Linux + Virtualization
10:54:11
otwieracz
Something weird happends and falls into uncommon case where due to virtualization CPU sharing something is being, maybe, optimized.
10:54:36
otwieracz
Still, I don't believe such bug will remain undetected if it won't be lisp-specific.
10:56:05
otwieracz
I am afraid I first have to prove that problem is on their side before I blame them.
10:56:08
jackdaniel
ACTION doesn't know google procedures for reporting bugs in their virtualization platforms
10:58:52
dmiles
schweers, so as varjag was saying (i think) is most out of the box supposed features people learn to do on a small scale (niave brute force search and inference) do not work on a large scale. but is very enjoyable on a toy levels. Though if a person uses prolog as a macro programming language instead of a structured query language it scales to every level - no problem
11:00:13
pjb
otwieracz: I don't see any problem: other thread is correctly printed after a unlocking message.
11:00:29
schweers
sounds a bit like the situation with lisp: yes, lists are kinda cool for some algorithms (espectially to transform code) but shouldn’t be used in the large
11:00:33
pjb
otwieracz: I would just add finish-output after each format to ensure more reliable output.
11:01:52
otwieracz
„Mutexes are used for controlling access to a shared resource. One thread is allowed to hold the mutex, others which attempt to take it will be made to wait until it's free. Threads are woken in the order that they go to sleep. ”
11:02:46
otwieracz
pjb: On others, correctly, just after thread started before it unlocked the lock.
11:04:28
otwieracz
„locking” message is printed just before any of looping threads goes to sleep. Correct?
11:11:35
otwieracz
pjb: updated & tested https://gist.github.com/otwieracz/d88dfc0d8b726f2610dda310e2b1e406
11:25:25
jackdaniel
if centos7 allows you to change kernel version, try newer Linux, that could narrow it even further
11:32:33
otwieracz
You see when each thread is started, when is starts waiting on lock and when it acquires it.
11:36:17
otwieracz
There is no way for any of the looping threads to sleep on lock before outputting „locking”.
11:41:42
phoe
How can I sort a list "like" the other? I mean, I have a list of class names, (FOO BAR BAZ QUUX FRED), and I have a list of objects that are (in)direct instances of these classes. I want to sort all of these objects so all FOOs come first, then come all BARs, then come all BAZs, and so on.
11:42:28
phoe
The instances are subclasses of one and only one of these classes, so there is no ambiguity here.
11:42:48
Shinmera
(loop for class in classes nconc (loop for instance in instances when (instancep instance class) collect instance))
11:57:02
phoe
I could perhaps go O(n) by going through the list and going (push instance (gethash (class-of instance) hash-table))
12:00:29
pjb
otwieracz: threading is not deterministic. Each thread executes at its own speed. Perhaps in parallel, perhaps sequentially with other threads (you can have different number of cores available!). Some threads may be busy processing unix signals, which may occur randomly.
12:07:03
pjb
Well, actually I would have expected the "thread # waits on starting condition" messages closer to the "submitting thread #" messages.
12:07:33
pjb
shrdlu68: nope, but there are com.informatimago.common-lisp.cesarum.utility:dichotomy and com.informatimago.common-lisp.cesarum.utility:dichotomy-search
12:08:25
pjb
(I expect the starting synchronization to take a little time). Otherwise it finishes here.
12:29:04
mrSpec
shaftoe: (destructuring-bind (&key a b) '(:b 5 :a 10) (print a)) isn't what you are looking for?
12:54:56
_death
wrote this some time ago https://gist.github.com/death/898330dda627876b00a05b33b11124f7
13:02:35
pjb
kolb: nope: (let ((level 0)) (with-simple-restart (abort "Exit command level ~D." level) (print (find-restart 'abort)))) #| #<restart abort #x34B5AEAD> --> #<BOGUS object @ #x34B5AEAD> |#
13:03:18
pjb
It becomes invalid when you get out of dynamic scope, since you cannot invoke it anymore.
13:06:25
phoe
translation for non-Deutsch people: owszem, można to tak zrobić, ale i tak wyjdzie do dupy
13:07:21
Bike
hard to determine -> for the compiler, i mean, thus why you get bad behavior instead of an error.
13:07:35
shrdlu68
Is there a library that contains a sorting function such that I can sort subsequences in a sequences in a straight-forward manner?
13:08:16
phoe
shrdlu68: subsequences in sequences? you could theoretically create displaced arrays (for vectors) and sort these
13:09:06
pjb
(let ((foo (coerce (loop repeat 20 collect (random 10)) 'vector))) (sort (make-array 10 :displaced-to foo :displaced-index-offset 5) '<) foo) #| --> #(0 5 9 5 1 0 1 2 2 2 3 4 5 6 9 2 0 3 8 1) |#
13:11:43
pjb
You can build a vector of displaced arrays, sort it, and then do whatever you want with the result.
13:13:15
schweers
I want to treat a double-float as 8 consecutive bytes. Is there a portable way of doing so apart from using CFFI?
13:13:42
phoe
schweers: no. The representation, according to standathe standard, is implementation-dependent.
13:14:20
pjb
schweers: com.informatimago.common-lisp.data-encoding.ieee-754:float-64-to-ieee-754 and com.informatimago.common-lisp.data-encoding.ieee-754:ieee-754-to-float-64
13:14:26
mrSpec
_death: personally I think &allow-other-keys makes code harder to debug, when you miss something and destructuring-bind doesn't protest.
13:14:57
_death
shrdlu68: also, may want to do it without consuming so much RAM, but that's just oldtimer speaking ;)
13:15:38
_death
mrSpec: sure, but I often use plists for their ad-hoc extensibility.. otherwise, classes/structs will do
13:16:24
Bike
looks like it returns an integer, but that's pretty straightforwardly turned into a byte vector if you want that
13:16:46
shrdlu68
_death: I'm not an oldtimer but I too feel this is inelegant. I have to generate combinations with repetitions, and I'm not aware of an efficient algorithm of doing so.
13:18:57
phoe
schweers: NaN/infinity values aren't portable. CL standard doesn't conform to the IEEE float standard.
13:20:12
schweers
As both SBCL and CCL have infinity I should be fine, especially as I only /really/ care about SBCl. CCL portability is only something I aspire to in order to not be tied to just one implementation.
13:20:17
_death
shrdlu68: I see.. it seems like a classic problem so I'm guessing there are academic papers
13:36:48
pjb
schweers: I wouldn't even know how to get infinity in lisp, since (/ 0) #| ERROR: division-by-zero detected performing / on (1 0) |#
13:37:12
pjb
(* most-positive-double-float most-positive-double-float) #| ERROR: floating-point-overflow detected performing * on (1.7976931348623157D+308 1.7976931348623157D+308) |#
13:37:29
schweers
pjb: I also havn’t found a portable way to do so. Both SBCL and CCL have constants for this.
15:10:51
jfe
i'm trying to get the function that corresponds to a symbol in a list but (function ...) seems to only accept "direct" symbols as arguments. is there a trick to doing this?
15:12:13
beach
jfe: You can't use FDEFINITION to find the definition of local functions. Only global ones. Is that adequate?
16:19:46
schweers
is there a way to find the size of a (built-in) type in lisp? for instance to find out how much space is needed for a fixnum?
16:20:58
schweers
I meant whether ther was a way to go from a type specifier to a number of bits or bytes
16:21:31
Bike
For example, you could have a complex that takes up a header word and two content words boxed, but in some situations it could be unboxed and only be the content words.
16:22:18
Bike
If your kludge involves objects having coherent sizes it's already too hacky. What are you doing?
16:23:23
schweers
I have a large amount of data which will not fit into ram, so I’m offloading it into an on-disk key-value store (kyotocabinet). I can but byte vectors in there, and I want to dump a simple struct which constists of only ints and floats.
16:23:43
schweers
that is also why I asked about putting floats into a byte vector a little while ago
16:24:08
schweers
varjag: I was thinking about that. Would have done it if I hadn’t gotten a good answer here ;)
16:24:35
Bike
If you're only worried about integers and floats- for floats, you can check your implementation documentation. For integers, integer-length will tell you how many bits are required to store it.
16:25:27
Bike
And for an integer type specifier, well, (unsigned-byte 7) means it takes seven bits if you don't need a sign, of course
16:25:47
schweers
pjb: that is what I am doing, I just wondered if there was a better way. But given your comments and some more thought I guess it may be the right way after all
16:26:48
Bike
If you're worried about other possibly compound objects, the internal representation might not help since it could be full of pointers
16:55:49
jfe
i'm an amateur on compilers but i've been writing a simple one in lisp and it just seems silly to me to use anything but a high-level language for bootstrapping.
16:58:06
schweers
is the proper way do deal with this to use large-ish labels blocks around what was previously an entry point function?
16:59:27
Shinmera
jfe: C is a systems language, so a primitive compiler for it is often a first target for a new platform. You can then bootstrap a better C compiler with that. If your language runtime is then written against C, you get a new target "for free". Or at least that's the idea behind writing a compiler in C.
17:02:23
Bike
The C _runtime_ is pretty much everywhere, and contains a number of useful things, so using it can be convenient. It would be shit to write a compiler in though.