Natural language style method declaration and usages in programming languages
More descriptive way to declare and use a method in programming languages
At present, in most programming language, a method is declared in few parts:
keyword, method name, method parameters and return type etc.
E.g.
function int add(int a, int b)
\\ The way to use it:
int r = add(2, 3)
new way: Natural language style method declaration and usages in programming languages
idea
The idea is to split a method name into multiple parts, and put parameters before/between/after these name parts.
Example 1:
function int (int a)add(int b)
\\ usage:
r = (2) add (3)
\\ or
r = 2 and 3
Example 2:
function void save(Employee employee)with(EmployeeSaveOptions options)
\\ usage:
save(employee)with(options)
\\ or
save employee with options
Example 2:
function (int a)add(int b) result is (return int)
\\ usage:
int r = (2) add (3)
\\ or
int r = 2 and 3
\\ or
(2) add (3) result is int r
Explanation
- For each parameter part, it may includes 0+ parameter(s).
- For return data type, we may use parameter style with a keyword return inside, e.g. result is (return (DataType))
Advantage
The new way makes code is more readable.
非常感谢阅读!如有不足之处,请留下您的评价和问题。
请“推荐”本文!
请“推荐”本文!