Here is my little idea,
i won't stand for it though
hipster writes:
>
> 1. Version check syntax
>
> ruby version
> require "1.6" # at least 1.6
Instead of numeric version number what about 'features'
e.g.
require "thread" supporting "pre-emption" ?
Of course it can also be
require "ruby" supporting "1.6"
> 2. How libraries (can) specify their versions
supports "pre-emption";
supoprts "1.6"
> for binary libraries (*.so), every .so implements (e.g.):
> char* library_version(){
> return "4.2";
> }
.so's are best loaded thru a .rb, which does all the check,
and loads and binds .so functioncs. This way, .rb can select
a proper implementation ( e.g. of a fractal.so is loaded in
multi-threaded or uni-threaded enviroment.
e.g.
1.
require "fractal" supporting "multi-threaded"
-- fractal.rb loads fractal.so, and aliases
Fractal.draw to fractal.so/draw-multi
2.
require "fractal" supporting "mono-threaded"
-- fractal.rb loads fractal.so, and aliases
Fractal.draw to fractal.so/draw-uni
> 2.1 A more fine-grained scheme
IMHO class-level-thing will be a _bad_ idea, still for
completeness:
clas Foobar [ << Inherits ]
supports "foo","bar"
>
> AFAICS the above scheme does not collide with the current versionless
> requires and libraries.
(-;
> If there are multiple versions of the same library present in the search
> path, they are all tried until a match is found. If no library matches the
> first on the path is loaded (with a warning?). <uneasy feeling>
But to check the version, you have to load a library, which
may do something bad ( setting a variable at top level ), and then you
load next library which may do more bad ( check that variable to see
if already loaded !!! ).
IMHO, you'll have to run a 'indexer' on library, which will
generate a neat little table:
library -- version -- physical_path --
This will also reduce 'magic', and fast up loading a
little.
>
>
--
Vardhan Varma <vardhan / cadence.com> +91-118-4562842 Extn / VMail: 4123
Random Quote: The only thing you take with you when you're gone
is what you leave behind. -John Allston