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
     
    函数的返回值是最后一个表达式执行的结果
    =============================================================
  • 相关阅读:
    【JavaScript】--ajax
    【Django】--Models 和ORM以及admin配置
    【Django】--基础知识
    【jQuery】--图片轮播
    双系统 windows引导项添加
    LVM
    linux安全加固
    oracle 11G 配置侦听文件
    LVM
    《virtual san 最佳实践》节选 Virtual SAN的发展与现状
  • 原文地址:https://www.cnblogs.com/fvsfvs123/p/4267415.html
Copyright © 2011-2022 走看看