On Feb 23, 2009, at 11:08 PM, Eli Barzilay wrote: > On Feb 23, Guillermo J. Rozas wrote: >>>> And why would I do that? Because, presumably, I don't want to >>>> re- type the definitions of the library that are already included >>>> in a .h file, and I'd rather write a tool that can be used and >>>> re-used as the .h file changes, than have to fix things by hand. >>> >>> (That is a perfectly fine job for a macro, BTW.) >> >> Parsing a .h file? Boy, I've written hairy macros in my life, but >> that's got to be a winner. > > I don't see why this would be hairier than writing code that parses a > header file... After all, this is Scheme, and macros are written in > Scheme. (Assuming that you're not restricted by a `syntax-rules'-only > implementation.)
No. That's not the point. It's hiding a C parser in a macro that I find 'curious' to say the least. After all, just because you can do something doesn't mean that you should. In general, the MIT tradition used macros a lot less than the Indiana tradition. It didn't avoid them, it just didn't use them as much. Macros were something to be used sparingly, when absolutely necessary. And that is not an issue of safety, but of clarity of the code. A well-chosen macro can occasionally make the code clearer, but often makes things harder to understand and debug. As Alan Bawden used to say 'people should need a license to write macros'. >>>> As part of that pre-processing, it would examine all the >>>> identifiers, and report any conflicts. >>>> >>>> I doubt that there would be many if at all. >>> >>> So in the case I describe above, it will break... >> >> No. It will produce a correct output. > > Let me repeat it: the original bindings are "foo" and "Bar", since > this is all you have, you're likely to go for the simple translation > to `foo' and `bar'. Later on the library is extended with a "FOO", > and the produced code is no longer valid, since it's missing a proper > translation for an all-caps name. *Or* you make the generator detect > such cases and adapt -- in that case, the generator saw no clashes > before and gave you `foo' and `bar', and now that there is one, it > does some automatic tweaking -- thereby breaking existing code. That assumes that the generator has no history. It is not hard to feed it its prior decisions, and only introduced oddities for new bindings, which, by definition, are not yet in use. No complaints, no warnings, no broken code. _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
