Programming in Scala (Second Edition) 读书笔记27 注解
2014-12-15 13:59
399 查看
Annotations are structured information added to program source code. Like
comments, they can be sprinkled throughout a program and attached to any
variable, method, expression, or other program element. Unlike comments,
they have structure, thus making them easier to machine process.
注解是附加到源码的结构化信息,就像注释,散布在程序的各个地方。注解可以被附加的任何变量
,方法,表达式或其它程序元素。但是不像注释,注解是有结构的,所以可以很容易被机器理解
元编程的任务:
1. Automatic generation of documentation as with Scaladoc.
2. Pretty printing code so that it matches your preferred style.
3. Checking code for common errors such as opening a file but, on some
control paths, never closing it.
4. Experimental type checking, for example to manage side effects or
ensure ownership properties.
Such tools are called meta-programming tools, because they are programs that take other programs as input. Annotations support these tools by
letting the programmer sprinkle directives to the tool throughout their source
code.
一其它程序作为输入的工具称为元编程工具,注解支持这类工具
comments, they can be sprinkled throughout a program and attached to any
variable, method, expression, or other program element. Unlike comments,
they have structure, thus making them easier to machine process.
注解是附加到源码的结构化信息,就像注释,散布在程序的各个地方。注解可以被附加的任何变量
,方法,表达式或其它程序元素。但是不像注释,注解是有结构的,所以可以很容易被机器理解
元编程的任务:
1. Automatic generation of documentation as with Scaladoc.
2. Pretty printing code so that it matches your preferred style.
3. Checking code for common errors such as opening a file but, on some
control paths, never closing it.
4. Experimental type checking, for example to manage side effects or
ensure ownership properties.
Such tools are called meta-programming tools, because they are programs that take other programs as input. Annotations support these tools by
letting the programmer sprinkle directives to the tool throughout their source
code.
一其它程序作为输入的工具称为元编程工具,注解支持这类工具
相关文章推荐
- Programming in Scala (Second Edition) 读书笔记4
- Programming in Scala (Second Edition) 读书笔记6 函数和闭包
- Programming in Scala (Second Edition) 读书笔记23 再论For表达式
- Programming in Scala (Second Edition) 读书笔记6 函数式对象
- Programming in Scala (Second Edition) 读书笔记21 隐式转化
- Programming in Scala (Second Edition) 读书笔记2
- Programming in Scala (Second Edition) 读书笔记12 Trais
- Programming in Scala (Second Edition) 读书笔记13 packages and import
- Programming in Scala (Second Edition) 读书笔记15 case class and pattern matching
- Programming in Scala (Second Edition) 读书笔记7 内置控制结构
- Programming in Scala (Second Edition) 读书笔记10
- Programming in Scala (Second Edition) 读书笔记12 Trais
- Programming in Scala (Second Edition) 读书笔记26 Extractors
- Programming in Scala (Second Edition) 读书笔记3
- Programming in Scala (Second Edition) 读书笔记12 Trais
- Programming in Scala (Second Edition) 读书笔记5
- Programming in Scala (Second Edition) 读书笔记18 Stateful Object
- Programming in Scala (Second Edition) 读书笔记15 使用List
- Programming in Scala (Second Edition) 读书笔记8 函数和闭包
- Programming in Scala (Second Edition) 读书笔记12 Trais