【问题标题】:Erlang atoms and ".."Erlang 原子和“..”
【发布时间】:2012-06-09 10:21:02
【问题描述】:

这是 erlang shell 的输出:

1> atom.
atom
2> next_atom.
next_atom
3> atom@erlang.
atom@erlang
4> 'atom in single quotes'.
'atom in single quotes'
5> atom = 'atom'.
atom
6> a.tom.
'a.tom'
7> a..tom.
* 1: syntax error before: '..'

当 atom 中只有一个点 .(第 6 行)时,我没有收到任何错误。但是,当有.. 时,我得到语法错误。 .. 在 Erlang 中是否有特殊含义,或者当 . 工作正常时为什么会出错?

【问题讨论】:

    标签: erlang


    【解决方案1】:

    原子中不允许点,但两个原子之间的点:'foo'.'bar', 是将原子连接到'foo.bar' 的编译时运算符。

    这是一个扩展,用于支持(尚未正式 支持)类 Java 包系统。这就是为什么它没有记录在案。

    【讨论】:

    • Afaik 带有 '.' 的语法还引入了原子作为主机名,即 bofh@home.com
    • 几年前有人问过这个问题,但似乎较新版本的 Erlang 根本不允许原子中的点。我试图粘贴一个示例,但格式不正确。 a.tom. 给我* 1: syntax error before: '.'
    猜你喜欢
    • 2017-03-01
    • 2011-01-14
    • 2012-02-17
    • 2011-07-28
    • 2015-04-27
    • 2011-08-16
    • 2016-07-01
    • 1970-01-01
    • 2013-12-29
    相关资源
    最近更新 更多