On 8/17/06, <b class="gmail_sendername">John Meacham</b> &lt;<a href="mailto:john@repetae.net">john@repetae.net</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Aug 17, 2006 at 11:44:17AM -0500, Brian Smith wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I find it strange that right now almost every Haskell program directly or<br>&gt; indirectly (through FPTOOLS) depends on CPP, yet there is no effort to
<br>&gt; replace CPP with something better or standardize its usage in Haskell.</blockquote><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
see this paper for some interesting work on the subject.<br><a href="http://citeseer.ist.psu.edu/wansbrough99macros.html">http://citeseer.ist.psu.edu/wansbrough99macros.html</a></blockquote><div><br>Thanks for that. I should have not said &quot;there is no effort to replace CPP&quot; before. I hope I did not offend anybody that has worked on this problem previously.
<br><br>I was also mistaken in saying that syntax could be fully checked without knowing any preprocessor symbol bindings. This is only true if one gets rid of the ability to choose between two syntaxes via the preprocessor.&nbsp; But, if we allow syntax that we can't parse (but presumably another implementation can), then the preprocesor must remain a true preprocessor. Then there isn't much reason to place so many restrictions on where the various preprocessor directives may appear.
<br><br>I proposed to limit where #define could appear mostly for asthetic reasons. If #define, #error, and #warn only appear at the beginning of a file, then the rest of the file would only contain Haskell syntax in between #if...#else...#endif. Also, a refactoring tool would not have these directives get in its way.
<br><br>I want to have conditionals limited in their placement to make things easier for refactoring tools. But, I don't have any ideas about how to deal with conditional exports without allowing preprocessor conditionals in the export list.
<br><br>* #define can only be used for parameterless definitions<br>* #define'd symbols are only visible to the preprocessor
<br>* #define can only give a symbol a value that is a valid preprocessor expression<br>* #define, #error, and #warn can only appear above the module declaration<br>* a preprocessor symbol, once defined, cannot be undefined or redefined with a different value
<br>
* #include and #undef are prohibited<br>*
The preprocessor can only be used at the top level. In particular, a
prepropcessor conditional or #line would not be allowed
within the export list or within a top-level binding.
<br>* A Haskell program must assume that any top-level symbol
definitions are constant over the entire program. For example, a
program must not depend on having one module compiled with one set of
command-line preprocessor symbol bindings and another module defined
with a different set of bindings.
<br>* preprocessor directives must loosely obey * #define can only be used for parameterless definitions<br>* #define'd symbols are only visible to the preprocessor
<br>* #define can only give a symbol a value that is a valid preprocessor expression<br>* #define can only appear above the module declaration<br>* a preprocessor symbol, once defined, cannot be undefined or redefined<br>

* #include and #undef are prohibited<br>*
The preprocessor can only be used at the top level. In particular, a
prepropcessor conditional, #error, #warn, #line would not be allowed
within the export list or within a top-level binding.
<br>* A Haskell program must assume that any top-level symbol
definitions are constant over the entire program. For example, a
program must not depend on having one module compiled with one set of
command-line preprocessor symbol bindings and another module defined
with a different set of bindings.
<br>* preprocessor directives must obey a very simple layout rule: an #if, #else, or #endif cannot be indented more than the bindings it &quot;contains.&quot;<br><br></div></div>