Page 2 of 2

Re: Antireader macros

Posted: Wed Sep 12, 2012 8:11 am
by Goheeca
It's user's arbitrariness (like *print-circle* etc.).

Re: Antireader macros

Posted: Thu Sep 13, 2012 1:01 am
by JamesF
Just spinning my wheels here, what about defining a type or class that's instantiated when the reader encounters curly-braces, possibly a subclass/subtype of list, and specialising print-object on that type/class?

Note: this is based on exactly zero fact-checking, combined with a sketchy grasp of CL's type system.

Re: Antireader macros

Posted: Thu Sep 13, 2012 6:07 am
by Goheeca
sylwester wrote:A) only curlies in place of parenthesis everywhere?
B) mixed curlies and parenthsis?
A) - I don't mind that I'm going to lose information during a reading part.
JamesF wrote:Just spinning my wheels here, what about defining a type or class that's instantiated when the reader encounters curly-braces, possibly a subclass/subtype of list, and specialising print-object on that type/class?
The reader macro is more generic actually it's for differently written lists, no special structure, so I would say that doesn't fit.

Re: Antireader macros

Posted: Sat Sep 15, 2012 3:34 am
by Goheeca
So I'm probably blind and possibly set-pprint-dispatch will be sufficient.
Here is a simple solution for my factitious problem, although it deals bad with a syntactic sugar like quote, quasiquote, unquote, etc.

Code: Select all

(set-pprint-dispatch '(cons t t)
                     #'(lambda (s input) (format s "{~{~s~^ ~}}" input)))
// I wonder you haven't kicked me to read the documentation properly.
And now I'll see how good is it for cl-2dsynax.

Re: Antireader macros

Posted: Tue Sep 18, 2012 11:40 pm
by Kohath
Good pickup - I just found 22.2.1.4 Pretty Print Dispatch Tables. Interestingly, I've never seen anyone use it (although that's not saying much :mrgreen:). Nice!