freenode/#lisp - IRC Chatlog
Search
5:36:22
beach
PuercoPope: I could use the full language if I had to, because I execute the HIR code inside a host Common Lisp system. However, the HIR instructions have a kind of natural translation to a small subset of Common Lisp. At the top level, there is a big TAGBODY where each label represents the start of a basic block.
5:37:25
beach
PuercoPope: So it's not that it has to be a subset, which is why I never bothered to define it precisely.
6:09:08
PuercoPope
beach: More than the operators the datatypes could be troublesome. CL supports for example bit-vectors, which I would think one would want to avoid having to implement in the target language
6:12:24
beach
PuercoPop: I really haven't given it any thought since the purpose of SICL is not to have a target language other than native machine code.
6:25:36
buhman
beach: I came up with https://gist.github.com/buhman/06a39c80623eb5d07ec593fd5715c221 which I think has correct behavior for all insertion cases, but I'm also not pleased with the code cleanliness
6:27:43
buhman
(node-insert) can correctly build https://upload.wikimedia.org/wikipedia/commons/e/eb/Insert_%27toast%27_into_a_Patricia_trie_with_a_split_and_a_move.png from a (make-node #f '()) root
6:54:59
didi
So I'm wondering: I have a function (FN) that consumes a static object (made of ordinary lisp objects) to produce an object. As it consumes a static object, this computation can be made during compilation. I see 3 ways of doing it: 1. define a macro that returns a computed object (defmacro mfn (x) (fn x)); 2. define a dispatch macro character that do the same thing as the macro; and 3. use #. to compute the object in read time #.(fn
7:01:13
gilberth
didi: When that is a function and should be function, I would consider a compiler macro.
7:08:04
didi
gilberth: I got the idea from languages (like Python and Racket) that define a special syntax for regular expressions.
7:08:05
gilberth
I have no idea of the nature of the arguments passed to your FN function. But a compiler macro also could bail out and say "Sorry, compiler I cannot do this at compile time, seek to invoke the function at runtime, please."
7:09:54
gilberth
As I said, I have no idea, what your function does. When it turns an external representation into some internal representation though, a reader macro would be fine. Like I used #u"http://foo.com/blah" in my URL library or #/a and #"foo" in my runes library.
7:11:56
didi
gilberth: Indeed. There is no need for secrecy. It reads a regular expression representation and returns an object that is used for matching, just list PPCRE's parse-tree.
7:16:06
gilberth
I always hesitate to define new syntax. Because it easily conflicts with other libraries and you hae issues, that you need to ensure that the read table is set up correctly for files using the stuff. These days. I was fond of reader macros 20 years ago, though.
7:18:03
gilberth
IMHO a macro like (foo (fancy-iteration (or "a" "b"))) would be fine. For completeness you could also have a FOO*, which evaluates the argument. Or: You define a FOO function, which then needs the argument quoted and go with a compiler compiler macro and ask for CONSTANTPness and bail out otherwise by returning the &whole form.
7:19:32
gilberth
Not having the option to build a FOO with an evaluated argument would be bad though. See parenscript for instance. We recently had that discussion right here.
7:20:42
didi
gilberth: Agreed. The function exists and I won't get rid of it. Like I said, I remembered the special syntax for regular expressions and thought it would be a neat optimization for constant regexps.
7:24:35
gilberth
It could be as simple as (define-compiler-macro fn (x &whole w) (if (constantp x) `(load-time-value (fn ,x)) w))
7:31:47
didi
Heh, my ignorance of load time vs. compile time vs. run time has finally showed its ugly head.
7:36:44
gilberth
didi: It will not be as easy as outlined, I justed tried it. My compiler macro goes into an infinite loop at compile time.
14:14:37
akater
Is there a way to ediff Lisp code in emacs ignoring differences like #:G40 vs #:G125 and #<OBJECT {42}> vs #<OBJECT {BEEF}>? I'm asking here because this looks fairly CL-specific. I know there's ediff-diff-options but maybe there is an estabilished solution already.
14:25:34
phoe
same with gensyms like #:G40 - they are useless when they are in Lisp code because they stop having their only reason to live, equality
14:26:06
phoe
so the question I'd ask is: why did you end up with code that has unreadable objects or uninterned symbols?
14:29:47
akater
phoe: I have lots of functions that generate code (that is never meant to be read, of course). Want to compare the output before and after modifications to said functions are made.
14:30:56
phoe
akater: I see. In that case, you might want to rebind *GENSYM-COUNTER* so the gensyms are printed in a similar (hopefully) manner.
14:31:38
phoe
As for unreadable objects, macroexpansions should not contain them as a matter of style and copypasting macroexpansions as text.
14:36:43
akater
phoe: I actually use my own counters. Conflating symbols' representations would clearly be a mere short-term solution in my case. Many different symbols will only differ in counters.
14:38:34
phoe
In that case, I have no idea. I wonder if some CL code could be written to walk the resulting tree and properly highlight the differences.
14:40:42
makomo
one especially annoying thing when working with CL and Git are the usual line-based diffs which pick up all the whitespace/indentation changes that were made. removing a single form could result in a whole lot of whitespace change
14:41:34
makomo
the conclusion was that a proper tree-based diffing tool would be awesome, but i have no idea how it would work
14:42:40
makomo
you could just check the structure of the tree of course, but i wonder if there are cases where you'd like something "smarter"
14:43:40
akater
makomo: Yes, the same sexp being on a different line triggers a diff, that's a bummer.
14:43:44
makomo
once that's solved, i suppose it wouldn't be too hard to treat gensyms as always equal, etc.
14:44:39
akater
I had a nice graphical diff in Mathematica. It would show common part of the tree unchanged and diffs marked in red in the appropriate tree nodes.
14:45:40
makomo
googling around it seems like solutions for other lisps do exist, https://github.com/zhengguan/ydiff-1, https://github.com/stamourv/sexp-diff
14:46:50
makomo
hmm, there's also https://www.cs.cmu.edu/Groups/AI/util/lang/lisp/code/tools/src_cmp/mkant/0.html
14:52:42
pjb
akater: (com.informatimago.common-lisp.cesarum.list:tree-difference (macroexpand-1 '(moo 42)) '(list 'foo (list #:foo) 42 #:bar)) #| --> (= (= = . =) (= (/= #1=#:g7002 #:foo) . =) = (/= #1# #:bar) . =) |#
14:52:49
pjb
akater: (com.informatimago.common-lisp.cesarum.list:tree-difference (macroexpand-1 '(moo 42)) (macroexpand-1 '(moo 42))) #| --> (= = (= (/= #1=#:g7003 #2=#:g7004) . =) = (/= #1# #2#) . =) |#
14:53:40
pjb
Notice how you need to unify the gensyms, to deal correctly with the repeatitions and circularities.
14:54:21
pjb
Also, tree-difference only walks conses. gensyms can be inserted into vectors and possibly other literal objects with macros, so you would have to walk inside them too.
15:16:31
makomo
is there a way to force ASDF to recompile all dependencies of a system as well? (asdf:load-system :something :force t) only forces the recompilation of the system :something
15:16:52
makomo
it will recompile dependencies only if a change is detected, but not unconditionally
15:19:05
phoe
makomo: is there a way to get a list of all dependencies, direct and indirect, of a system?
15:20:12
phoe
makomo: you could perhaps do that by calling #'asdf:system-depends-on and #'asdf:find-system over and over
15:21:33
phoe
I have no idea if ASDF actually has anything that force-recompiles a system along with all dependencies
15:23:36
makomo
"If force is :all, then all systems are forced to be recompiled even if not modified since last compilation."
15:24:00
Jachy
phoe: Swank has a swank-asdf.lisp file with slime bindings, though it wasn't working for me so I changed it a bit and bound it to another slime xref type. https://pastebin.com/qM3yLbeW
15:31:51
pjb
akater: at first, I would have suggested a pattern matcher, for the unifying of the gensyms. But any existing function will have to be patched to do exactly what you need.
15:32:15
pjb
(com.informatimago.common-lisp.cesarum.pmatch:match (macroexpand-1 '(moo 42)) '(list 'foo (list #:foo) 42 #:bar)) #| --> (:failed (:different #:g7006 #:foo)) |#
15:32:34
pjb
akater: you could read the sources of those functions, and write the one you need from them.
16:23:55
phoe
for instance, most implementations prefer to implement Unicode rather than implement the part of standard that ensures that there is a 1-to-1 mapping between all lowercase and uppercase characters
16:25:06
phoe
because the CLHS says, "prog2 evaluates first-form, then second-form, and then forms, yielding as its only value the primary value yielded by first-form. "
16:33:55
beach
dtw: You could "fix" the dpANS, which is freely available, but what would you do with the result?
16:35:58
beach
dtw: I have a planned project for creating a new language, called WSCL (for Well-Specified Common Lisp) based on the dpANS. The new language will be like Common Lisp, but without the mistakes in the Common Lisp HyperSpec, and with more situations specified than what is the case for the Common Lisp HyperSpec.
16:37:41
beach
Step 1 is to parse the dpANS into a single LaTeX document (in several files) as opposed to the dpANS which is a TeX document for each chapter.
16:38:56
selwyn
does there exist communication between Common Lisp implementors concerning common approaches with which to resolve the known inconsistencies in the standard?
16:39:55
Fare
I mean, occasionally, someone who cares about a particular aspect sends bug reports to lots of implementations, but that's all.
16:42:11
Fare
While developing ASDF3, I did lots of work getting pathname bugs fixed, some CLOS bugs related to class redefinition, or readtable issues.
16:43:27
beach
Fare: I think of a bug as a failure to respect the standard, which is different from the inconsistencies of the standard itself.
16:43:35
Fare
which led to a few implementations adopting read-only readtables for the standard readtable, for instance
16:44:53
Fare
The standard is far from perfect, but some worship it as a sacred text rather than a work in arrested progress.
16:52:22
pjb
Fare: (copy-readtable nil) returns a new standard readtable. So why would we need read-only readtables?
16:54:56
makomo
Fare: not sure if you've seen my ping from a week or two ago, but i'd like to let you know that i've opened a PR for fare-quasiquote (not a bug, don't worry :-))
17:03:28
Fare
pjb: see the discussion a few years back on asdf-devel. The standard somewhere (in the glossary?) describes the standard table as read-only
17:12:02
jmercouris
when you guys are adding docstrings to a function and it spans multiple lines, do you indent it to be inline with the first line?
17:14:46
edgar-rft
jmercouris: looks shitty in the code but looks much better when read via (documentation ...)
17:17:27
jackdaniel
to be honest I do put newlines in them myself, but I think it is a wrong thing to do - it is the printer responsibility to wrap by word at chosen column
17:18:53
jmercouris
however I think the other tool should allow and understand newlines in the source code
17:19:11
jmercouris
as far as I understand it, if you want a new paragraph, you sould have two new lines
17:19:23
jackdaniel
if you put newline there is no way any tool could infere it is something what is a soft newline