Ask Your Question

Should we start explicitly using top-scope in class names?

asked 2013-08-06 20:15:40 -0600

nibalizer gravatar image

I've recently run into a strange situation with two modules:

1) an ubuntu module, with an ubuntu class.

2) a site module, that I use as glue to connect other modules together. It has a main class spencer and a subclass spencer::ubuntu.

If I write

include ubuntu

in my spencer class. It will include not the ubuntu class from the ubuntu module, as I would expect it to, but instead it will include the 'spencer::ubuntu' class. This is most likely following from the 'most local' principle of variable scoping.

If I want the ubuntu class from the ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2013-08-07 21:14:05 -0600

Trevor Vaughan gravatar image

This is a known issue and the best way to work around it is to use top scope calls to your classes as you are doing.

As far as I know, there is no suggested standard for class scoping calls. If you want consistency across your code base, then scope all class calls. Otherwise, use it where necessary and comment it for maintainability.

edit flag offensive delete link more


Okay, thanks for the speedy reply :)

nibalizer gravatar imagenibalizer ( 2013-08-08 12:04:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-08-06 20:15:40 -0600

Seen: 531 times

Last updated: Aug 07 '13