freenode/#lisp - IRC Chatlog
Search
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.
17:07:04
beach
jfe: I think the analyses of Shinmera and Bike are correct. But there are many disadvantages with writing a Common Lisp system in C or C++. There seems to be a widespread idea that a lower-level language has to be used in order to implement a higher-level one.
17:07:14
Bike
Cos, you know, writing a language runtime in C I can understand, you could debate whether that's a good idea. Writing a compiler in C is just bad.
17:07:56
pjb
If you have a native compiler, then just add code generation for syscalls, and you can write your libcl instead of using libc.
17:09:34
waynecolvin
what is needed to impliment a core lisp? isn't the execution model and debugging features different than C...
17:10:26
pjb
A lot of things are implementation dependent and a default implementation doing nothing is often allowed.
17:11:02
pjb
Even the compiler is optional (you only need to perform minimal compilation, ie. macroexpanding (and special declaration noting).
17:11:05
beach
waynecolvin: The people who use C to implement Common Lisp often rely on traditional, but unspecified or undefined, features of C.
17:11:32
pjb
And conversely, C implementation can include REPL, debuggers and interpreters. Cf. Cint, EiC, etc.
17:11:51
waynecolvin
well, if CL has regular arguments, &key arguments etc, should your VM have bloated activation recotds for all functions?
17:13:27
pjb
About half the functions in CL can be implemented trivially calling the other half (eg. (setf (symbol-function 'delete) (symbol-function 'remove)) ; done )
17:14:12
jasom
waynecolvin: C has variadic functions. keyword arguments are just a special case of variadic functions
17:15:36
jasom
waynecolvin: it is not required that lisp use the same ABI as used by C on the system, but doing so isn't automatically bad; even multiple return values of size less than N can be done efficiently for all ABIs that permit N registers to be modified by the caller
17:27:31
waynecolvin
there are lisp/subset-to-c translators but i don't know what subset or how they work lol
17:27:34
pjb
If you're really serious about bootstrap, then you start at the bash, and echo bytes to your exe file. Then you will bootstrap from a few binary instructions.
17:28:24
beach
waynecolvin: I had a better idea for SICL, namely to use an existing Common Lisp implementation to compile the code. That way, I can use the full language to write the compiler.
17:29:18
pjb
You may start implementing car cdr cons if null and lambda (no closure, just functions) and read-char in binary. This could be feasible. Then from that you could implement (still in binary) a simple reader, eval and print. Then you would be able to go on in "lisp".
17:31:05
jackdaniel
waynecolvin: if you look for something minimal, what is not CL to bootstrap from, you may check out ecl_min (something used to build ecl's compiler)
17:31:48
beach
waynecolvin: But that's beside the point here. The point is that, if you build your system from a subset the way you describe, you either end up writing your compiler in a subset of the language, or you end up with code that is replaced once the system is built, or probably both.
17:33:47
waynecolvin
interesting https://gitlab.com/embeddable-common-lisp/ecl/issues/350 hey that's you!
17:34:17
Shinmera
compiling to machine code or assembly just means emitting bytes or characters to disk or memory. Anything can do that. There's really no reason to bootstrap from a minimal system unless you have awful constraints like needing to interop with a system that is underspecified.
17:34:25
pjb
waynecolvin: have a look at http://www.sheepshellcode.com/blog/2014/12/31/writing-a-linux-executable-using-only-echo/
17:36:44
pjb
waynecolvin: Start with that, implement your first primitive in binary by hand, until you have your minimal REPL, and then go on writing lisp.
17:37:08
pjb
the eval can be very limited (not CL eval), cf. http://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/aim-8/aim-8.html
17:38:02
jackdaniel
reading LiSP is a very good reading to learn how to write it and discusses important topics like variables etc
17:38:54
waynecolvin
i worked out a text pattern to make DOS/CP-M86 assemble binary, but never made a Forth out of it
18:21:13
jackdaniel
if you are intersted in eql5-android, you'll find a good tutorial in this project
18:35:27
smurfrobot
does amyone know of recent survey/review papers discussing implicit parallelism and functional programming languages like lisp?
18:36:39
emaczen`
I'm getting an Error with ECL: Detected access to an invalid or protected memory address
18:52:35
osune
can somebody recommend a hassle "free" PAS like Heroku for CL ? I want to host a small chat bot for no cost but fun.
18:53:23
froggey
Ober: theoretically. I'm not sure how you'd interact with a translated library though
18:55:30
osune
Ober: does it has ready to go sbcl? There seems no maintained base "Buildapp" Template for Heroku.
18:56:10
waynecolvin
xlisp is fairly pretty easy to build on android (use make -f makefile.unix) but it isn't standard. ECL is much harder but there are binaries for arm32 you can download
18:58:43
phoe
My indentation just went crazy. My macro suddenly stopped indenting like it should and instead my macro is like https://i.imgtc.com/ni1wA3y.png
18:59:37
osune
phoe: i only know this behavior if my lisp buffer has no repl mode (or was it the other way round?)
19:01:01
phoe
(defmacro define-raptor-module (name (&rest protocol-classes) &body clauses) ...) is how it's defined.
19:11:57
k-stz
I'm reading "Lisp outside the box" and in a chapter on Memory, the author mentions "The stack is a data structure which, like the GCed heap, was originally invented for
19:11:57
k-stz
Lisp back in the 1950s.", I think that's interesting and like to back it up with some sources, but I can't find any, and for the stack I found contradicting ones
19:14:25
pjb
Also any early compilation book; they'll discuss at length about displays (storage for the frames of functions).
19:20:46
pjb
shka: Actually, it was a second generation system: LISP has been developped only because neither the FORTRAN guys nor the Algo guys accepted to add ternary IF or COND to their languages! As for the cons cells, they were invented by NSS: http://informatimago.com/articles/flpl/index.html
19:36:31
k-stz
pjb: I'll keep it in the back of my head, I might just have occasion to check out your work, but its too much for now
21:04:06
python476
ever wanted to see lisp and quantum computers ? https://www.youtube.com/watch?v=f9vRcSAneiw
22:19:37
resttime
I got CCL 1.9 working on flight hardware, I got told if packaged then it might get deployed with the satellite once it goes to space :3
22:20:53
resttime
I took a picture of testing sending a hex command to a serial device connected and it works: https://i.imgur.com/KLKm9iN.png
22:22:56
resttime
If I can get PPP running by compiling the kernel module then I might be able to get a REPL over SSH
22:29:51
pjb
Because IIRC, I had some bad bugs in 1.9, and was quite happy to upgrade to 1.10… (but it may have been MacOSX specific bugs, I don't remember).
22:30:42
resttime
I wasn't sure how, I read there would be some issues because the hardware uses soft float and that was 'abandoned' 1.10 and onwards would mess up some math functions
22:31:33
whoman
#1=with all of the (with-all-of-the-... in lisp, is there a commonly accepted practice to jump into rabbit holes ? also what is that procedure =)?
22:32:04
resttime
pjb: Yeah reading over release notes again for v1.10 and it says it https://trac.clozure.com/ccl/wiki/ReleaseNotes/1.10
22:34:02
whoman
pjb: i see a lot of lisp code using (with-...) as wrappers to create/destroy of various states or objects. is it normal that main program code is often wrapped in all of that ?
22:34:06
resttime
If I can send lisp to space and make it useful I will be satisfied (and then I will try to send my art on the satellite too hehehe)
22:34:59
pjb
resttime: of course, if you write papers and make youtube conferences, you'll be in good place next to DeepSpace 1 and its RAX software.
22:41:56
resttime
Hahaha no way, what I do is so little. I am in disbelief that I somehow ended up this kind of stuff. Like I see how stuff happened but at the same time I'm like, "waht? serisouly?"
22:48:04
whoman
pjb: ive dont a bunch of C++ so the idioms make a lot of sense to me. and now i understand.. so its quite alright to have many levels deep of main code running inside of the insides of the insides of ... ? perhaps i am touching in to some stack depth trauma, i am not smart enough to see
22:54:11
jasom
whoman: because of the possibility of non-local exits, you're going to have a lot of code of the pattern (let ((foo ...)) (unwind-protect (progn ...) (destroy foo))) the WITH- familiy of macros just allow you to not worry about all the moving parts there.
22:55:44
lisp_guest
hi everyone, could someone tell me what's wrong with this piece of code? http://rextester.com/TDO73450
22:57:32
lisp_guest
it does seem fishy to me too, but i've been thinking that the book must be right, so it's probably my fault in not understanding backquote correctly or something
22:57:48
Bike
no, the book is wrong. you're not the first person to come in here asking about defmacro/g!
22:58:09
Bike
when i say "wrong" i mean that it works on several implementations, such as ccl. but it's not conformant code.
22:58:28
whoman
jasom: ah cool, that is exactly what i was hoping =) i will read more about non-local exits later on. im still not approaching return/return-from and how that seems a bit magical
22:59:27
pjb
whoman: that said, if you have to open several files and it bothers you to have several with-open-file embedded, you can always write a macro to be able to open them all in one go. Just like LET lets you bind several variables at once.
22:59:38
Bike
"An implementation is free to interpret a backquoted form F1 as any form F2 that, when evaluated, will produce a result that is the same under equal as the result implied by the above definition, provided that the side-effect behavior of the substitute form F2 is also consistent with the description given above."
23:00:22
Bike
this means that `whatever can be read as anything. it can incorporate things like vectors and structs that flatten doesn't know about.
23:00:38
pjb
jasom: it's probably not a stand alone expression. Check where it occurs, and see if there's a ` around it.
23:01:04
whoman
Shinmera: why would someone with ego problems have good code? is what i am thinking.
23:01:44
lisp_guest
Bike: hmm, so would that be the reason why one of the symbols is literally ",g!three" instead of "g!three" as i would expect?
23:01:52
Shinmera
Well, I mean, some people have a good justification for saying their stuff is good. Because it is actually good.
23:02:00
Bike
lisp_guest: that said, your code is wrong in another way, and i don't know if it's from the book
23:02:19
pjb
lisp_guest: The bug is on the second line of: (defmacro/g! test-macro (x y) `(let ((,g!three 3)) (print (1 2 ,g!three))))
23:02:30
Bike
lisp_guest: first you call syms-in, which sort of flattens a form, then you call g!-sym-p on each item
23:03:01
Bike
lisp_guest: so, if your form has a 3 in it, your thing tries to do (symbol-name 3), which is wrong
23:04:14
Bike
pjb: the intent of this is that g!three will be bound at macroexpansion time to a gensym
23:04:23
pjb
Well, the other bug is in (print (1 2 ,g!three)) since 1 is not the name of a function!
23:06:01
Bike
(defmacro foo (thing) (struct-read thing)) is ok. rare, but ok, and implementations do this kind of thing sometimes.
23:06:40
pjb
well if g!three is bound to a variable name, then it should be (print (list 1 2 ,g!three))
23:06:53
jasom
wait, this happens before the body is macroexpanded, so it shouldn't be an issue there, right? i.e. it's not the generic code-walker problem
23:07:48
Bike
so in the unmacroexpanded code, there's a literal struct. and in that struct, there's something that will be a form later
23:07:57
pjb
but syms-in is buggy, it should be: (defun syms-in (&rest body) (remove-if-not (functiokn symbolp) (remove-duplicates (flatten body))))
23:08:24
jasom
Bike: the rest of the standard readtable is pretty well defined, right? quasiquotation is the only issue
23:09:25
Bike
(defstruct foo form) (defmacro unfoo (thing) (foo-form thing)) now have code like (unfoo #.(make-foo :form 'g!three))
23:09:35
lisp_guest
pjb: i've fixed g!-sym-p according to what bike said, i.e. moving the check for symbolp before using (symbol-name s)
23:10:26
jasom
Bike: I'm missing how (foo-form thing) can have a *read-time* expansion of a non-list
23:10:44
lisp_guest
Bike: so using what you quoted from clhs, where exactly is the part that's wrong?
23:11:05
Bike
the part that's wrong is the assumption that lisp code is entirely contained in list structure
23:11:23
jasom
oh, I see what you're saying. It's not non-conformant, it just requires that the body be a list.
23:11:47
pjb
So yes, the code in "Let Over Lambda" is pedagogical! You have to find the bugs in it… :-)
23:12:33
Bike
especially since the problem being solved is being too lazy to use with-gensyms explicitly :/
23:12:52
jasom
LoL shows it in use with quasi-quote, which is absolutely wrong; the rest becomes more of a style question
23:13:43
jasom
as long as LoL is approached as a fun exercise it's fine. It shouldn't be used as a library of useful macros
23:14:03
Bike
and that representation can include code outside of list structure, that is the obvious problem, yes.
23:14:26
jasom
lisp_guest: yes. There are similar issues e.g. for pattern matching. The solution there is to use a known quasiquote implementation (e.g. fare-quasiquote)
23:15:03
lisp_guest
right, that's what i meant, but the formulation was kinda weird (for me at least)
23:16:08
lisp_guest
i've read the clhs page multiple times but didn't connect the fact that flatten only works on lists and that "any other form F2" might contain non-lists
23:16:35
Bike
i don't think any implementation did choose to expand into non-lists, before sbcl switched to that uh... a year ago?
23:18:34
Bike
anyway, like i said, you're not the first newbie to come in here asking about this. it's most of what i've heard of LoL, so my opinion isn't great, but on the other hand i haven't heard any OTHER problems with it, so just be cautious i guess
23:18:59
pjb
lisp_guest: depends on what you mean by "walking over". The expansions should contain only functions, macros and standard special operators, so a code walker should be able to interpret it correctly.
23:19:33
lisp_guest
another question, in the body of defmacro/g!, inside the first quasiquote, when ,@body is spliced into the list
23:19:36
pjb
The only problem to code walkers are implementation specific special operators (not covered by a macro expanding to non implementation specific special operators).
23:22:34
lisp_guest
the relevant definition from clhs i see about ,@body is "[,@form] is interpreted as form"
23:22:55
lisp_guest
"form" here is my "body", but "body" itself is a list of something that uses quasiquote
23:42:23
jasom
lisp_guest: quasiquote is expanded by the reader, and are expanded as soon as it is read
23:43:28
jasom
lisp_guest: if you have a quasiquote inside a quasiquote, recurse down to the inner quasiquote
23:44:16
lisp_guest
jasom: right, so in this example http://rextester.com/TDO73450 (ignore the mentioned bugs), when ,@body is used to splice another list, i.e. the list "body"
23:44:44
lisp_guest
this list "body" was constructed by capturing the body of "test-macro" which itself had a quasiquote
23:45:34
jasom
lisp_guest: yes quasiquote is expanded at *read* time, long before macros ever get into it
23:47:46
lisp_guest
right, so i'd have to use some other implementation that doesn't use these internal representations for quasiquote
23:48:21
jasom
I should say, it is expanded to some unknown FORM that when evaluated will generate something equivalent to what the hyperspec says
23:48:37
lisp_guest
being aware that the internal representation of quasiquote is impl-specific makes it clearer now a bit
23:50:40
jasom
lisp_guest: the spec even mentions that implementations may do this for making printing prettier
23:51:25
lisp_guest
jasom: ya, i've read that paragraph multiple times but couldn't think of an example where it might affect me
23:56:04
jasom
https://gitlab.common-lisp.net/frideau/fare-quasiquote <-- readme here also talks a lot about quasiquotation
0:00:24
Bike
"n conformance with the CLHS, fare-quasiquote expands its patterns at read-time ... If you enable feature #+quasiquote-at-macro-expansion-time, fare-quasiquote will expands its patterns at macro-expansion time, using the same convention as Scheme, with symbols quasiquote, unquote, unquote-splicing and unquote-nsplicing" huh?
3:31:44
aeth
What video is that? There's no title bot in here and I don't trust YouTube links. (Although it probably is safe or else |3b| would have commented.)
3:32:03
aeth
Oh, it's this one, don't even need to click, it matches the URL on the front of HN. https://news.ycombinator.com/item?id=15880172
3:39:37
vtomole
From around 43 minutes in that video he talks about what the interns thought of Lisp.