* Robert Klemme <bob.news / gmx.net> [Jan, 24 2004 20:00]:
> $ irb --prompt simple
> >> module Kernel
> >>   def namespace(nested, bind = binding, &block)
> >>     pre = ""
> >>     post = ""
> >>
> ?>     nested.split('::').each do |sym|
> ?>       raise NameError, "Symbol must start uppercase" unless /^[A-Z]/ =~
> sym
> >>       pre << "module " << sym << ";"
> >>       post << "end;"
> >>     end
> >>
> ?>     eval( pre + post, bind )
> >>     eval( nested, bind )
> >>   end
> >> end
> => nil
> >> namespace 'Foo::Bar'
> => Kernel::Foo::Bar
> >> namespace 'Bar::Foo', binding
> => Bar::Foo
> >>
heh, sweet...one can really tell Ruby is inspired by Lisp :-)
	nikolai

--
::: name: Nikolai Weibull    :: aliases: pcp / lone-star / aka :::
::: born: Chicago, IL USA    :: loc atm: Gothenburg, Sweden    :::
::: page: www.pcppopper.org  :: fun atm: gf,lps,ruby,lisp,war3 :::
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}