Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'instance,': 0.05; 'subject:Python': 0.05; 'python': 0.08; '1.)': 0.09; 'etc...': 0.09; 'foo': 0.09; 'libraries.': 0.09; 'macro.': 0.09; 'output': 0.10; 'syntax': 0.15; '(e.g.)': 0.16; '2.)': 0.16; 'brand-new': 0.16; 'code?': 0.16; 'ecosystem': 0.16; 'input,': 0.16; 'terse': 0.16; 'language': 0.17; '\xa0so': 0.18; 'cheers,': 0.20; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'concise': 0.23; 'dictionary': 0.23; 'expanded': 0.23; 'produces': 0.23; 'tests.': 0.23; 'libraries': 0.24; "python's": 0.24; 'code': 0.25; 'creating': 0.25; 'compiled': 0.25; 'tests': 0.25; 'code.': 0.26; 'asking': 0.27; 'message-id:@mail.gmail.com': 0.28; 'compile': 0.28; '(unless': 0.30; 'translator': 0.30; 'quite': 0.31; 'correct': 0.31; 'like.': 0.32; 'instead': 0.33; 'to:addr:python- list': 0.33; 'there': 0.33; 'this.': 0.33; 'rather': 0.34; 'something': 0.35; 'things': 0.35; 'received:209.85.160.46': 0.35; 'received:mail-pw0-f46.google.com': 0.35; 'received:209.85.160': 0.35; 'regular': 0.35; 'awesome': 0.36; 'to:name:python-list': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'could': 0.37; 'some': 0.38; 'received:209.85': 0.38; 'put': 0.38; 'third': 0.38; 'think': 0.38; "i'd": 0.39; 'why': 0.39; 'are:': 0.39; 'define': 0.39; 'maintaining': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'under': 0.40; 'most': 0.60; 'more': 0.61; 'your': 0.61; 'love': 0.62; 'making': 0.65; 'hate': 0.73; 'writers': 0.77; 'compiles': 0.84; 'nathan': 0.84; 'source?': 0.84; 'affair': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=IbOrFc0ATWWwopbq5RMk5RojsrDSFLBs0l/LZGoWGJw=; b=YFp8kYVQav2mKl8RIHgMp1QpVhYBjEBEW6jzRqM3DGnZh81Rs+GzOsvg9tbM3iNCLb 1djzC4rSDcADi4907FR9GhTfhZ9Z4571g2UvP2GIhvbuP2b96ZIlRk7K5OL69eFfrssv e5AmctgtnFWf/CJMVmEGfdwXXbqkO+ZHd/OSo= MIME-Version: 1.0 In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Date: Fri, 3 Feb 2012 09:08:51 -0500 Subject: Re: SnakeScript? (CoffeeScript for Python) From: Nathan Rice To: python-list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328278135 news.xs4all.nl 6966 [2001:888:2000:d::a6]:51575 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19833 >> 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. =A0So 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 =3D 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