[Thinking] how to add new functions in C #

Source: Internet
Author: User

How to add functions (syntaxes and keywords) to C )?

This document does not refer to user-defined classes, functions, and so on. It refers to modifying and adding the C # syntax.

Re-develop a new language. The workload is too large and it is difficult to be scientific and practical, but it is difficult to keep up with the update progress of C #. Therefore, we chose to expand the C # method, to meet the needs of professional applications.

Scenario 1: Define an exchange operator <=> to implement the function of swap (A, B. UpperCode

Int A = 3;

Int B = 5;

A <=> B;

After that, the values of A and B are interchangeable (provided that the variables A and B are compatible)

Scenario 2: Define the With keyword

String [] filenames;
With (New openfiledialog ())
{
. Filter = "*. txt | *. txt ";
. Multiselect = true;
If (. showdialog () = dialogresult. OK)
{
Filenames =. filenames;
}
}

// Do (filenames );

The above two examples can significantly reduce the number of temporary variables used.

Idea: translate the added (modified) syntax and keywords into standard C # code, and then hand it over to Visual Studio for compilation and processing.

Problem:

1. How to integrate these changed functions in the vs code editor, such as code smart prompts, dynamic syntax check, and code coloring.

2. Translate extended keywords and syntaxes into standard syntaxes at the bottom. What interfaces does it use? For example, where is the translated code stored? How does one enable vs to automatically compile the translated code? How does one deal with the relationship between the previous and translated code?

3. How to integrate this function in the compiler? For example, how can we make compilation give correct row numbers and correct syntax recognition for previous code?

4. How can I apply the added features in other languages? How can I interoperate with VB.net?

 

Because mono and monodevelopment are both open-source, modify monodevelopmentSource codeTo achieve the above functions, what should I do?

If Visual Studio is used for development and plug-ins, can it be implemented?

What about DSL?

 

 

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.