Arc Forumnew | comments | leaders | submitlogin
1 point by shader 5532 days ago | link | parent

>I don't know precisely how you're doing this, though, so that might not work.

All my source table does is

  (sref source* '(def ,name ,parms ,@body) ',name)
for def and

  (sref source* '(mac ,name ,parms ,@body) ',name)
for mac.

Since name, parms, and body are read by the reader, reader macros have already been expanded. I'm looking for a way to print the source in a more readable fashion.

Your functions looks pretty close to what I want. Maybe stringify could just be syntaxify, and make it recursive? I don't know if tail recursion is possible because of make-br-fn, but the rest of it looks pretty simple.

If the current object is a cons, but not one of the above, return "(" (syntaxify:cdr _) ")", and if it's an atom return (string _).

I'll do some more thinking on it, but it looks like you're on the right track.



1 point by absz 5532 days ago | link

That would work, except that

  (do
    (zap [cons 'head _] xs)
    (prn xs))
would come out as something like

  (do(zap[cons'head_]xs)(prnxs))
and I'm not sure how to deal with that, even if we add spaces.

-----

1 point by shader 5532 days ago | link

Adding spaces shouldn't be too hard; are you saying that we don't know how to handle indentation and newlines? I don't think that should be too hard. Looking at ppr and friends in string.arc should give us a clue as to that.

Is it possible to create a list in which the syntax is not expanded? I.e. preserve our syntaxification, after we've completed it? So that ', `, , ,@ [] become part of their symbols? That would probably be helpful, because then we could just use the built in ppr function, and not have to worry about formatting.

-----