nested modules and editor

D

David Garamond

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?
 
S

Simon Strandgaard

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.
 
M

Mikael Brockman

David Garamond said:
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
 
D

David Garamond

Simon said:
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?
 
D

David Garamond

Mikael said:
| 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).
 
D

David A. Black

Hi --

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,807
Members
48,797
Latest member
PeterSimpson
Top