From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: tantalum Newsgroups: gmane.lisp.guile.user Subject: Re: C programs in Scheme syntax Date: Sun, 31 May 2020 15:40:03 +0000 Message-ID: Reply-To: sph@posteo.eu Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="81539"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Posteo Webmail To: Guile user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun May 31 17:40:19 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfQ4R-000L6i-Jc for guile-user@m.gmane-mx.org; Sun, 31 May 2020 17:40:19 +0200 Original-Received: from localhost ([::1]:33010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfQ4Q-0001hY-Kh for guile-user@m.gmane-mx.org; Sun, 31 May 2020 11:40:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfQ4G-0001hP-8U for guile-user@gnu.org; Sun, 31 May 2020 11:40:08 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:33845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfQ4E-00032x-Qr for guile-user@gnu.org; Sun, 31 May 2020 11:40:07 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 33C112400FB for ; Sun, 31 May 2020 17:40:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.eu; s=2017; t=1590939604; bh=QMWbLUs21Zf+Rz0LGJotbwGdhvBI8tytSJRlyWS9NeU=; h=Date:From:To:Subject:From; b=VQVPqFgIbJWPkPn2emDMLmbFyMwfPeiuIbOT/e3s4jmpZKxxOzE28JGJ0PcFDiBYz X0ZnRzK4nnT8MMz90f5/WsvYxBtLjlbzsm+SjBcB65EsiyhyJeh1VMVJanxh5G4yOq jae6iPm/3y27QXD8v0+xiX9fbCG8J1qxaN/TK3ROmQDxtd5K/MwhsU5xSv3Hv726Xh zwrT3fJVHr6HjXb8YAq080eSe3Nv96ViFlelI97JoiSoSloJljE3PlQmaAeFfTC8h8 7PLpSf6owCMKQxBd/7g9Cb2KqWuHePSDxYGSf4uLxyYyJ8HtKbt43F1RZl9YeBK9YO q2H0nRqSERKbg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 49ZjDM5BCYz9rxB for ; Sun, 31 May 2020 17:40:03 +0200 (CEST) Mail-Reply-To: sph@posteo.eu X-Sender: sph@posteo.eu Received-SPF: pass client-ip=185.67.36.66; envelope-from=sph@posteo.eu; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 08:26:17 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16543 Archived-At: ive started https://github.com/sph-mn/sph-sc and have been using it a lot over the years and worked through several c edge cases. i enjoy using it, more and more even. the git repository page contains several hints and ideas on the general topic. i you have any questions, i'd be happy to answer them. a few key points about sc: * it uses scheme read to parse code but that discards scheme comments and other ways to insert c comments are needed. using guile-reader instead works, but it is a c library to be compiled by the user and i often faced autotools issues with it * i guess it would be possible to do the whole generation process via scheme macros. it might be better than the approach currently implemented in sc, as the scheme macro system and scheme comments are immediately available. syntax checks with hints on error would be nice. the translation process of sc calls procedures for all elements of the nested list of expressions returned by scheme read. first going through the tree top to bottom - possibly translating whole subtrees to c strings or returning sc to be parsed again, then bottom to top to handle remaining elements - elements which might be lists with arguments that have been previously translated. sescript, the javascript variant of sc, uses hashtables that map s-expression prefixes to replacer functions, which is easier to extend than the case statements used by sc * the reason why i havent implemented a scheme style macro system for sc yet is that the task of implementing something like syntax-rules or syntax-case seems quite daunting. a good pattern matcher and preserving hygiene seem to be the top issues. simpler macro systems are possible, quickly implemented even, but all in all i havent hit a clear need for it yet (still thinking what i would do with it) and fear that it might create hard to read c code. then again, it might simplify c code because of a reduced dependence on the preprocessor * sc has automated tests with input/output listed, this could be helpful for finding edge cases even in other projects * with s-expressions, automated code documentation for c becomes easier than ever before