"Typed Notation" for "Weakly-Typed" languages

From EditPlus Wiki
Jump to: navigation, search

Why is there a "Typed Notation" section in the JScript Auto-Completion Cliptext file?

The "Typed Notation" syntax is invented by me for those "weakly-typed" languages--Oops, perhaps somebody else has invented it far before me. :)

Known by us all, JScript is not actually a strongly-typed language, sometimes, commenting the exact type requirements for a certain functions or variables might be of help when programming.

So that is why the notation is introduced. For example, you wrote a function:

function TextWriter (fileName) { 
   this.FileName = fileName;
   this._init = true;

Actually it is a constructor from which you can get a TextWriter object. The declaration might be more readable in the following form:

function /* class */ TextWriter (/*string*/ fileName) {
	/*public*/ /*string*/ this.FileName = fileName;
	/*private*/ /*bool*/ this._init = true;

When you read the declaration, you immediately have the following ideas:

  1. This function is actually a constructor function of a JScript object--from the "/*class*/".
  2. It accepts a string variable--from the "/*string*/".
  3. We can access the public property "FileName" of TextWriter--from the "/*public*/".
  4. However, we should NOT access or modify the boolean property "_init" which is commented as "private" (/*private*/ /*bool*/).

You might understand the statements better with the "Typed Notation" in this way.

You can also apply such kind of notations onto other "weakly-typed" languages for example SQL, VBScript, etc.

Since inputing the "/* */" annotation is not so easy, I put it into the auto-completion cliptext so that you can input them a little easier. Be sure to check up that file, if you found it useful at[EditPlus.com User Files].

This trick is originally provided by W. Jordan