Antireader macros

Discussion of Common Lisp

Re: Antireader macros

Postby Goheeca » Wed Sep 12, 2012 8:11 am

It's user's arbitrariness (like *print-circle* etc.).
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version).
User avatar
Goheeca
 
Posts: 218
Joined: Thu May 10, 2012 12:54 pm

Re: Antireader macros

Postby JamesF » Thu Sep 13, 2012 1:01 am

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.
JamesF
 
Posts: 95
Joined: Thu Jul 10, 2008 7:14 pm

Re: Antireader macros

Postby Goheeca » Thu Sep 13, 2012 6:07 am

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.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version).
User avatar
Goheeca
 
Posts: 218
Joined: Thu May 10, 2012 12:54 pm

Re: Antireader macros

Postby Goheeca » Sat Sep 15, 2012 3:34 am

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.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version).
User avatar
Goheeca
 
Posts: 218
Joined: Thu May 10, 2012 12:54 pm

Re: Antireader macros

Postby Kohath » Tue Sep 18, 2012 11:40 pm

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!
User avatar
Kohath
 
Posts: 53
Joined: Mon Jul 07, 2008 8:06 pm
Location: Toowoomba, Queensland, Australia

Previous

Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 4 guests