<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><span style="font-size: 12pt;">We have:</span><br><div><br></div><div><br></div><div>cm3/MODULE M3Backend;</div><div> </div><div>...</div><div> </div><div> VAR </div><div> obj_file : M3ObjFile.T := NIL;</div><div> obj_wr : Wr.T := NIL;</div><div> obj_name : TEXT := NIL;</div><div> log : Wr.T := NIL;</div><div> log_name : TEXT := NIL;</div><div><br></div><div>...</div><div>PROCEDURE Close (<*UNUSED*> cg: M3CG.T) =</div><div> BEGIN</div><div> IF obj_file # NIL THEN</div><div> TRY</div><div> NTObjFile.Dump (obj_file, obj_wr);</div><div> EXCEPT Wr.Failure, Thread.Alerted =></div><div> Msg.FatalError (NIL, "problem writing object file: ", obj_name);</div><div> END;</div><div> Utils.CloseWriter (log, log_name);</div><div> obj_file := NIL;</div><div> obj_wr := NIL;</div><div> obj_name := NIL;</div><div> log := NIL;</div><div> log_name := NIL;</div><div> END;</div><div> END Close;</div><div><br></div><div><br></div><div><br></div><div>Surely we should add those variables to M3CG_Ops in order</div><div>to get them to Close for this specific M3CG?</div><div><br></div><div><br></div><div>i.e. prefer "instance variables" over "module variables" aka globals.</div><div><br></div><div>Perhaps in a record called M3Backend to give an appearance of opacity</div><div>or perhaps in an actual opaque type, though I hate to pay for the</div><div>extra heap allocation just to achieve opacity.</div><div><br></div><div> </div><div>(Larger point is the cm3 is written an old unfortunate thread-unsafe style with many globals.)</div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;"><br></span></div><div><span style="font-size: 12pt;">And this is a good reason then to smush M3CG.T and M3CG_Ops.T together,</span></div><div>in order for M3Backend.New() result to be passed back to Close.</div><div><br></div><div><br></div><div> - Jay</div> </div></body>
</html>