When colon scripting is comming (JavaScript syntax extension)

Source: Internet
Author: User
Tags javascript extension

When the colon script comes --

Javascript syntax Extension

After several consecutive nights of silence, we can conclude that future language compilers should support syntax customization rules and syntax extension, so that the programming language will evolve to make it easier for humans to use! Of course, the colon idea comes from the JSON expression. In the previous article, the preliminary form of JavaScript extension is preliminarily expressed. That is, the colon declares the assignment, Lambda;

Supplement: Object Organization Form

The colon assigns compatibility in addition to the JSON object form. If we want to organize data in JSON format, the data is expressed in JSON format and separated by commas.

The object format is fully organized by the colon language. Example:

// Organize object expressions with semicolons: object: {// propertyname: "obj1"; No: 1; properties: // JSON object FORM {prop1: name, prop2: No }; // method func2function func2 () {return name ;}; // so here call its methodresult: object. func2 ();

Of course, it is best to separate JSON data from scripts to describe soft configuration and other data storage files.

The script is mainly used to process data and generate other inputs.

Language mode, interface for interaction with other language systems

For static languages such as C/C ++, the coordination of multiple modules in parallel and synchronous development requires the coordination of an interface document, such as. h. Imagine a. h is nothing more than to describe the data organization structure required by the interface, so it is some structure declarations, some types of expressions, and the function call Convention Declaration for operating these types of data.

Of course any program development, the task is large enough, always requires collaborative development by multiple people, or requires a certain form of pre-organized. Because the script is, there should also be such a type description system, which cannot be expressed in a set of modes. Such as static languages, this is required by the system. Because the freedom of the scripting language is loose enough and easy to operate, this step is generally not used unless a complete function library is produced and will be promoted to many people, at this time, the corresponding instructions must be generated. Since all documents are required, can we seek the same formal expression for representation?

Specifies the type object of an attribute.

Here we still need to use a colon to express its meaning; in fact, we directly use Pascal to declare variables;

Form name: typename;

Organize expressions of a Class Object

An organizational class object is actually a new type name;

C/C ++ has key statements. This is free of charge. It is different from attribute assignment and Script Name assignment. We will not add a colon to describe it, which is the most direct and closest to the C/C ++ structure.

The following is an example:

// Object Mode representation // The following describes the structure of a class of objects. Object // Object Schema {// propname: typenameproperty: int; Name: string; // Hehe, declare a method // it like a C ++ 11 form // method: function (INT, string)-> int; // method2: function ()-> object; // return the object // Following like the Pascal, right! It's clearfunction method (Arg: int, arg2: string): int; function method2 (): object; // declare a methodx can attach a Lambda processor, // and Its no return object; function methodx (Arg: object, lambda) ;}; // object defined over

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.