Yeah, that seems like a problem. The convention is 4 spaces.
I thought for sure it was documented somewhere, but the closest I could
find was the prettyprinter's control variables (
http://docs.factorcode.org/content/article-prettyprint-variables.html),
which are set to:
4 tab-size set-global
64 margin set-global
It'd be cool to have a lint tool for this. There seem to be a few vocabs
lying around that are 2-space indented:
$ grep -l "^ \{2\}[^ ]" **/*.factor | wc -l
226
$ grep -l "^ \{4\}[^ ]" **/*.factor | wc -l
3402
I know the 64-character line-length limit isn't obeyed globally.
$ grep -l ".\{65,\}" **/*.factor | wc -l
3035
$ ls **/*.factor | wc -l
4309
$ grep -l ".\{65,\}" **/!(*-docs).factor | wc -l
2362
$ ls **/!(*-docs).factor | wc -l
3622
I get the feeling it's a less religious matter than Python. But 4 space
indentation is still clearly the standard.
The prettyprinter's not perfect, but it might help if you're trying to
decide how to split up a long expression. For example, there's code in
alien.endian indented like this:
```
nip
[
[
[ alien-unsigned-4 4 f byte-reverse 32 shift ]
[ 4 + alien-unsigned-4 4 f byte-reverse ] 2bi bitor
]
] dip [ [ 64 >signed ] compose ] when
```
If we give it to the prettyprinter, we get back nearly the same thing:
```
IN: scratchpad [ nip [ [ [ alien-unsigned-4 4 f byte-reverse 32 shift ] [ 4
+ alien-unsigned-4 4 f byte-reverse ] 2bi bitor ] ] dip [ [ 64 >signed ]
compose ] when ] .
[
nip [
[
[ alien-unsigned-4 4 f byte-reverse 32 shift ]
[ 4 + alien-unsigned-4 4 f byte-reverse ] 2bi bitor
]
] dip [ [ 64 >signed ] compose ] when
]
```
Not perfect, but gives you a general idea. And the prettyprinter's output
for the above isn't awful.
Documenting these conventions would clearly be better, of course...
Hope that helps,
--Alex Vondrak
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk