前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Natural language style method declaration and usages in programming languages

Natural language style method declaration and usages in programming languages

作者头像
绿巨人
发布2018-05-16 18:00:49
6310
发布2018-05-16 18:00:49
举报
文章被收录于专栏:绿巨人专栏绿巨人专栏

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.

代码语言:javascript
复制
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:

代码语言:javascript
复制
function int (int a)add(int b)

\\ usage:
r = (2) add (3)
\\ or
r = 2 and 3

Example 2:

代码语言:javascript
复制
function void save(Employee employee)with(EmployeeSaveOptions options)

\\ usage:
save(employee)with(options)
\\ or
save employee with options

Example 2:

代码语言:javascript
复制
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.

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-11-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • More descriptive way to declare and use a method in programming languages
  • new way: Natural language style method declaration and usages in programming languages
    • idea
      • Example 1:
        • Example 2:
          • Example 2:
            • Explanation
              • Advantage
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档