On Oct 6, 2006, at 11:15 AM, Kevin Olemoh wrote:
> I'm very glad I bothered to bring this up since at least now I have a
> workaround until such time that the defacto requirement for K&R style
> indentation with respect to blocks is removed.

I'm not sure where you are going with this but I think it is terribly
misleading to think of Ruby blocks (do/end and {}) as in any way similar
to the blocks deliminated by {} in C.  They use the same punctuation,  
but
beyond that they have vastly different semantics and so I'm not sure how
it follows necessarily that their textual representation would be  
similar.

> I was also wondering is there a way to *not* have to write the  
> following:
>
> magick::fobar.blah
> or simillar when using libraries?
> further more what exactly is magick:: supposed to be called?

Sure you can write:

	magick.foobar.blah	# instead of using the scope :: operator

or you can create a temporary reference

	fb = magick::foobar
	fb.blah

I think there are two schools of thought on the :: scope operator.

1) Only use it to access constants:

	Math::PI

2) Use it as in 1) but also use it when calling class methods:

	Math::sin(0)

Its use in 1) is required, that is the only way you can access  
constants within
modules or classes.

Its use in 2) is a style choice.  Ruby is just as happy to access  
class methods
using the dot notation:

	Math.sin(0)


For method and constant lookup you can create shortcuts by using  
include:

PI		# uninitialized constant
include Math	# add Math to the search path for constants and methods
PI		# OK now because Math is searched also

So in your example, if magick was a module (Magick) and foobar was a  
constant (Foobar)
you could do:

	Magick::Foobar	# explicit access
	Foobar.blah	# error
	include Magick	# include Magick in method/constant lookup path
	Foobar.blah	# ok now

This also works if foobar is a method for similar reasons but Magick  
has to be a module
for include to work, and the include has to be executed in a module  
(or top level) scope.

You could also use 'extend' to make a particular object search Magick  
for methods and
constants:

	class A; end
	a = A.new
	a.foobar	# error
	a.extend Magick
	a.foobar




Gary Wright