Python syntax in Lisp and Scheme

Daniel P. M. Silva dsilva at ccs.neu.edu
Sat Oct 11 20:11:46 EDT 2003


Alex Martelli wrote:
> As for me personally, and for my typical customers, we have lower
> appetite for risk:

Right, and your customers use no C apps.

> In other words, I'm an engineer, not a scientist.  Scientists whose
> goals are not the programs they write -- all those for whom the
> programs are mere tools, not goals in themselves -- tend to feel
> likewise about programming and other technologies that support
> their main work but are secondary to it, though they may have
> ambitions as burning as you wish in other, quite different areas.
> 
> So, maybe, your favourite technologies are best for research in
> computer science itself, or to develop "artificial intelligence" programs
> (has the term gone out of fashion these days?) and other programs
> pushing the envelope of computer science and technology -- and
> mine are best for the purpose of delivering normal, useful, working
> applications safely and reliably.  If this is true, there is surely space
> for both in this world.

How depressing.  Leave the powerful languages to those with Computer Science
degrees and let the "software engineers" use weaker systems?  What happens
when more functionality is needed (eg., web services)?

It's now nearly the end of 2003 and web applications are still created with
old, flawed technologies -- CGI, server pages, and explicit session
objects.  Wouldn't it be nice if web applications were written like, well,
applications?

# my web adder
print_result( get_number() + get_number() )

where print_result sends out a web page, and get_number gets a number from a
web request.

> 
>> things.  If you have no ambitions beyond writing
>> yet-another-standard-web-app then macros are not for you.  But if your

He's wrong.  "Advanced" technologies like continuations and macros are
exactly what are needed to make web apps work correctly.  The web-app
writer doesn't have to know he's using any of it, but even the Apache
people realized they needed to provide more power in their application
framework.

> [...] I basically
> feel there's a huge unfilled demand for perfectly normal applications,
> best filled by technologies such as Python, which, I find, maximize the
> productivity of professional programmers in developing such apps and
> frameworks for such apps, AND empower non-professional programmers
> to perform some of their own programming, customizing, and the like.
> [...] 
> So, general macros in a general-purpose language are not for me, nor for
> all those who feel like me -- not for _production_ use, at least, though I
> do see how they're fun to play with.

What the non-professional programmer wants to write a program using two or
more languages?  Should we restrict him?  Or give him the tools...

> (py-eval "x = 1")
> (define py_x (in-python (ns-get 'x)))
> (define scm_x (->scheme py_x))
> scm_x
1
> (in-python (ns-set! 'x (->python (+ 2 scm_x))))
> (py-eval "print x")
3 

In this case, a special form is again needed:

(define-syntax (in-python stx)
  (syntax-case stx ()
    [(_ expr) #`(parameterize ([current-namespace pns])
                  expr)]))

- DS




More information about the Python-list mailing list