[英]Erlang Types Specifications
I recently read the source code of couch-db, I find this type definition which i don't understand: 我最近阅读了couch-db的源代码,我发现这个类型定义我不明白:
-type branch() :: {Key::term(), Value::term(), Tree::term()}.
-type path() :: {Start::pos_integer(), branch()}.
-type tree() :: [branch()].
I did read Erlang doc , But what is the meaning of Start , Key , Value and Tree ? 我确实阅读过Erlang doc ,但Start , Key , Value和Tree的含义是什么? From what i understand, they are Erlang variables!
据我所知,它们是Erlang变量! I didn't find any information about this in Erlang doc .
我在Erlang doc中没有找到任何关于此的信息。
Start
etc. are just descriptive names for the respective parts of the terms, to make it easier for humans to read the type definition. Start
等只是术语各部分的描述性名称,以使人们更容易阅读类型定义。 They have nothing to do with actual variable names. 它们与实际变量名无关。
(Side note: Unfortunately, even in OTP R14B, edoc
still does not read -type
and -spec
for generating its HTML documentation - it uses the old @type
and @spec
instead.) (旁注:不幸的是,即使在OTP R14B中,
edoc
仍然没有读取-type
和-spec
来生成HTML文档 - 它使用旧的@type
和@spec
代替。)
Update: The official docs on -type
and -spec
. 更新: 关于
-type
和-spec
的官方文档 。 More things to search for are the word success typing and the manuals for dialyzer and typer . 更多要搜索的内容是成功输入这个词以及透析器和typer的手册。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.