The scope:
---------
Looking at the Hugs98 (November release) I found an
interesting extension: dynamic scoped variables.
(for reference, just read the Hugs98 documentation,
that can be found at their site).
<http://www.cse.ogi.edu/PacSoft/projects/Hugs/hugsman/exts.html>
This extension just come to what I have been
looking for to use in a Computer Algebra system
am developing. It has been too hard to accomplish
what I want without them.
My problem:
----------
One of the algorithms I have to implement is the
addition of symbolic expressions. It should have
two symbolic expressions as arguments and should
produce a symbolic expression as the result. But
how the result is produced is depending on series
of flags that control how the expressions is to
be manipulated. This set of flags should then be
passed as a third argument to addition function.
This is the correct way of doing it. But, being
a Mathematics application, my system should preserve
the tradicional Math notation (that is, infix
operators with suitable associations defined). So
my symbolic expression type should be an instance
of the Num class so that the (+) operator can
be overloaded for it. But, as the function has
now three arguments, it cannot be a binary operator
anymore.
Monads are not suitable:
-----------------------
I thought about hiding the environment (the set of
flags mentioned above) inside a reader monad, but
then there will a series of problems about the
notation and the Math notation will be impossible.
Dynamic scoping is the solution:
-------------------------------
If I could pass around the environment indirectly to
my addition function, then it would remain a 2-argument
function and would be implemented as
binary operator. Defining the environment as dynamic scoped
variable just do it for me. In fact, that is how the
computer algebra system has been implemented in its first
version using the Scheme programming language.
The questions:
-------------
I can develop my system in Hugs98 using this extension. But
I will end up with a program that is non-portable across
other Haskell implementations. So,
- Is dynamic scoping a stablished feature in Hugs98?
(Will it continue to be offered in next releases, or is
it just experimental and may be dropped soon?)
- Is it feasible to incorporate this feature into the
next version of Haskell?
- Does other Haskell implementations (ghc, nhc, hbc, ...)
would provide this extension in next releases? (This way,
even been an extension, my system would be portable)
Any comments on these subject will be apreciated.
Regards.
J. R. Malaquias
--
Prof. José Romildo Malaquias <[EMAIL PROTECTED]>
Departamento de Computação
Universidade Federal de Ouro Preto
Brasil