freenode/#lisp - IRC Chatlog
Search
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
17:30:25
pjb
jmercouris: In any case, I assume that a tool that extracts the docstring and use it will reformat it according to some rule, so you can do as you wish. The only problem is that we have sevearl markup syntax of possible formats for docstring…
17:30:52
pjb
jmercouris: in CL not much. In emacs lisp, emacs assumes the first line of the docstring contains a summary.
17:31:17
pjb
jmercouris: the point is that it depends on the tools that interpret the contents of the docstring. Some people use HTML!
17:31:31
Fare
makomo, the first bullet point still doesn't display properly. Thanks for the magic quoting.
17:32:16
pjb
jmercouris: you could use #.(my-doc-string-format "…") and generate different strings depending on the circumstances.
17:32:19
jmercouris
either way, I don't use generated docstring, I only care about how emacs interprets
17:32:52
pjb
If the text is read to generate html documentation, my-doc-string-format would convert to html, if it's read to compile, it would convert to a simple ascii docstring, etc.
17:33:51
pjb
Another one is the localization. Some times, you want to have different language versions (French, English, Russian, etc)
17:37:48
jackdaniel
in London I'm using output records for documentation, so it may contain arbitrary content with specialized rendering method
17:38:36
jackdaniel
so documentation output-record is not limited to text and is disjoint from the source function definition
18:11:52
asdf_asdf_asdf
(map 'list #'(lambda (x) (if (evenp x) x)) '(1 2 3 4 5 6 7 8 9)) => (NIL 2 NIL 4 NIL 6 NIL 8 NIL)
18:15:01
asdf_asdf_asdf
OK, thanks - works. But how do the same on the map - my example above. Instead NIL print "nothing"?
18:15:51
jackdaniel
map collects result for each element, if there is no result NIL is returned instead
18:17:08
jackdaniel
(collecting (evens) (map nil (lambda (elt) (when (evenp elt) (evens elt))) col) (evens)) ; collecting is a macro which has numerous variants, i.e there is implementation of it in cl-collectors (or something named like that)
21:50:30
didi
Hum. Why (constantp (quote 42)) => t, but (constantp '(42)) => nil? Shouldn't ' be identical to quote?
21:52:55
pjb
42 always evaluates to 42. (42) signals an error (and each time a different condition is created anyways), so in no way can it be considered a constant expression.
21:52:56
didi
Related, SBCL describes CONSTANTP with "True of any FORM that has a constant value: self-evaluating objects, keywords, defined constants, quote forms.". Isn't (quote (42)) a "quote form"?