zoukankan      html  css  js  c++  java
  • LYSE-类型

    动态强类型

    在运行时捕捉所有错误。

    多数语言的目标是做到没有错误,而Erlang假设错误会发生因此要覆盖所有错误。

    强类型,不会进行隐式的类型转换。

    类型转换

    使用erlang模块的内建函数  

    1> erlang:list_to_integer("54").
    54
    2> erlang:integer_to_list(54).
    "54"
    3> erlang:list_to_integer("54.32").
    ** exception error: bad argument
    in function  list_to_integer/1
    called as list_to_integer("54.32")
    4> erlang:list_to_float("54.32").
    54.32
    5> erlang:atom_to_list(true).
    "true"
    6> erlang:list_to_bitstring("hi there").
    <<"hi there">>
    7> erlang:bitstring_to_list(<<"hi there">>).
    "hi there"

    守护数据类型

    is_atom/1           is_binary/1        
    is_bitstring/1      is_boolean/1        is_builtin/3       
    is_float/1          is_function/1       is_function/2      
    is_integer/1        is_list/1           is_number/1        
    is_pid/1            is_port/1           is_record/2        
    is_record/3         is_reference/1      is_tuple/1 

    Erlang设计为给正确的范例编程。

    守护表达式使用的其它BIFs:

    abs(Number), bit_size(Bitstring), byte_size(Bitstring), element(N, Tuple), float(Term), hd(List), length(List), node(), node(Pid|Ref|Port), round(Number), self(), size(Tuple|Bitstring), tl(List), trunc(Number), tuple_size(Tuple).
  • 相关阅读:
    性能优化与使用Block实现数据回传(3)
    封装思想和抽取(2)
    磁盘缓存的计算与清理(1)
    滑动返回的延伸(全局滑动返回功能)
    滑动返回功能被覆盖的解决思路
    OC之类与对象
    OC之OC与C的比较
    OC之知识储备篇
    C语言之总结3
    C语言总结2
  • 原文地址:https://www.cnblogs.com/sqxy110/p/4997079.html
Copyright © 2011-2022 走看看