#3549: unlit does not follow H98 spec
-----------------------------+----------------------------------------------
Reporter: duncan | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.10.4 | Severity: normal
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
-----------------------------+----------------------------------------------
The Haskell 98 spec has this to say about the
[http://haskell.org/onlinereport/syntax-iso.html Latex \begin{code}
\end{code}] style:
An alternative style of literate programming is particularly suitable
for use with the LaTeX text processing system. In this convention, only
those parts of the literate program that are entirely enclosed between
\begin{code}...\end{code} delimiters are treated as program text; all
other lines are comment. More precisely:
* Program code begins on the first line following a line that begins
\begin{code}.
* Program code ends just before a subsequent line that begins
\end{code} (ignoring string literals, of course).
The key phrases are "a line that begins \begin{code}" and "line that
begins \end{code}". This means the semantics is something like:
{{{
classifyLine s
| "\\begin{code}" `isPrefixOf` s = BeginCode
| "\\end{code}" `isPrefixOf` s = EndCode
}}}
GHC's `unlit` C program uses:
{{{
if (strcmp(buf, "\\begin{code}") == 0)
return BEGIN;
}}}
The equivalent semantics in the style above would be:
{{{
classifyLine s
| "\\begin{code}" == s = BeginCode
| "\\end{code}" == s = EndCode
}}}
It seems fairly clear from the spec that GHC's unlit program is wrong in
this respect.
The practical consequence is that Cabal's unlit and GHC's one do not match
and this [http://haskell.org/pipermail/haskell-
cafe/2009-September/066780.html catches people out]. There is
[http://www.haskell.org/haskellwiki/Literate_programming#Hiding_code_from_Haskell
explicit advice on the Haskell wiki] recommending that people take
advantage of this GHC bug.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3549>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs