您的位置:首页 > 其它

Natural language style method declaration and usages in programming languages

2016-11-01 10:49 459 查看

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐