Sweeten results
Posted Dec 4, 2012 14:19 UTC (Tue) by
david.a.wheeler (guest, #72896)
In reply to:
Don't worry - we're not done! by HelloWorld
Parent article:
GNU Guile 2.0.7 released
Since "sweeten" is a pretty-printer, there will always be cases where people will differ on what's "pretty". That said, suggestions to improve it are very welcome; my hope is that "sweeten" will make it easy for people to switch to sweet-expressions. So let's take a look.
First of all, we both agree that the expression:
(defun foo (bar baz) ...)
can be rewritten either as:
defun foo bar(baz)
or as:
defun foo
bar baz
...
So, when sweeten rewrites existing code, what form *should* it prefer?
I think this format is sensible when you see stuff like this:
define cos1 cos(1)
which is why I wrote the heuristic to do this.
The current heuristic for determining if something should be in one line is (in this case) implemented in the "sweeten-top" function, as follows:
if { {length-asline < max-unit-character-length} and
fits-width?(indent-already indent length-asline) and
{general-length(m) < max-unit-list-length} }
....
Since:
define maxwidth 78
define max-unit-character-length 60
define max-unit-list-length 8
The current "sweeten" does what it does.
Feel free to suggest a better heuristic! For more discussions, please join the "readable" mailing list, where this sort of discussion takes place:
http://readable.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss
(
Log in to post comments)