[erlang-questions] where did my code come from?

Joe Armstrong erlang@REDACTED
Tue Sep 13 09:19:13 CEST 2011


I had an idea on my way to work ...

When you write code, you have *implicit* knowledge of where the
external code comes from.

When I write the following:

     -module(foo).
      ...
     start() ->
          X = lists:reverse(...),
          Y = elib1_misc:zap(...)
          Z = misultin:request(...)
     ...

I "know" that lists is part of my local OTP install, elib1_misc is my
own library installed
in ~/code/elib2_1/ebin and misultin is an imported project stored in
~/imports/misultin
I also know that my paths etc are setup so this code will work when I
run the program.

The problem is the *nobody else* knows this.

I could tell the system like this:

    -module(foo).

    -location(lists,
"https://github.com/erlang/otp/blob/dev/lib/stdlib/src/lists.erl").
    -location(elib1_misc,
"https://github.com/joearms/elib1/blob/master/lib/src/elib1_misc.erl").
    -location(misultin,
"https://github.com/ostinelli/misultin/blob/master/src/misultin.erl").

    ...


   The location annotation give a *definitive source" for the module I
am using in the module

    What could you do with this information?

    Answer - a lot - for starters

         - automatically check for "latest versions" of libraries
download them when they change
         - provide "who uses my code" feedback to the authors of the code
         - publish (globally) lists of "definitive" versions of code
         - recursive track and code dependencies (What do I mean)
            when my system discovers that I use misultin - it
downloads misultin.erl
            misultin.erl will have location dependencies which I can
follow, thus the libraries
            that misultin calls can be fetched.
         - automate code loading

    Most often this kind of "additional" information is kept "outside
the program" by strictly
annotating the program with the location dependencies we bring this
information *into* the program
in a form where it cannot be detached from the source code.

    Comments?

   /Joe



More information about the erlang-questions mailing list