Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation)

Kevin Jacobs jacobs at darwin.epbi.cwru.edu
Mon Jul 17 22:01:58 EDT 2000


> In a program where there are a lot of computations, you'll get either
> something like a ritual on every line,

> PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C)
> PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C)
> PyAlgebra.evaluate(r'(A .* B)\C', A=A, B=B, C=C)

What if it could be as simple as:

e(r'(A .* B)\C') # --> PyAlgebra.evaluate(r'(A .* B)\C', globals(), locals())
e(r'(A .* B)\C')
e(r'(A .* B)\C')

where A, B and C are bound to variables in the current namespace
automatically?  Does this not go 95% of the way toward the ideal solution?

> Everybody would rush for the latter.  In the end what's inside the quote
> would be a minilanguage with all the bells and wistles of python.  This
> would be just similar to patching the parser, with lesser results.

I disagree with your conclusion.  Having worked with many algebra and
statistical languages, I know the road you are undertaking.  It doesn't and
can't stop with one extra dot in the grammar.  To do it right, you need the
ability to break more rules that are intrinsic to Python's core.  e.g.,
consider changing the rules for '\' as above.

Another advantage to compromising and implementing a domain specific
mini-language is that it simplifies some very tough design issues that only
come up when working with the full Python grammar.  Some of these syntactic
and semantic issues are very likely irreconcilable.  In the end we could end
up with a any number of splinter languages with inferior support and narrow
audiences.  Lets not forget we are a community of users with very diverse
goals, all trying make our lives easier by building better tools.

-Kevin

-- 
----------->  Kevin Jacobs  <-----------|------->  (216) 778-8211  <--------
S.A.G.E. Project Technical Coordinator  | Department of Epidemiology
  & System Administrator                |   & Biostatistics
Internet E-mail: jacobs at darwin.cwru.edu | Case Western Reserve University
----------------------------------------------------------------------------



More information about the Python-list mailing list