The new Visual Cobol 2010 from Micro Focus has interesting, although non-standard features. For example, code expressiveness has improved a lot by eliminating the need of temp variable declaration in working-storage section:
set button1::Location to new System.Drawing.Point( 244 109)
Cobol 2002 standard would require that "Point" class was defined in the Repository, then in the working-storage section, then an instance for it was created by Invoke verb. Only after all these previous steps that we could set button1::Location to the new Point class instance. Verbosity, verbosity, verbosity.
The WinForm designer has been greatly improved by this new feature. Lets take a look in a simple example, a window with a push button.
class-id WindowsFormsApplication1.Form1 is partial inherits type System.Windows.Forms.Form.
method-id NEW.
procedure division.
invoke self::InitializeComponent
end method.
method-id button1_Click final private.
procedure division using by value sender as object e as type System.EventArgs.
set button1::Text to "Hello" end method.
end-method.
end class.
Since the compiler supports partial, the generated code is behind the scene. Thanks to removal of Repository and temp variables declaration, the generated code is readable and concise. With Repository and temp variables creation the very same code would require over 600 extra lines to express the same...
This is the partial code generated by Visual Cobol 2010:
class-id WindowsFormsApplication1.Form1 is partial
inherits type System.Windows.Forms.Form.
01 button1 type System.Windows.Forms.Button.
01 components type System.ComponentModel.IContainer.
*> Required method for Designer support - do not modify
*> the contents of this method with the code editor.
method-id InitializeComponent private.
procedure division.
set button1 to new System.Windows.Forms.Button
invoke self::SuspendLayout
*>
*> button1
*>
set button1::Location to new System.Drawing.Point( 244 109)
set button1::Name to "button1"
set button1::Size to new System.Drawing.Size( 75 23)
set button1::TabIndex to 0
set button1::Text to "button1"
set button1::UseVisualStyleBackColor to True
invoke button1::add_Click(new System.EventHandler(self::button1_Click))
*>
*> Form1
*>
set self::ClientSize to new System.Drawing.Size( 672 305)
invoke self::Controls::Add(button1)
set self::Name to "Form1"
set self::Text to "Form1"
invoke self::ResumeLayout(False)
end method.
*> Clean up any resources being used.
method-id Dispose override protected.
procedure division using by value disposing as condition-value.
if disposing then
if components not = null then
invoke components::Dispose()
end-if
end-if
invoke super::Dispose(by value disposing)
goback.
end method.
end class.
Visual Cobol is a great OO Compiler with excellent type inference, and very good integration with Visual Studio 2010. The non-standard features should be considered by ISO/JIS/ANS workgroups since they greatly improve expressiveness and readbility of OO Cobol code. Micro Focus could also learn a lesson from others and remove runtime fees as well.