TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

An Erlang WAT-story about guards and guards

52 点作者 elbrujohalcon将近 9 年前

5 条评论

yetihehe将近 9 年前
In erlang 'and' has higher priority than comparisons. So 'is_integer(X) and X > 0' is interpreted as '(is_integer(X) and X) > 0'. 'andalso' has lower priority than comparisons so it is interpreted as we expect.
njharman将近 9 年前
I really don&#x27;t understand the aversion?, lack of use? of parenthesis. Back in college (before C++ was released to give you time scale) some C class, spent a lot of time on operator precedence. I was like, why bother? Just use parens, be explicit, clear and never ever have to learn or be bit by any language&#x27;s precedence ever!<p>Ever.
pepesza将近 9 年前
Just FYI. Brujo is close to being expert in Erlang. This post is a more of a &quot;warning for juniors&quot; than &quot;damn, today I&#x27;ve discovered something new&quot;.<p>And there is nothing really WAT about it. Just part of rather simple Erlang language grammar.
评论 #12050032 未加载
评论 #12048956 未加载
评论 #12050018 未加载
Luc将近 9 年前
I always use &#x27;,&#x27; and &#x27;;&#x27; in guards. Maybe I&#x27;m weird but it feels wrong using the short-circuit operators knowing that guards are always short-circuited anyway. Also they take up too much space :)
评论 #12049829 未加载
chriswarbo将近 9 年前
Reminded me of `and`, `or`, etc. precedence in PHP, e.g. <a href="http:&#x2F;&#x2F;php.net&#x2F;manual&#x2F;en&#x2F;language.operators.precedence.php#117390" rel="nofollow">http:&#x2F;&#x2F;php.net&#x2F;manual&#x2F;en&#x2F;language.operators.precedence.php#1...</a>