[Haskell-cafe] A restricted subset of CPP included in a
revisionof Haskell 98
brianh at metamilk.com
Thu Aug 17 17:11:31 EDT 2006
On Thursday, August 17, 2006 7:54 PM, Brian Smith wrote:
> 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.
It seems to me that all uses of the preprocessor could be avoided except for
-- sparc code
-- i86 code
-- byte code
and the above could afaics be dealt with by having a conditional import
module Platforms (Platform(..)) where
data Platform = Sparc | Intel | ByteCode
module Client where
import qualified (
case #Platform of
Sparc -> Compiler.Sparc.CodeGen
Intel -> Compiler.Intel.CodeGen
_ -> Compiler.ByteCode.CodeGen
) as CodeGen
where a leading '#' denotes a preprocessor symbol (corresponding to the type
of the same name) which can only be set outside the program ie on the
command line, thus ensuring that the same module can't have multiple
interpretations in the same program.
Conditions could be formed using case, if, and expressions which can be
evaluated at compile time.
Of course this would require some effort to modify existing code, but it
would have the great advantage that the conditional compilation would be
well typed and be part of the normal grammar thus making it easier to write
Regards, (another) Brian.
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
More information about the Haskell-Cafe