freenode/#lisp - IRC Chatlog
Search
8:14:51
makomo
i also had a deadline until 23:59 yesterday, writing a codegen for a c-like language (given the parsing tree)
8:15:19
makomo
my teammate was supposed to do it, but he choked so i had to jump in (same thing happen in his previous exercise too)
8:16:22
makomo
what a ride it was. completely rewrote what he did (which wasn't much anyway) and managed to pull it off. in total ~9 hours of coding
8:26:20
makomo
beach: WSCL seems interesting. found a typo in the README: "and is\ndesign so that each chapter"
8:27:16
pjb
makomo: no, in a very classic way, the requirements increased tenfold as the deadline came closer.
8:28:06
pjb
makomo: it's not clear if it was "the" toy compiler, or "a" toy compiler compiling the same language.
8:29:49
pjb
there was one guy who had fun implementing a toy compiler and a toy VM on github (I had same fun at least twice on usenet). Then his teacher took that toy compiler as an example in his compilation lecture.
8:30:19
pjb
makomo: <megachombass> all is base on this guy work : https://github.com/thibaudcolas/clisp-compiler-vm
8:33:22
makomo
actually, the thing i was doing is pretty similar. the code generation was done for an imaginary processor for which a simulator exists which is used to actually run the code and test the output of the programs
8:33:31
pjb
Either he keeps the compiler which is written in CL and uses sexps as is, and he needs a lisp VM with operations such as CONS, CAR, CDR, etc. Or he rewrites his compiler to use only integers, since the current VM only deals with integers. What's more, the current VM is not a Von Neuman architecture!
8:34:02
pjb
Namely, the program stored in memory cannot be written by a program in the VM, since as said, the VM only has integers, and the programs contain sexps!
8:35:39
pjb
So, in 22 hours, and being tired, I don't think many people would be able to do it from scratch.
8:35:50
makomo
but if the compiler is supposed to compile from Lisp into VM bytecode, couldn't he just compile the compile?
8:36:05
makomo
i suppose the compiler isn't powerful enough to handle all of the lisp constructs he had used in his compiler?
8:39:49
pjb
It's funny, because we knew from the start it would be a failure… So many in the same situation…
8:54:49
makomo
mhm. especially if the person is inexperienced and doesn't know what "to do next" or anticipate problems that might come up and avoid them before they occur
10:02:06
phoe
Does CL have any kind of operator that applies FN consecutively to ARG N times and returns the last result?
10:05:30
beach
phoe: Sometimes, it is easier to understand code if it doesn't refer to some external function that has to be looked up in the documentation. Especially short snippets like this.
11:00:17
Cymew
I repeatedly tear my hair out over LOOP syntax, and smile like a fool when I get it right and it's just so clever.
11:03:50
loke
I do remember feeling confused by it the first time I used it, but these days it's second nature.
11:09:34
beach
Or perhaps I mean (loop for x = bla then (f y) for y ...) I can't remember the details.
11:11:18
makomo
actually there were 2 but extermely similar, differing only in the ordering of 2 lines or something like that
11:12:24
loke
beach: ah, you mean when you have (loop for x = (something y something) for y = (something x something) ...)?
12:25:14
stylewarning
phoe: show off your leet hacking skills with this code: http://codepad.org/1zalcTgI
13:29:59
beach
ebrasca: Take the documentation of the macro with-preserved-top-level-ness in this file: https://github.com/robert-strandh/SICL/blob/master/Code/Cleavir/CST-to-AST/variables.lisp
13:33:35
beach
ebrasca: It would be something that the user of the macro could read, and then he or she could use the macro without knowing how it is implemented. For example, in your case, it would document what variables the macro intentionally captures in the bodies that you pass it, and it would mention things like the fact that the code of the bodies is repeatedly invoked, how many times they are invoked, and how each invocation is different.
13:54:40
beach
ebrasca: For more documentation ideas, here is an example: http://metamodular.com/cluffer-documentation.pdf
13:57:28
attila_lendvai
did anyone see issues recently with cxml getting repeatedly reloaded by asdf?
14:00:49
Xach
I think there is a situation where multiple defsystems in a single .asd will cause unexpected reloads. Not just in cxml's complicated case.
14:02:19
Xach
https://github.com/mrossini-ethz/physical-quantities/blob/master/physical-quantities.asd triggers it, though
14:44:39
makomo
beach: since your documentation always looks solid, what's your opinion on literate programming?
14:51:54
pjb
makomo: just start your programs with #| and end them with |# Parenthesize the code parts with |# (code) #|
14:57:26
beach
makomo: I think the original idea is completely bogus. It was necessary because Pascal requires a very strict order between definitions and instructions, and that order is contrary to how Knuth wanted to present it to the human reader. The language we use does not have that restriction.
14:58:54
beach
makomo: So I guess my opinion about it will depend on how it is defined for a language such as Common Lisp.
14:59:57
dlowe
I kind of like the idea of an essay with code embedded in it that can be executed as a whole. But that's as a learning device, not as a programming practice.
15:00:02
makomo
beach: hmm. well if we put aside the fact that it was partly necessary because of Pascal's restrictions, what do you think about the general idea of literate programming: writing a book first and foremost and only then code
15:00:44
makomo
dlowe: yeah, i'm not sure how practical something like literate programming is when a program continues to evolve
15:01:30
makomo
for example, the Axiom CAS system uses literate programming (and it's written in Common Lisp + a language built on top of CL called SPAD)
15:01:33
beach
makomo: Well, I don't think there is a temporal order like that. But I do agree that the communication with the maintainer of the code is more important than communication with the compiler, if that is what you mean.
15:02:03
makomo
and there's also a book called "Understanding MP3" that uses literate programming with C to implement a full-blown mp3 parser and player
15:02:52
pjb
makomo: beach's right, see this article that passed on hackernews yesterday: http://lightsonsoftware.com/writing-code-that-reads-like-a-story/
15:02:54
beach
And, yes, I agree that the way literate programming is typically used, makes it totally impossible to have the code evolve.
15:03:18
pjb
beach: however, literate programming has the advantage that it stress on the human reader and documentation first.
15:03:35
asarch
beach, require('child_process').exec('ls', function(err, stdout, stderr) {if (err) {console.log("\n", stderr);} else {console.log(stdout);}}); in http://www.ecma-international.org/publications/standards/Ecma-262.htm
15:04:09
beach
pjb: So the challenge is to emphasize the communication with the person reading the code, while keeping the possibility of evolving the code.
15:10:29
Shinmera
makomo: Generally I think the documentation and the code should be separate. The code is an implementation detail, and requires a different level of description than documentation. Mixing the two together (as with literate programming) thus seems like a bad idea.
15:11:36
Xach
Who was it who, when paul graham said that arc code was its documentation, asked him if "inverts a matrix" was clearer than the code for inverting a matrix?
15:12:28
beach
Shinmera: Take a library for instance. The documentation for how client code should use it should be separate from the code.
15:13:11
beach
Shinmera: But the documentation explaining why the code is written in a particular way should definitely by next to the code, i.e. the maintainer documentation.
15:13:17
Shinmera
beach: When I say documentation I generally mean the user-facing one. Documentation about the internals would be comments.
15:15:38
dlowe
there should be at least three parts to documentation: a tutorial, a playbook, and a reference. The tutorial eases a user into what it possible, the playbook helps the user solve the most common problems, the reference has details for use once the interface elements have been selected.
15:15:56
pjb
Shinmera: agreed. But I would want tools to link the different parts and track the dependencies. Specifications <-> Analysis <-> Design <-> Code <-> Tests. So if you navigate to some place in the code, you get a window with all the relevant sections of the Specifications, the Analysis, the Design and the Tests. If you modify the Specifications, you get a list of all the places impacted in the Analysis the Design, the Code, the
15:16:15
mfiano
Xach: The matrix inversion slow path for non-orthonormal matrices is a sight to see ;)
15:18:06
pjb
Shinmera: That was the idea behind the OO CASE tool Objecteering/Modelio; but it would probably involve more integrated tools, more like InterLisp…
15:18:22
mfiano
Xach: haha. and here is a macroized version which uses symbol macros to hide all the arefs: https://github.com/mfiano/gamebox-math/blob/master/src/matrix/matrix4.lisp#L465-L518
15:19:53
Shinmera
Weak! Check this out. https://github.com/Shinmera/3d-matrices/blob/master/ops.lisp#L470
15:20:55
pjb
I would write the source code as: {\displaystyle \mathbf {A} ^{-1}={\frac {1}{\det \mathbf {A} }}\left[\left(\operatorname {tr} \mathbf {A} \right)\mathbf {I} -\mathbf {A} \right].}
15:22:47
mfiano
But there is a fast path inversion for when a matrix is orthonormal, which is pretty short. luckily this is usually the case in graphics programming
15:27:17
pjb
On the other hand, maths and physics code is a little different, in that 1- it's "well" specified and documented in maths and physics books ;-), and 2- we often want optimized code to implement those algorithms.
15:28:00
pjb
If you can generate fast code, the better, but if not, just write it by hand as ugly as it is…
15:28:13
mfiano
Xach: Do we have a rough eta for the next dist? Wondering if I have time during the busy work week to sneak in one last fix/feature to a library
15:36:08
Xach
I don't know about a lot - there are some that are broken, and some loaded too often, and many more warnings that I think are not very useful.
15:38:52
dlowe
The road from a permissive reader to a strict reader is one filled with sharp edges and tears.
15:44:47
beach
Me and my (admittedly small) family are going to be there. I booked travel and hotel(s) a few days ago.
15:45:46
beach
jackdaniel: You and your wife may have to come to Malaga for dinner one of the days we are there. We are going to be in Marbella only from Sunday to Wednesday.
15:47:53
jackdaniel
we'll be there 14-21, so if anyone stays longer (or comes earlier) it will be nice to meet you
15:49:48
Shinmera
It's a bit of a shame that there was no good big hotel offer this time around. Having a party of lispers at the same place was really nice the previous two years.
16:07:48
sjl
if it's any consolation, I was surprised by the same thing, and regretfully spent a good hour tearing it out of all my stuff
16:08:40
mfiano
Yeah I want to eventually replace that, but I wonder how legal it is considering I'm not distributing it, but Quicklisp is pulling everything down on a user's machine.
16:09:47
sjl
I would think a court would consider that distributing. "The user's web browser requested foo.tgz from my server, I didn't push it to them" is similar.
16:10:18
mfiano
Would a court consider Quicklisp itself infringing on the GPLv3, having everything together in the quicklisp dir?
16:10:55
dlowe
the license interpretation depends heavily on what is considered a dependency of a program
16:11:12
sjl
Since quicklisp doesn't actually rely on the code, it just treats it as data, I doubt it would be a derivative work.
16:12:29
jackdaniel
mfiano: there is a clear distinction between "derivative work" and a "mere aggregation"
16:13:01
sjl
Someone should do a clean-room reimplementation of defstar (or something like it). It's a useful idea that more people would use if it were more permissively licensed.
16:13:24
jackdaniel
https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.en.html#MereAggregation (from faq)
16:13:29
mfiano
Pushed high up on my priority list. Thanks for bringing that to my attention. I recently went through my software and culled GPL dependencies, but apparently didn't look hard enough :/
16:15:09
sjl
(declaim (ftype (function (fixnum fixnum) fixnum) foo)) (defun foo (x y) ...) => (defun* (foo -> fixnum) ((x fixnum) (y fixnum)) ...)
16:17:40
mfiano
sjl: I appreciate that you brought that to my attention. This is a huge deal as that library is a foundation for pretty much everything I write.
16:17:47
jackdaniel
on the other hand I'm not sure if it can work as desired (that is – declamation being part of macroexpansion – does spec guarantee that it will be processed by a compiler?)
16:18:50
beach
ebrasca: Just as the author of a book writes several versions before being content with the result, programmers often have to do the same.
16:19:39
dlowe
it looks like it would be pretty trivial to duplicate under a more forgiving license.
16:20:45
sjl
Bike: it does expand into a declaim+defun, though there's more functionality than just the bare expansion
16:21:03
mfiano
dlowe: Indeed. I only used it for brevity/laziness. I usually stay away from those sorts of libraries.
16:21:35
beach
jackdaniel: That sounds like something we should do, i.e. take our wives to a flamenco restaurant in Malaga.
16:21:50
sjl
it can insert check-type forms, handles optional/keyword/rest args, has pre/post-condition features
16:22:00
AeroNotix
Does defstar allow for any optimizations? I.e. will the type hints tell the compiler to do anything different?
16:22:41
sjl
AeroNotix: depends on the compiler and the optimization settings. All it does it the declarations.
16:28:07
sjl
I think if you limit yourself to "make some macros that make type declaration less tedious" and ignore all the pre/post condition stuff you could do it in far fewer lines.
16:28:28
sjl
But still, handling rest/optional/key args and defmethod/defgeneric args is nontrivial.
16:29:11
AeroNotix
yeah I just thought to make a toy which just dealt with positional args and basic declair/declaim expansion
16:30:47
mfiano
Speaking of licenses being a problem, cffi pulls in babel which is MIT but admits to stealing LLGPL code: https://github.com/cl-babel/babel/blob/cd4183b5767e65a718d199e4dfa5bd5f61370d4d/NOTES#L4-L6
16:32:28
AeroNotix
jackdaniel: how does it work if you used something as a library and then at runtime modified some functions?
16:33:05
jackdaniel
AeroNotix: I describe licensing implications here: https://common-lisp.net/project/ecl/posts/ECL-license.html
16:33:28
jackdaniel
(don't get discouraged by "ECL" in post name, I talk about other licensing models as well)
16:33:50
mfiano
LLGPL is sort of a custom license. It has never been tested in a court, so I don't think even a lawyer can answer that
16:34:48
AeroNotix
Is code written by an AI derivative work? If I write an AI capable of writing code, who owns the code?
16:35:22
jackdaniel
mfiano: llgpl is lgpl + preamble. also testing in court isn't a good argument – license is what it is - you have many countries and ruling may be different etc
16:36:01
jackdaniel
AeroNotix: depends on the license. in case of GPL result of your code is not covered by the license
16:37:02
beach
jackdaniel: This looks like the best bet so far: http://www.restaurantevinomio.es/en/
16:37:58
mfiano
I wonder how many MIT libraries actually steal code from incompatibly-licensed software without mention. babel makes me worried, especially since they never even fixed the problem they identified.
16:42:45
sjl
jackdaniel: are you writing a tutorial for it? that would be welcome, it could use some additional docs.
16:55:11
phoe
Just to be sure: in GF dispatch, are EQL specializers more specific than class-based dispatch?
19:10:28
pjb
https://www.hillelwayne.com/post/the-best-se-paper/ -> Fixing Faults in C and Java Source Code: Abbreviated vs. Full-Word Identifier Names
19:16:21
mfiano
sjl: defstar does more than (declaim (ftype (function (fixnum fixnum) fixnum) foo)) (defun foo (x y) ...) => (defun* (foo -> fixnum) ((x fixnum) (y fixnum)) ...)