zoukankan      html  css  js  c++  java
  • Erlang Module and Function

    Module
     
    -module(Name).
    模块是方法的集合。注意这行最后的“.”符号是必不可少的。
    这个模块名必须和保存这段代码的文件(后缀为“erl”的文件)有相同的名称。
    当我们在使用另一个模块中的函数时,我们使用下面的语法module_name:function_name(arguments).
    在模块中的注释用“%”表示,一直到这一行的结束。
     
    -Tag(Value).
    模块中包括一系列的属性列表。
    属性可以用Module:module_info(attributes)或者beam_lib(3)得到。
     
    -compiled(export_all).
    -export([Function/Arity,...]).
    -import(Module,[function/Arity,...]).
    -author(Name).
    -date(Date).
    -behaviour(Behaviour).
    -record(Name, Field).
    -vsn(Version).
    -include("SomeFile.hrl").
    -define(Macro,Replacement).
    -file(File, Line).
    -type my_type() :: atom() | integer().
       自定义类型特别是在record中有助于进行类型检查
    -spec my_function(integer()) -> integer().
       对于方法的参数和返回值进行类型的定义,用以TypEr进行类型的检查。
     
     
    module_loaded(Module) -> bool()
       判断模块是否被装载。(并不会试图装载模块)。
    %% This BIF is intended for the code server (see code(3)) and should not be used elsewhere.
     
    =============================================================
    Function
     
    函数的返回值是最后一个表达式执行的结果
    =============================================================
  • 相关阅读:
    哈希表
    c++中的虚函数
    struct并不报错
    c风格的字符串
    动态数组
    常量指针和指针常量
    关于struct和typedef struct
    常量成员函数
    关于free的使用疑惑
    mutable用于修改const成员函数中的成员变量
  • 原文地址:https://www.cnblogs.com/fvsfvs123/p/4267415.html
Copyright © 2011-2022 走看看