From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: John Cowan Newsgroups: gmane.lisp.guile.user Subject: Re: C programs in Scheme syntax Date: Thu, 28 May 2020 23:57:04 -0400 Message-ID: References: <87pnantoe5.fsf@fcs20.keithdiane.us> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="55571"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Keith Wright Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri May 29 05:57:29 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 1jeW9B-000EMg-4z for guile-user@m.gmane-mx.org; Fri, 29 May 2020 05:57:29 +0200 Original-Received: from localhost ([::1]:50316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeW99-0007Qg-Id for guile-user@m.gmane-mx.org; Thu, 28 May 2020 23:57:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeW90-0007QZ-5W for guile-user@gnu.org; Thu, 28 May 2020 23:57:18 -0400 Original-Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:41729) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeW8y-0005mm-TV for guile-user@gnu.org; Thu, 28 May 2020 23:57:17 -0400 Original-Received: by mail-qk1-x72c.google.com with SMTP id n11so1060065qkn.8 for ; Thu, 28 May 2020 20:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccil-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rCvstCChoYjSmit8RRifHPOHzLd/IeuE46hQh3WHy6M=; b=Y3HAUaFUU03Xt1jmobz+u00mB4bQqpcbURUt9bddU/LACbj1wSdls0L00zFUeuzVm6 SsOND3nJcZgvM814sACZrrJQ72LUyi1EQKXBkY3pabPak+U397208uz9geO2RUGr/Uab flJzOp1Pawp3eEgBf25je0dVRGVNN4vlmuZvjIv3nYhLlHff8X4A/zZ/PkVJ4m3+xSdM hOUhipBZ2ECAZRgsVqbLNFYwdvAFE4aU4InX2KpDWUkdFZi9fOKsJKJCmfVS8Fu4sZou ERpPECpOp78oMiBQqgiBMmYsbKb+cd9RiBULoPRdpYFdYQxVjbcdZEh09dA8zRivYsvy MjqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rCvstCChoYjSmit8RRifHPOHzLd/IeuE46hQh3WHy6M=; b=a3APXv8QRbh49/RRY+JB0Z4TCEhXLhgMjFgnoirUdIzr2U+rY8Uhnrg0rr/dYNxfRr MJFjeSO9Fc5MMgTk7S1WFODEvqzUv5PHb27CAmuj5ZdfwJgmaryyfgIE6M6Mop6AWxb+ TEc+Gae33X4we/YxIB5klVBd0nmoxFvSYO5/ndX/rgy10FDwHrKZgLBNflnR62++zdry 5QDV8LVqmFrylbkCIBSOxfth1Xg/0v9y7dylDDQk5StFZ1X5/3amNJTBAKPUhQWetpBX Fk//fsFdhXnGey8zWIunqSPBldpJw3rv0wxHYPxLMXqPwyBjavPWBRjNuQLjDqCLKXai Uupg== X-Gm-Message-State: AOAM530D/qy0xOIRvg18IAiFxazYyH6wXGKx3XrDm+39FqIfrBBmhlMT KK03Fg+fPkpAmMBFTANi/WT3w54ugdGJ7B23uHKc5gnjbLM= X-Google-Smtp-Source: ABdhPJx937I2xHPiBK5E1iLpgvyqetPY3kpJLAr2lTYxU5ss5/ELHjUrq0pBC0vGtVj0sDXDAnVaFQvot5N0z83xbrM= X-Received: by 2002:a37:9f09:: with SMTP id i9mr6085174qke.60.1590724635171; Thu, 28 May 2020 20:57:15 -0700 (PDT) In-Reply-To: <87pnantoe5.fsf@fcs20.keithdiane.us> Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=cowan@ccil.org; helo=mail-qk1-x72c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:16524 Archived-At: Check out the Chibi library (chibi show c). in the Chibi repo at lib/chibi/show/c.scm and .sld. It provides combinators that create a C equivalent of the sexp; there is both a macro-based compiler and an interpreter, IIRC. Unfortunately there is no real documentation. There's some cleverness in it: c-if in statement context expands to an if-statement, but in an expression context to a ?: operator. If you import (chibi show) and (chibi show c) then (show #t (c-if 'foo 'bar 'baz)) will generate a statement, but (show #t (c+ 2 (c-if 'foo 'bar 'baz))) will generate an expression. On Thu, May 28, 2020 at 11:38 PM Keith Wright wrote: > I am thinkging about a project that uses Scheme macros > to generate C code. To this end I want to encode C > programs as S-expressions. For example, the C program > that is encoded in Ascii as > > for (j=0;j<12;++j) a[j] = j*pi/6; > > might be encoded as an S-expression as > > (for ((= j 0)(< j 12) (++ j)) (= (sub a j)(/ (* j pi) 6))) > > Note that this is not a valid Scheme program, even with > non-standard functions defined. It is a re-encoding > of the Ascii C syntax as an S-expression. > > I think I have read about something like this, perhaps > on this list, I am not sure. (Note to future language > inventors: a single letter name makes a horrible Google > search query. Name things with made up but pronouncable > words---perl, fortran...) > > I most need to convert S-expr encoded C, to Ascii encoded C, > but I am interested in > (a) programs to convert S-expresions to C > (b) specifications for the form of the S-expr encoding > (c) better plans; advice from those who have tried and failed. > > Any pointers? > > -- Keith > > >