精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-03-27
哈哈,找到证据了,原来那个getting started诚不我欺
2.11 String Strings are enclosed in double quotes ("), but is not a data type in Erlang. Instead a string "hello" is shorthand for the list [$h,$e,$l,$l,$o], that is [104,101,108,108,111]. Two adjacent string literals are concatenated into one. This is done at compile-time and does not incur any runtime overhead. Example: "string" "42" is equivalent to "string42" 不过楼上几位说得也没错。 |
|
返回顶楼 | |
发表时间:2007-03-27
String 类型在Erlang中作为一个list提供,涉及到编码的时候不是很方便。
ejabber这些项目是通过一个iconv的port来处理编码转换的问题。 |
|
返回顶楼 | |
发表时间:2007-04-01
Trustno1 写道 list_to_existing_atom(String) -> atom()
在efficiency guide中: 引用 5.2.2 Atom vs Strings
It is more efficient to send atoms than strings. However it is more inefficient to convert all strings with list_to_atom before sending them, then to send the string as it is. The best way is to always use atoms if possible. DO %% Send message on the following format {insert, {Name, Location}} {remove, Name} {retrieve_location, Name} DO NOT %% Don't send message on the following format {"insert", {Name, Location}} {"remove", Name} {"retrieve_location", Name} 以及 引用 list_to_atom/1
Since atoms are not garbage collected it is not a good idea to create atoms dynamically in a system that will run continously. Sooner or later the limit 1048576 for number of atoms will be reached with a emulator crash as result. In addition to the bad memory consumption characteristics the function is also quite expensive to execute. |
|
返回顶楼 | |
发表时间:2007-04-01
原来如此,hihi
|
|
返回顶楼 | |