If I create a reader macro that the Lisp reader treats with curly brackets like parentheses, how to program the Lisp printer to do the opposite.It's something with pretty printing probably, but I can't find some example and the documentation is bald resp. it would take me too much time and perhaps here is somebody, which has some experience with this.

If you genuinely wish things in curly braces to be returned to the compiler as lists, then printing the code has no chance to distinguish between "normal" lists and your new ones, so either you change the print-object for all lists (probably not what you want), or you live with it.

If your curly braces are producing an object that isn't a list then you can choose how to print it whatever way you want

You really don't want that to happen for all lists because it will break too many other things potentially... This sounds like a rather peculiar task for some of your custom data / purpose. I'd just go with format'ing them with whatever style you like, else you might have to change too much of other code to work with your kind of parenthesis.

If you know exactly where there are curlies and where there are normal parenthesis such that the structure makes it obvious you can just make a function my-print to deal with it.If there is no way of knowing where the curlies are they are kind of like how Racket reads all types of brackets. (Yes, I know this is the CL forum)

As you can see. Just like people are telling here, there is no way to actually tell the two apart after it's parsed unless you do some other tricks.One trick would be to tag the different list so that your reader actualy adds something instead of just converting it to a parenthesis.

Goheeca wrote:The reading I have got solved, the issue is printing lisp-objects in my syntax by the standard print function, so REPL returns results in my syntax.

If I understand you correctly your reader reads {} as () so that ANY place in an expression it could be entered as curlies.You can overload print, but you cannot "undo" what the reader does exactly unless you tag the ines with different brackets. Print could show curlies where you would like culries to be in place of parenthesis follwing a pattern but not dictated by the original input (unless the input followed the same scheme).Can you give an example of input for the reader and how the result is returned from the reader and how it should look when printed if you feed your reader the same expression with:

A) only curlies in place of parenthesis everywhere?B) mixed curlies and parenthsis?

Last edited by sylwester on Wed Sep 12, 2012 8:16 am, edited 1 time in total.