Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19833

Re: SnakeScript? (CoffeeScript for Python)

References <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> <CAL7_Mo-b6F7moEvK9BkvCqNb7GOZJmEaVb6u3Mi-CaboFpxhiw@mail.gmail.com> <CAF_E5JbBdZuNRyUbEKBkrac5dVEQQtpAq=1B1HwL8QuL3q+TcQ@mail.gmail.com> <CALwzidmZBDVQ2hARLK_WmTASFR+V-u==6TJvs2Jp1LM1_0xV7Q@mail.gmail.com>
Date 2012-02-03 09:08 -0500
Subject Re: SnakeScript? (CoffeeScript for Python)
From Nathan Rice <nathan.alexander.rice@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5404.1328278135.27778.python-list@python.org> (permalink)

Show all headers | View raw


>> Mm I don't think it's what the OP is asking (unless I misunderstood...).
>> I think he wants to compile some syntax TO Python.
>> But I don't really see why you would something like this (if not for fun).
>
> Maybe because you think that Python syntax could be improved upon --
> for instance, Python with pattern-matching would be freaking awesome
> -- but at the same time you want to leverage Python's extensive
> ecosystem of libraries.  So instead of creating your own brand-new
> language with no third party libraries whatsoever, you create one that
> just compiles down to regular Python.

You can generalize the dictionary based dispatch used for "case"
statements to do this.  The main downsides are:

1.) You have to define your functions ahead of time or use lambdas
2.) The syntax is not quite as nice as it could be (e.g.)

foo = DispatchDict({
    Pattern1: f1,
    Pattern2: f2,
    etc...
})

Reminds me more of javascript than I would like.

>> Then how are you going to maintain the code? Maintain the compiled
>> code or the source?
>
> As with all compiled software, you maintain the input, not the output.

I think maintaining the output can be valuable.  There are going to be
things that can be expressed in the more verbose expanded form that
will not be easily expressible in the terse pre-translated macro.
Unfortunately, most macro writers don't put much time into making sure
their macro produces concise code.

>> And proving that your translator is always correct
>
> That's what unit tests are for.

I have a love hate affair with unit tests.  You need them, but I'd
really rather analytically prove that my software is correct under
some set of assumptions.


Cheers,

Nathan

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

SnakeScript? (CoffeeScript for Python) Michal Hantl <michal.hantl@gmail.com> - 2012-02-02 06:09 -0800
  Re: SnakeScript? (CoffeeScript for Python) Paul  Moore <p.f.moore@gmail.com> - 2012-02-02 08:30 -0800
    Re: SnakeScript? (CoffeeScript for Python) Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-02-02 12:12 -0500
    Re: SnakeScript? (CoffeeScript for Python) Michal Hantl <michal.hantl@gmail.com> - 2012-02-02 12:23 -0800
      Re: SnakeScript? (CoffeeScript for Python) "bruno.desthuilliers@gmail.com" <bruno.desthuilliers@gmail.com> - 2012-02-03 04:03 -0800
  Re: SnakeScript? (CoffeeScript for Python) andrea crotti <andrea.crotti.0@gmail.com> - 2012-02-02 22:53 +0000
  Re: SnakeScript? (CoffeeScript for Python) Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-02 18:19 -0700
    Re: SnakeScript? (CoffeeScript for Python) Matej Cepl <mcepl@redhat.com> - 2012-02-03 11:42 +0100
      Re: SnakeScript? (CoffeeScript for Python) alex23 <wuwei23@gmail.com> - 2012-02-06 19:52 -0800
  Re: SnakeScript? (CoffeeScript for Python) Chris Angelico <rosuav@gmail.com> - 2012-02-03 13:51 +1100
  Re: SnakeScript? (CoffeeScript for Python) Nathan Rice <nathan.alexander.rice@gmail.com> - 2012-02-03 09:08 -0500
  Re: SnakeScript? (CoffeeScript for Python) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-02-03 11:20 -0500
  Re: SnakeScript? (CoffeeScript for Python) andrea crotti <andrea.crotti.0@gmail.com> - 2012-02-03 17:24 +0000

csiph-web