[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

nested modules and editor

David Garamond

10/20/2004 7:38:00 AM

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



5 Answers

Simon Strandgaard

10/20/2004 3:58:00 PM

0

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


Mikael Brockman

10/20/2004 4:53:00 PM

0

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



David Garamond

10/21/2004 2:31:00 AM

0

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

10/21/2004 2:35:00 AM

0

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


dblack

10/21/2004 2:40:00 AM

0