精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-03-24
问题儿童,还请多见谅 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-03-24
可能大致明白一点了,刚才发现原来还有 {process_atom, Process_Node} ! Msg. 这种用法。
|
|
返回顶楼 | |
发表时间:2007-03-24
erlang的atom是有数量限制的,不过一般的程序都不用考虑这个问题.只是你不要没有限制地使用list_to_atom这样的函数,因为程序无限制的从list中转换atom会使得atom 表溢出.一般可以使用list_to_exit_atom来避免这个问题.
|
|
返回顶楼 | |
发表时间:2007-03-24
回帖专用 写道 erlang的atom是有数量限制的,不过一般的程序都不用考虑这个问题.只是你不要没有限制地使用list_to_atom这样的函数,因为程序无限制的从list中转换atom会使得atom 表溢出.一般可以使用list_to_exit_atom来避免这个问题.
atom居然有数量限制,atom数量太多会导致atom表溢出,这个实在让我太吃惊了。不明白为什么Erlang中或者说其实现会做这么一个限制? 另外, list_to_atom我简单的理解就是把一个list转换成atom,但是list_to_atom和list_to_exit_atom的区别是什么? |
|
返回顶楼 | |
发表时间:2007-03-25
按照我的理解,atom类似Ruby里面的symbol,从底层角度来说是一个指针,这点可以从Port中对应的类型那里可以看得到。
此外我找不到list_to_exit_atom这个函数,3楼的能否解释一下? |
|
返回顶楼 | |
发表时间:2007-03-26
list_to_existing_atom(String) -> atom()
|
|
返回顶楼 | |
发表时间:2007-03-26
list_to_existing_atom(String) -> atom()
Types: String = string() Returns the atom whose text representation is String, but only if there already exists such atom. Failure: badarg if there does not already exist an atom whose text representation is String. 这样说来,它的作用在于将接收到的外来字符串转换为atom时使用 try list_to_existing_atom(String) catch Class:Error -> % 异常处理 end |
|
返回顶楼 | |
发表时间:2007-03-26
晕了.我的理解是Erlang中没有其他语言中的String这种类型,为什么突然多了这么一种数据类型了呢?
还麻烦问一下楼上的,我看到的捕获异常的写法是 case catch list_to_existing_atom(List) of class:Error -> ###异常处理 end. 有你写的: try list_to_existing_atom(String) catch Class:Error -> % 异常处理 end 那种写法吗?我没见过 ![]() |
|
返回顶楼 | |
发表时间:2007-03-26
引用 try Expr
catch [Class1:]ExceptionPattern1 [when ExceptionGuardSeq1] -> ExceptionBody1; [ClassN:]ExceptionPatternN [when ExceptionGuardSeqN] -> ExceptionBodyN end 引用 catch Expr
两种语法都是可以的 |
|
返回顶楼 | |
发表时间:2007-03-26
Erlang有String这种数据类型吗?我一直以为"This is not a data type of string"归属于数据类型列表,只不过是一个整数列表,但并不是另外一种叫做String的数据类型.
![]() |
|
返回顶楼 | |