[TUHS] Mac OS X is Unix

Tim Bradshaw tfb at tfeb.org
Wed Jan 4 22:26:45 AEST 2017


On 4 Jan 2017, at 03:50, Dan Cross <crossd at gmail.com> wrote:
> 
> Interesting, but I'm curious how this would work in the context of C (or a C-like variant)? The code must parse and type-check in accordance with the existing standard, no? So if the `if(LINUX)` branch referred to, say, Linux-specific structure members, then how would the compiler recognize that avoid spitting out a diagnostic/erroring out? The existing C language seems defined to expressly disallow this sort of thing.


Common Lisp has a notion of 'suppressing the reader' which basically means that the reader (which in CL is the thing which turns a stream of characters into the data structure that is the source code of the language) will do just enough to consume a form, but not any more than that.  In particular it will ignore all sorts of things which would make it very unhappy if it looked too closely at them.  And there are then read-time conditionals which will cause the reader to suppress the following thing, or not.  It seems to me that, even without defining how things work in the very fine-grained way that CL does (where the data structure the reader produces is defined and you can program the reader itself), a C-like language could define what it means to 'suppress' a form, and support conditionals which did that.  I think, reading again, that this might be quite close to your compile-time-evaluated idea.

The thing to avoid is 'language in a string', where one language contains another language in strings (or equivalent), because then you end up putting the inner language together by concatenating strings, which can cross-cut constructs in the inner language in a horrible way.  C is the language in a string of the C preprocessor.  Where I work we use a tool which has a deeply horrible preprocessor which has the main syntax as its language in a string.  That syntax *in turn* has a whole other language in its strings.  Every time I look at this I want to hit someone.

--tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20170104/c241047f/attachment.html>


More information about the TUHS mailing list