I think Prototype is a bad idea to start typing right now, because of: Class.create, Object.extend, use of .prototype, use of 'this', use of the DOM, use of base classes (RegExp), use of constructors.
I think Prototype is a bad idea to start typing right now, because of: Class.create, Object.extend, use of .prototype, use of 'this', use of the DOM, use of base classes (RegExp), use of constructors.

In more detail:

Prototype is filled with Class.create({...}) calls. What this does is
it dynamically defines an object. So there's no way to type the
Class.create function ATM, since that object can have anything in it,
except maybe to leave it as untyped code and have it take a
{}. However, the parameter to create is an object which contains
functions that use the 'this' variable, and the type of that 'this'
variable is the very object you're giving to create! This might be
possible, but we need two things first:

1) Typing of 'this'
2) Generics.
3) Really funky generics that can manipulate properties of Objects,
and can also specify that a type has to be an object.
4) constructor types, since Class.create returns a constructor.

Class.create would have to be specified as follows:
  function create(o) :: (T, a type that is an Object, where every field of the
    object that is a function has a this type of T --> a constructor that
    takes as many arguments as T's initialize field)

Maybe we can extend our type system to allow stuff like that. Maybe
that's a bad idea.

Prototype also has the 'Object.extend' function, which changes the type of
whatever is given as its first parameter.

Maybe we can leave all those in the untyped world and just type the
resulting, final objects, after all the Class.create and Object.extend
calls. In that case we have to change our framework to run a bunch of
untyped code, then have some typed code with 'external' statements to
wrap the untyped code in contracts, and then have some typed / untyped
code that uses them.

Maybe I can 'unwrap' Object.extend calls and Class.create calls to make
this feasible... I'll give it a try.

brownplt/strobe-old,brownplt/strobe-old,brownplt/strobe-old