[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: bytecode unification for scripting (and other!) languages



[Oops -- I just discovered, much to my chagrin, what Ctrl-Enter does
 in Outlook.  What a dumb binding.]

> 2. Having said that, I believe that programmers should actually think
about
>    their types, in all situations. As Michael also points out, if you
>    understand the types of your program well, you avoid many mistakes.
Many
>    errors manifest themselves in violations of data invariants, and that's
>    what these simple proof systems called type systems are good at.

I disagree with the implication of this.  The implication is that, when a
programmer reasons incorrectly about their types, they should get slapped
on the hand -- whether as a static rejection, a la ML, or as a dynamic check
failure, a la Scheme, is irrelevant.

I believe there is a very useful way of relaxing this restriction to capture
the essence of scripting, while still recovering it when programs grow to
engineer software.  PLT Scheme needs a "scripting" language level, where
operators coerce heavily: APPEND consumes strings as well as
lists; FIRST works on vectors, not just pairs; + adds strings that contain
only digits; and so on.

MrSpidey then needs a scripting analysis level, where it flags these coerced
uses in ultra-special-red, meaning "this may have worked for you earlier,
but
it sure won't work now".  Based on the coercions, it can indicate what
operator you meant to use, and even synthesize the code that automatically
performs the coercion: eg,

  (append (+ S "2") "y")
  ->
  (string-append (number->string (+ (string->number S)
                                    (string->number "2")))
                 "y")

under the right circumstances.

For programs that don't live on, programmers get to write very concise
descriptions, and their minor infractions are forgiven.  But the scripting
language level should provide no programming-in-the-medium features --
no modules or units or classes, for instance.  The moment you want to
make your script reusable, you must go through Scripting Spidey and clean
up your act to upgrade your code into a mature fragment.

Shriram