On Jun 11, 1:35=A0pm, Ilias Lazaridis <il... / lazaridis.com> wrote:
> This is a simple Request for Comments.
>
> Scenario:
>
> require_relative 'lib/alter'
> require 'alibrary'
>
> Some project manager complains about "require_relative", and asks you
> to find a one-word alias.
>
> Which name would you select and for what reasons?
>
> Requirements
> must:
> * one word
>
> optional:
> * ideally a 7 letter word

Okay, I'm willing to respond to this b/c I think there's an
interesting alternative here that would be an improvement over the
current system.[1]

Instead of having two different methods, have the one #require that
does both. How would it work? Kind of like constant lookup. First the
require method would look locally, if it failed to find it there it
could look relative to the current loading project, and then from
there globally. Of course the problem is name conflict, but that can
easily be solved. Let's say I have lib file called 'ostruct.rb', say
it has an extension to ruby's OpenStruct class. Because of the
relative loading we wouldn't be able to just require 'ostruct' b/c it
would try to load itself. So instead we have to tell it to look
globally. We just need a way to denote it, e.g.

    require '::ostruct'

We could also be more specific and actually specify the library it is
in, which could be used to speed up load times and prevent name
clashes altogether, with:

    require 'ruby:ostruct'.

This idea of course presents backward compatibility issues, but it is
a way to do it that actually improves the robustness and efficiency of
the load system.


[1] Hey, get what you can out of him.



>
> --http://lazaridis.com