V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xuanwu
V2EX  ›  分享发现

一种改进中文 API 可读性的方法:参数不限于在末尾

  •  
  •   xuanwu · 2020-01-03 17:39:30 +08:00 · 1681 次点击
    这是一个创建于 1546 天前的主题,其中的信息可能已经有所发展或是发生改变。
    5 条回复    2020-01-07 10:44:32 +08:00
    shutongxinq
        1
    shutongxinq  
       2020-01-03 20:54:37 +08:00 via iPhone   ❤️ 1
    支持楼主
    robinchina
        2
    robinchina  
       2020-01-04 10:51:04 +08:00
    支持。

    uniapp 不支持中文,不会英文的我只能用拼音了
    xuanwu
        3
    xuanwu  
    OP
       2020-01-05 01:19:38 +08:00
    @robinchina 请问是哪些标识符不支持中文命名?之前在 vue 中试过,支持的还不错的样子: https://zhuanlan.zhihu.com/p/30917346
    baobao1270
        4
    baobao1270  
       2020-01-05 15:14:31 +08:00
    感觉这样不如这种格式:
    N.房间(1).桌子(1).写入颜色(黑色);

    知乎里的 string replace 可以用这种方式解决:
    Replace(origin => "string aaa", from => "aaa", to => 'bbb');
    "string aaa".Replace().From("aaa").To("bbb");

    个人认为原文所述的方式容易导致歧义。
    xuanwu
        5
    xuanwu  
    OP
       2020-01-07 10:44:32 +08:00
    @baobao1270 可以看看文章最后一部分,Agda 可作参考。另外,链式调用也有其局限性。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   956 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 21:42 · PVG 05:42 · LAX 14:42 · JFK 17:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.