Re: Setting namespace in loaded files



Eero Saynatkari wrote:
unknown wrote:
On Tue, 22 Aug 2006, Luke Kanies wrote:

Is there a way to load a file within an existing namespace, so that the
method search path started at the scope doing the loading?

If you read the file, and then eval it in the desired scope, it has the
effect of loading it into that scope.

There is some complexity/problem with this but
the details elude me. Came up when implementing
the require 'foo', MyNamespace thingy.

Note to self, Enter does not do the same thing
as Ctrl-z.

The problem was that extending existing classes
etc. would cause issues since they would be also
enveloped in the new namespace. So this is only
an issue for general-purpose programming.

Kirk Haines


--
Posted via http://www.ruby-forum.com/.

.



Relevant Pages

  • RE: table datatype in EXEC string
    ... and variables have scope. ... exec usp_mySP 'customers' ... > loading the table from a number of insert/select statements in the sp before ... > The sp is being called from sql reporting services and is loading a matrix. ...
    (microsoft.public.sqlserver.programming)
  • Re: Setting namespace in loaded files
    ... On Wed, 23 Aug 2006, Luke Kanies wrote: ... I do a lot of this sort of dynamic loading with no problems. ... Write yourself a method that iterates through your search path, and write one that loads and evals a file into a specific scope, and it should come together all right for you. ... Kirk Haines ...
    (comp.lang.ruby)
  • Re: multimeter protocol
    ... when I hooked up the scope the additional loading was already too much ... wouldn't work with an extra port either, ... thought the 50 us were glitches as well, ...
    (sci.electronics.design)
  • Re: Setting namespace in loaded files
    ... On Tue, 22 Aug 2006, Luke Kanies wrote: ... method search path started at the scope doing the loading? ... If you read the file, and then eval it in the desired scope, it has the effect of loading it into that scope. ...
    (comp.lang.ruby)
  • Re: Setting namespace in loaded files
    ... method search path started at the scope doing the loading? ... If you read the file, and then eval it in the desired scope, it has the ... effect of loading it into that scope. ...
    (comp.lang.ruby)