zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    QT学习笔记
    局域网摄像头安装与调试
    从0开始搭建视觉检测智能车
    树莓派安装anaconda
    手把手教你搭建视觉检测智能车
    树莓派与Arduino串口通信实验
    树莓派设置关机重启键
    树莓派can通信
    树莓派GPIO使用笔记
    MySQL练习题
  • 原文地址:https://www.cnblogs.com/steven-yang/p/6018602.html
Copyright © 2011-2022 走看看