nested modules and editor

Discussion in 'Ruby' started by David Garamond, Oct 20, 2004.

  1. Since I don't like code in nested modules to be indented so deeply, I
    tend to do this:

    module Foo; module Bar; module Baz; end end end

    module Foo::Bar::Baz
    ... # only 1 level indented
    end

    I was wondering how people that prefer

    module Foo
    module Bar
    module Baz
    ...
    end
    end
    end

    write their code, especially with auto-indenting editor, like emacs +
    ruby-mode. Do you just let the editor indent it deeply or do you resist
    the indentation and reverse what the editor does for you? Or, do you
    tend to avoid nested modules because of this?

    --
    dave
    David Garamond, Oct 20, 2004
    #1
    1. Advertising

  2. On Wednesday 20 October 2004 09:37, David Garamond wrote:
    [snip]
    > Do you just let the editor indent it deeply or do you resist
    > the indentation and reverse what the editor does for you? Or, do you
    > tend to avoid nested modules because of this?


    I don't use indentation for modules.. instead I use comment on the end's.

    module M1

    module M2

    CONST c=42

    end # module M2

    end # module M1


    IMO Indention feels awkvard when there is too many levels.

    --
    Simon Strandgaard
    Simon Strandgaard, Oct 20, 2004
    #2
    1. Advertising

  3. David Garamond <lists@zara.6.isreserved.com> writes:

    > Since I don't like code in nested modules to be indented so deeply, I
    > tend to do this:
    >
    > module Foo; module Bar; module Baz; end end end
    >
    > module Foo::Bar::Baz
    > ... # only 1 level indented
    > end
    >
    > I was wondering how people that prefer
    >
    > module Foo
    > module Bar
    > module Baz
    > ...
    > end
    > end
    > end
    >
    > write their code, especially with auto-indenting editor, like emacs +
    > ruby-mode. Do you just let the editor indent it deeply or do you
    > resist the indentation and reverse what the editor does for you? Or,
    > do you tend to avoid nested modules because of this?


    | irb(main):001:0> module A; FOO = 4; module B; end; end
    | => nil
    | irb(main):002:0> module A::B
    | irb(main):003:1> puts FOO
    | irb(main):004:1> end
    | NameError: uninitialized constant A::B::FOO
    | from (irb):3
    | irb(main):005:0> module A
    | irb(main):006:1> module B
    | irb(main):007:2> puts FOO
    | irb(main):008:2> end
    | irb(main):009:1> end
    | 4
    Mikael Brockman, Oct 20, 2004
    #3
  4. Simon Strandgaard wrote:
    >>Do you just let the editor indent it deeply or do you resist
    >>the indentation and reverse what the editor does for you? Or, do you
    >>tend to avoid nested modules because of this?

    >
    > I don't use indentation for modules.. instead I use comment on the end's.
    >
    > module M1
    >
    > module M2
    >
    > CONST c=42
    >
    > end # module M2
    >
    > end # module M1
    >
    > IMO Indention feels awkvard when there is too many levels.


    Is this what most people see. But I need to fight emacs' ruby-mode
    everytime I want to do that. Perhaps a modification or an option to
    ruby-mode is available?

    --
    dave
    David Garamond, Oct 21, 2004
    #4
  5. Mikael Brockman wrote:
    > | irb(main):001:0> module A; FOO = 4; module B; end; end
    > | => nil
    > | irb(main):002:0> module A::B
    > | irb(main):003:1> puts FOO
    > | irb(main):004:1> end
    > | NameError: uninitialized constant A::B::FOO
    > | from (irb):3
    > | irb(main):005:0> module A
    > | irb(main):006:1> module B
    > | irb(main):007:2> puts FOO
    > | irb(main):008:2> end
    > | irb(main):009:1> end
    > | 4


    Fine by me, since I usually use fully qualified name anyway (puts A::FOO).

    --
    dave
    David Garamond, Oct 21, 2004
    #5
  6. Hi --

    On Wed, 20 Oct 2004, David Garamond wrote:

    > Since I don't like code in nested modules to be indented so deeply, I
    > tend to do this:
    >
    > module Foo; module Bar; module Baz; end end end
    >
    > module Foo::Bar::Baz
    > ... # only 1 level indented
    > end
    >
    > I was wondering how people that prefer
    >
    > module Foo
    > module Bar
    > module Baz
    > ...
    > end
    > end
    > end
    >
    > write their code, especially with auto-indenting editor, like emacs +
    > ruby-mode. Do you just let the editor indent it deeply or do you resist
    > the indentation and reverse what the editor does for you? Or, do you
    > tend to avoid nested modules because of this?


    I just let the editor indent it deeply. I don't think I've ever gone
    more than three levels deep, and at two spaces per level, it seems to
    be OK.


    David

    --
    David A. Black
    David A. Black, Oct 21, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    651
    Stylus Studio
    Aug 3, 2004
  2. Hatem KNANI
    Replies:
    2
    Views:
    643
    Morphon Technologies
    Aug 4, 2003
  3. SyncRO Soft
    Replies:
    0
    Views:
    499
    SyncRO Soft
    Jul 21, 2005
  4. SyncRO Soft
    Replies:
    0
    Views:
    498
    SyncRO Soft
    Sep 21, 2005
  5. ImpalerCore
    Replies:
    0
    Views:
    832
    ImpalerCore
    Mar 10, 2011
Loading...

Share This Page