The yukky syntax was meant to allow you to specify what type the function
had
i.e.
if Foo.f has type Double -> Double
then requesting Foo.f::Int->Int would fail.
I like the idea of being able to pickup polymorphic functions tho.
I had initially only considered monomorphic ones but this is due to
thinking of going through the Dynamic mechanism.
One thing I dont like, is going through IO, although I guess this wouldnt
matter so much.
once I start doing that it seems I have to use glasgow's unsafe IO stuff or
make all my functions IO-returnric :-/
I suppose it comes down to
if (performUnsaveIO.f) always returns the same answer to the same arguments
why does f return (IO a) rather than (a)
This is how I feel about commandline arguments.
since for any program run this would not change I personally would rather
that args was just a constant globally-available at runtime. I feel the same
way about configuration files.
i.e. there could be some mechanism where we can define a readAndCache which
does not
repeat actions.
-----Original Message-----
From: George Russell [mailto:[EMAIL PROTECTED]]
Sent: 25 January 2000 17:23
To: Chris Angus
Cc: 'Peter Hancock'; '[EMAIL PROTECTED]'
Subject: Re: Relection
Chris Angus wrote:
>
> Put simply
>
> What do people think about being able to access functions from other
modules
> without
> importing the module.
>
> i.e. Rather than
>
> ---------------Start-------------
> import Foo
> -- call f
> callFoof x = f x
> --------------End----------------
>
> We can do
>
> ---------------Start-------------
> callFoof x =
> case (getFunction "Foo.f" (bot::Int -> Int) ) of
> (Just f) -> f x
> (nothing) -> error "Foo not linked in"
> ---------------End---------------
My first reaction is "ugh" but on further consideration it is at least
an intriguing idea. But I think the syntax is wrong. Perhaps you could
have something like this:
loadModule :: String -> IO Module
-- dynamically load module, or raise some
-- sort of exception
lookupName :: Module -> String -> IO a -- lookup name or give exception
Then code might look like
do
fooModule <- loadModule "Foo"
fooF <- (lookupName fooModule "f") :: IO (Int -> Int)
. . .
lookupName would need to be a special compiler primitive and there would
need to be special compiler magic to pass the most general possible type
for its result to the RTS. For example
applyFooF x =
do
fooF <- lookupName fooModule "f"
return (fooF x)
might have to fail except in the unlikely case that Foo.f turned out to
have type (for all a,b) ( a -> b ).