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

Re: Vectors as functions



mike@newhall.net wrote:

>     My point is I don't see why programmer constraints that help
> optimization, code analysis, etc., and their opposite freedoms cannot
> coexist in one language as choices a programmer can make with
> knowledge of the tradeoffs, rather than being made by the language
> designer.  Certainly there are many optimizations applied by compilers
> optionally, depending on the local circumstances.

It's entirely possible.  In fact, DrScheme, the programming
environment for PLT Scheme, provides not one view of Scheme but
several.  As you scale up the language level ladder, you gain
expressive power but lose the ability to catch certain kinds of
errors.  (For instance, in a language without higher-order functions,
certain kinds of expressions become *syntactically* illegal.)

Unfortunately, this kind of choice is very hard to provide.  DrScheme
mainly provides a series of syntactic analyses (the constrained
versions of Scheme have additional checks).  It would be possible to
exploit these constraints, but because features interact in all sorts
of subtle ways, it's very difficult to get much meaningful reuse
without having first exhaustively worked out what will and won't
interfere.

In short, this boils down to a semantic reuse problem.  It's a hard
problem in that I know very few techniques that are a substitute for
brute-force human labor.  On the other hand, if you're willing to do
the hard work manually, it's an easy problem -- just implement the
language x operation grid:

                            parser  compiler  optimizer  verifier ...
  first-order functions
  + higher-order functions
  + exceptions
  + continuations
        :
        :

The more general you make your starting point, the harder you would
have to work to get something usable, because the default version of
the tool will have to handle the language in all its generality, and
just recognizing when what you have is an instance of a restricted
subset is often quite difficult.  If you've tried to write an
optimizing compiler, or even just a useful program analysis engine,
you will know exactly what I'm getting at.

Shriram