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

Re: AOP/Fast matrices/Type hinting



Noel-

Thanks for the pointers to AOP, type hinting and the suggestion
regarding
pattern matching. 

Thanks for the mention of Zodiac. I was trying to figure out what it
did. I though at first from a few references it was some sort of visual
programming or GUI building system.

The pattern matching should help a lot if I tried to move the translator
beyond a "toy" translator implementation -- where presumably the match
syntax will be much more concise than the simplistic approach I took
there. 

Nice idea to wrap the hints using a special form. It is true that I'm
just as happy to have a "special hacks" list to apply for the
transformation process if it works (which is how Squeak does
translation). However, the special form you mention is much more
modular, and I like the idea of it in theory knowing enough about the
translation process to complain early on to the developer if the
function does not meet the assumptions needed for easy numerical
translation (like use of car/cdr or numerous other functions implying a
more complex runtime, or use of tail recursion or other unusual
constructs that are more difficult to translate.) This sort of special
form would make it much easier for others (i.e. students) to do this
sort of optimization because they might have immediate feedback in
DrScheme when the violate a translation assumption. 

-Paul Fernhout
Kurtz-Fernhout Software 
=========================================================
Developers of custom software and educational simulations
Creators of the Garden with Insight(TM) garden simulator
http://www.kurtz-fernhout.com

Noel Welsh wrote:
> 
> Here are the links to the AOP research that describes the `loop
> collapsing':
> 
> http://www.stanford.edu/~amitp/Java/amgoyal/aop.html
> http://www.parc.xerox.com/csl/groups/sda/publications/papers/Kiczales-ECOOP97/for-web.pdf
> 
> There is a package called SERIES for Common Lisp that appears to do
> the same sort of thing:
> 
> http://series.sourceforge.net/
> 
> All of the above is Lisp so should be eminently stealable and
> hackable. It is possible that doing this kind of smart programming
> would get back the losses from a rather simple minded
> compiler. Anything that is better than Matlab will get my attention!
> 
> -------
> 
> Type hinting:
> 
> The way Gambit does type hinting (which I think is the same as Common
> Lisp) is with the declare special form.
> 
> http://www.iro.umontreal.ca/~gambit/doc/gambit-c.html
> 
> "special form: declare declaration...
> 
> This form introduces declarations to be used by the compiler(currently
> the interpreter ignores the declarations). This form can only appear
> where a define form is acceptable. Declarations are lexically scoped
> in the same way as macros. The following declarations are accepted by
> the compiler:
> 
> [snip]
> 
> (number-type primitive...)
>             Numeric arguments and result of the specified primitives
> are known to be of the given type (all primitives if none
> specified). number-type can be: `generic', `fixnum', or `flonum'."
> 
> -------
> 
> Re Paul's simple translation program:
> 
> Take a look at the pattern matching system in MzLib (match.ss). I find
> it makes this sort of code a lot easier.
> 
> E.g.
> 
> (define (print-infix-call-arg arg)
>   (if (list? arg)
>       (print-call arg)
>       (print arg)))
> 
> can be written as
> 
> (require-library "match.ss" "mzlib")
> 
> (define print-infix-call-arg
>   (match-lambda
>     [(arg . rest) (print-call arg)]
>     [arg (print arg)]))
> 
> Note square brackets [] are equivalent to parentheses ()
> 
> DrScheme comes with a parser system called Zodiac, described best in
> the DrScheme Extension Manual. I suspect its is over-kill if you only
> want to compile a limited subset of Scheme to C (but maybe the
> vocabularies will help?)
> 
> cya,
> Noel
> --
> Noel Welsh
> http://www.dai.ed.ac.uk/~noelw/   noelw@dai.ed.ac.uk