[m-users.] IO and global state.
    Julien Fischer 
    jfischer at opturion.com
       
    Mon Apr 26 16:35:57 AEST 2021
    
    
  
Hi Sean,
On Mon, 26 Apr 2021, Sean Charles (emacstheviking) wrote:
> Is it a —wise— idea to consider using globals on the IO State?
Yes.
> I have a command line option, -d/—debug which I need to refer to
> probably everywhere I write output…otherwise I have to explicitly pass
> it around… I just wondered if there was a consensus on using this
> feature?
>
> There’s also a ‘packed/quiet’ mode which guarantees zero spurious
> output, startup messages etc.
For both those things, I would use a mutable attached to the I/O
state.  (See: "Module-local mutable variables" in the reference manual.)
This is pretty much what the Mercury compiler itself does for (some of)
its global state.  (See compiler/globals.m).
Julien.
    
    
More information about the users
mailing list