Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.04; '#include': 0.05; 'instance,': 0.05; 'subject:Python': 0.05; 'python': 0.08; 'structure.': 0.09; 'am,': 0.12; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'processed': 0.15; 'syntax': 0.15; 'code),': 0.16; 'code?': 0.16; 'files).': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handy': 0.16; 'trivially': 0.16; 'wrote:': 0.16; 'language,': 0.17; 'source.': 0.18; 'written': 0.19; 'feb': 0.22; 'header:In- Reply-To:1': 0.22; 'code': 0.25; 'compiled': 0.25; 'code.': 0.26; 'fix': 0.27; 'asking': 0.27; 'message-id:@mail.gmail.com': 0.28; 'compile': 0.28; 'fri,': 0.30; '(so': 0.30; '(unless': 0.30; 'translator': 0.30; 'usually': 0.30; 'quite': 0.31; "i've": 0.31; 'correct': 0.31; 'source': 0.32; 'languages': 0.32; 'sort': 0.32; 'it.': 0.33; 'to:addr:python-list': 0.33; 'certain': 0.34; 'executable': 0.34; 'identical': 0.34; '(not': 0.34; 'something': 0.35; '(for': 0.35; 'similar': 0.36; 'two': 0.37; 'run': 0.37; 'but': 0.37; "there's": 0.37; 'received:google.com': 0.37; 'resulting': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'think': 0.38; 'concepts': 0.38; 'why': 0.39; 'files': 0.39; 'received:209': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'your': 0.61; 'kind': 0.62; 'perfect': 0.64; 'here.': 0.64; 'become': 0.69; 'care': 0.70; 'quality': 0.74; "'em": 0.84; 'andrea': 0.84; 'source?': 0.84; 'template,': 0.84; 'technique': 0.93 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; bh=Zb3cquHnfP5SWbQ8EcOUr38UFNBRVoXfG3xNcEgvIuo=; b=F3Tkt4VX2iRAJX07CpMW8Yl9JpDgaA5sbH44A/JnUgC8SsvCXPu42MMWyZXK56goOZ qKqNQcZiAsWn51Taj9Txp4uIDCCLZFnMRVmfMLKPcJmMMUaXVmMEKc12Q/PcXeyp5vkF OLEyIrUCoHi74R0vco2TgalyGbFIbVY/lLJew= MIME-Version: 1.0 In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Date: Fri, 3 Feb 2012 13:51:49 +1100 Subject: Re: SnakeScript? (CoffeeScript for Python) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328237512 news.xs4all.nl 6844 [2001:888:2000:d::a6]:35855 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19819 On Fri, Feb 3, 2012 at 9:53 AM, andrea crotti wrote: > 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). > > Then how are you going to maintain the code? Maintain the compiled > code or the source? And proving that your translator is always correct > I think it's quite a hard task too... There's two similar concepts here. 1) Skeleton codegens. You do up some kind of template, run it through a program, and get a ready-to-fill-in code structure. In this case, you don't care so much about the translator's quality (if there's bugs/limitations, you fix 'em after codegenning), and will maintain the compiled code. 2) Compilation to Python. You write your program in some other language, run it through a program, and get executable code out of it. You want the translator to be perfect (so that you don't have to edit the resulting code), and will maintain the original source. I think the OP is looking for #2. I've used that sort of technique a number of times (not with Python specifically, but with other languages that lack certain handy features); usually the source is trivially translateable into the output, with 99% of syntax identical (for instance, one oft-wanted feature is a C-like #include - I've written .php.m4 files that get processed through M4 to become PHP files). ChrisA