Perl 作为元数据工具有何用处?
How is Perl useful as a metadata tool?
Normally, you can simply hide a third-party product behind a
well-defined, abstract interface. In fact , we've always been able to
do so on any project we've worked on. But suppose you couldn't isolate
it that cleanly. What if you had to sprinkle certain statements
liberally throughout the code? Put that requirement in metadata, and
use some automatic mechanism, such as Aspects (see page 39 ) or Perl,
to insert the necessary statements into the code itself.
这里作者指的是 Aspect Oriented Programming 和 Perl 作为支持 "automatic mechanisms" 插入元数据的工具。
在我看来,我设想了某种类型的 运行-时间注入代码。 Perl 如何允许 "automatic mechanisms" 插入元数据?
向前跳到代码生成器部分。作者提供了很多处理输入文件生成代码的例子,包括这个:
Another example of melding environments using code generators happens when different programming languages are used in the same application. In order to communicate, each code base will need some information in commondata structures, message formats, and field names, for example. Rather than duplicate this information, use a code generator. Sometimes you can parse the information out of the source files of one language and use it to generate code in a second language. Often, though, it is simpler to express it in a simpler, language-neutral representation and generate the code for both languages, as shown in Figure 3.4 on the following page. Also see the answer to Exercise 13 on page 286 for an example of how to separate the parsing of the flat file representation from code generation.
练习 13 的答案是一组用于从通用输入文件生成 C 和 Pascal 数据结构的 Perl 程序。
Normally, you can simply hide a third-party product behind a well-defined, abstract interface. In fact , we've always been able to do so on any project we've worked on. But suppose you couldn't isolate it that cleanly. What if you had to sprinkle certain statements liberally throughout the code? Put that requirement in metadata, and use some automatic mechanism, such as Aspects (see page 39 ) or Perl, to insert the necessary statements into the code itself.
这里作者指的是 Aspect Oriented Programming 和 Perl 作为支持 "automatic mechanisms" 插入元数据的工具。
在我看来,我设想了某种类型的 运行-时间注入代码。 Perl 如何允许 "automatic mechanisms" 插入元数据?
向前跳到代码生成器部分。作者提供了很多处理输入文件生成代码的例子,包括这个:
Another example of melding environments using code generators happens when different programming languages are used in the same application. In order to communicate, each code base will need some information in commondata structures, message formats, and field names, for example. Rather than duplicate this information, use a code generator. Sometimes you can parse the information out of the source files of one language and use it to generate code in a second language. Often, though, it is simpler to express it in a simpler, language-neutral representation and generate the code for both languages, as shown in Figure 3.4 on the following page. Also see the answer to Exercise 13 on page 286 for an example of how to separate the parsing of the flat file representation from code generation.
练习 13 的答案是一组用于从通用输入文件生成 C 和 Pascal 数据结构的 Perl 程序。