• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ibudao
V2EX  ›  程序员

语法规范中的 Clause guards 该如何翻译

  •  
  •   ibudao ·
    lujb · May 19, 2014 · 4283 views
    This topic created in 4385 days ago, the information mentioned may be changed or developed.
    最近想翻译一篇Erlang的specification,碰到这样个术语:clause guard,不知道如何翻译是好。
    我不知道哪些语言也有这个概念,在erlang中,如下函数:

    is_old(Age) when is_integer(Age) and Age>60 ->
    io:format("Old man~n");
    is_old(Age) when is_integer(Age) ->
    io:format("Young man~n").

    is_old/1这个函数对参数Age有这样的检查:is_integer(Age) and Age>60,这就是clause guard,虽然一看就懂,但是真不知道该怎么翻译。。
    3 replies    2014-05-19 15:22:54 +08:00
    JoshuaJin
        1
    JoshuaJin  
       May 19, 2014
    卫戍语句
    ibudao
        2
    ibudao  
    OP
       May 19, 2014
    @JoshuaJin 卫戍?额,太高大上了,我还是直接翻译成'断言'算了。。
    bombless
        3
    bombless  
       May 19, 2014
    这种就是所谓的卫语句吧
    在Haskell和Scala的教程中都是这么叫的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5190 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:26 · PVG 16:26 · LAX 01:26 · JFK 04:26
    ♥ Do have faith in what you're doing.