[MLton] mlb support

Stephen Weeks MLton@mlton.org
Mon, 26 Jul 2004 16:02:56 -0700


> Since there wasn't much response to Steve's MLton-user post on the def/use
> flags, I'd like to propose dropping -show-basis-used and having
> -show-basis print the basis of the input or derived mlb and having
> -show-def-use print the def/use info for the whole program.

OK with me.

> Here's how I'm currently exposing warnUnused annotations.  Suggestions
> welcome.
...
> Upon entering an annotation, warnUnused is modified as follows:
> 
> annotation             | effect
> -----------------------|---------------------------
> warnUnused true        | List.push(warnUnused, All)
> warnUnused false       | List.push(warnUnused, No)
> warnLocalUnused true   | List.push(warnUnused, Local)
> warnLocalUnused false  | List.push(warnUnused,
>                                    valOf (List.peek(!warnUnused, fn z =>
>                                                     z <> Local)))
> 
> I'm not quite happy with the behavior of warnLocalUnused false; but I
> don't know what would be better.

I agree it's messy.  Do you have an idiom in mind where
"warnLocalUnused false" would be useful?  If not, why not drop
warnLocalUnused for a single annotation that marks everything in scope
as used; call it "forceUsed" or "useExports".  This would also let you
turn Control.warnUnused into a WarnUnused.t ref, since there will be
no need to expose its history.

I'm also wondering about the fact that "warnLocalUnused true" enables
warnings despite the setting of warnUnused.  Since people can already
enable this with "warnUnused true", why not decouple that?

> During elaboration, if List.first(!warnUnused) = No then every
> extension of the environment forces the extension to be used.  This
> is done by modifying the newUses function in the generic extend
> function of elaborate-env.fun to check the warnUnused control in
> addition to the forceUsed argument.  Steve, is this the right place
> to do the force?

I haven't looked at that stuff in a while, so you're probably better
up on it than me, but it looks good as far as I can see.  I know I had
ideas at some point about not even recording definitions with
"warnUnused false".  That would entail changing NameSpace.newUses.
I'm don't know what the difference would be, though.