[Factor-talk] Indentation width and other style guidelines
Hi all factorians! I noticed the default indentation width recently changed in fuel-mode from 4 to 2 spaces. Does that mean the recommended indentation is now 2? In general, does Factor have any established style guidelines analogous to, say PEP 8 (http://www.python.org/dev/peps/pep-0008/) for Python? I often struggle with figuring out the most readable way to split long expressions into multiple lines. -- mvh/best regards Björn Lindqvist http://www.bjornlindqvist.se/ -- 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=48808831iu=/4140/ostg.clktrk ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Indentation width and other style guidelines
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=48808831iu=/4140/ostg.clktrk___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] Indentation width and other style guidelines
If you want to provide a pull request to 4 spaces, I'll merge it. I see a reference to indent 2 in fuel-menu.el, factor-mode.el. On Sun, Jul 21, 2013 at 6:12 AM, Björn Lindqvist bjou...@gmail.com wrote: Hi all factorians! I noticed the default indentation width recently changed in fuel-mode from 4 to 2 spaces. Does that mean the recommended indentation is now 2? In general, does Factor have any established style guidelines analogous to, say PEP 8 (http://www.python.org/dev/peps/pep-0008/) for Python? I often struggle with figuring out the most readable way to split long expressions into multiple lines. -- mvh/best regards Björn Lindqvist http://www.bjornlindqvist.se/ -- 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=48808831iu=/4140/ostg.clktrk ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk -- 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=48808831iu=/4140/ostg.clktrk___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk