[M3devel] declaring/initializing variables "anywhere"

Jay K jay.krell at cornell.edu
Tue Aug 4 12:02:03 CEST 2015


I had:

PROCEDURE CompileProcAllocateJmpbufs (p: Proc) =VAR module := Module.Current ();    alloca := Module.GetAlloca (module);    size := Module.GetJmpbufSize (module);    try_count := p.try_count;BEGIN

which is fairly nice and elegant.I like the static type inference.

but p could be NIL so I need like:

PROCEDURE CompileProcAllocateJmpbufs (p: Proc) =VAR module: Module.T;    alloca: CG.Proc;    size: CG.Var;    try_count: INTEGER;BEGIN    IF p = NIL THEN RETURN END;    module := Module.Current ();    alloca := Module.GetAlloca (module);    size := Module.GetJmpbufSize (module);    try_count := p.try_count;

double the lines, and a need to state types that I didn't have to state before,

OR I can use WITH to get the "best" of both, but implied extra indentation.


Pretty much all other mainstream languages in use today,except C89, are "better" than this, they all let youboth delay local variable declaration until arbitrarilyinto a function, but with implying that you should indent further,or close an extra block.

Most mainstream languages also share Modula-3's type inferenceand let you omit the type, except C.

Can we update Modula-3 here somehow?

Or just use "with"?

Proposals for a syntax that works well with the existing language and compiler?

Thank you, - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20150804/f269dfd2/attachment-0001.html>


More information about the M3devel mailing list