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.

  • 相关阅读:
    mysql dns反说明的成绩
    Solaris 11 安装图解(1)
    Meld 1.1.5
    Open Movie Editor-视频编纂器
    Solaris 11 装配图解(6)
    Pidgin 2.0.2
    Subversion 1.4.4 发布
    Solaris 11 安装图解(5)
    Solaris 11 安置图解(3)
    HTML 实体盘诘东西
  • 原文地址:https://www.cnblogs.com/steven-yang/p/6018602.html
Copyright © 2011-2022 走看看