[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C programs in Scheme syntax

From: tantalum
Subject: Re: C programs in Scheme syntax
Date: Sun, 31 May 2020 15:40:03 +0000
User-agent: Posteo Webmail

ive started 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]