freenode/#lisp - IRC Chatlog
Search
3:19:12
Oladon
I find myself needing to write a new combination Markdown (probably Commonmark?) + BBCode parser. What's the best approach, architecture/organization-wise, to ensure maximum utility for others while still attaining my aim of a combination parser?
4:32:53
gjulio__
Hey is anyone willing to share a snippet of a .gitattributes file for handling control-m line endings in a *.lisp file? I've been trying a million tactics and I can't seem to resolve the problem.
5:03:48
gjulio__
i solved it. added *.lisp text eol=crlf to .gitattributes. then added (add-hook 'before-save-hook 'delete-trailing-whitespace) to .emacs and then created new files, moved my lisp file to the new file, added the new file to my git repo, and now it's working. it seems like the *.lisp text eol=crlf stuff isn't retroactive. maybe i'm wrong?
5:11:03
gjulio__
not sure. i did edit parts of the file on a different computer that was windows, maybe it's from that?
5:39:14
fe[nl]ix
gjulio__: convert all CRLF line endings to LF and configure your Windows editors to use LF as well
5:40:16
gjulio__
thanks. i'm usually using linux, but i'll keep that in mind if i need to switch back.
13:40:08
jcowan
What are the most common use cases for the syntaxes #n= and #n#, as opposed to the data structures they represent? Is it genuinely common to serialize such things as S-exprssions?
13:40:57
beach
For example, if I have an application with some internal structured data, I use it as a format on disk.
13:41:36
jcowan
beach: thanks. jackdaniel: I didn't mean in code, but that usage is new to me, so I'm glad to see it.
13:41:37
beach
jcowan: Recently, the ASTs produced by the SICL compiler are saved like that, thereby producing FASL files .
13:52:42
beach
jcowan: Here is an example. It is the AST for (defclass t () (:metaclass built-in-class)): http://metamodular.com/SICL/t-defclass.fasl.
14:00:53
beach
In both cases, I use the character `[' as a reader macro. It takes a name of a class and a bunch of initargs, just like the protocol dictates.
14:01:00
phoe
but all that's just a fancy pretty-printed S-expression with *print-circle* being true
14:03:07
beach
It creates a structure that is entirely isomorphic to the original one that was saved.
14:10:10
phoe
how do you map concrete classes to protocol classes? I assume that GSHARP-BUFFER:BUFFER is a protocol class
14:15:03
_death
for example, (defstruct link parent child) the parent link has to refer to the child
14:15:55
_death
you do need forward references for cyclic graphs.. this is the same issue that CL designers solved in make-load-form by having it return a creation form and an initialization form
14:17:35
phoe
I guess that this is because multiple MAKE-LOAD-FORMs do not necessarily depend on the slots of one another, whereas the above is just one big ball of cyclic references printed as a whole
14:21:38
beach
So when it sees #1#, it sticks in some unique temporary object, and enters the correspondence in a table. Then when the entire expression (in this case a single CONS cell) has been read, the graph is traversed, and the temporary object is replaced by what was returned as #1=.
14:24:11
aeth
jcowan: One use is when *print-circle*. A useless example: https://gitlab.com/snippets/1761668
14:26:04
_death
so while the form looks like it supplies initargs, it's actually patching the slots?
14:26:18
beach
I guess this feature (and its power) is little known, hence the question from jcowan. I think it is fantastic and, like I said, I use it all the time.
14:27:28
beach
_death: In my examples, if it sees :some-initarg #n#, it is replaced by :some-initarg <unique>
14:28:02
beach
_death: Then, if it turns out that :some-initarg stores <unique> in a slot, then it is patched later.
14:28:15
phoe
and I assume that all of this patching is done by the reader on the lists, before any MAKE-INSTANCE is even called
14:28:27
TMA
unless #n# is encountered before #n=, there is no need to patch if you can construct the object in some incomplete state (the state between allocate-instance and initialize-instance)
14:29:29
jackdaniel
had there been instances to be serialized, then the reader macro [ wouldn't make sense
14:29:55
jackdaniel
and there is no need to define a method on make-load-form on simple objects, like 3 or :staff
14:30:04
phoe
this means that READ-DELIMITED-LIST must finish operating before MAKE-INSTANCE is called
14:30:35
phoe
which means that the reading (including the patching!) must be complete before MAKE-INSTANCE is called
14:31:57
jcowan
beach: _death is correct, 2.4.8.16 explicitly forbids forward references with #n#, so no patching is necessary.
14:32:08
Bike
reading a standard-object with circular references in it isn't much different from reading a vector with em
14:32:11
phoe
because #1= must happen before #1# - if the reader stores the EQ references in some sort of read-time hash table, it can then directly look up the object and insert it there
14:33:33
phoe
you can't have an instance before calling MAKE-INSTANCE so there is nothing to insert there.