atom. atom 2> next_atom. next_atom 3> atom@erlang. atom@erlang 4> 'atom in s-6ren">
gpt4 book ai didi

Erlang原子和 ".."

转载 作者:行者123 更新时间:2023-12-04 16:40:30 33 4
gpt4 key购买 nike

这是 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 中有一些特殊含义或者为什么我在 . 时会出错工作正常?

最佳答案

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

这是一个扩展,用于支持(仍未正式
支持)类似Java的包系统。这就是它没有记录的原因。

关于Erlang原子和 "..",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10896638/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com