Metaprogramming has many uses in large-scale computer programming. 元编程在大型计算机编程中有许多用途。
Because you can include functions in the data structures, functional languages make excellent platforms for metaprogramming. 因为可以在数据结构中包含函数,所以函数性语言构成了元编程的优秀平台。
But the Searchable plug-in also does a bit of metaprogramming on your individual domain classes. 但Searchable插件也可以在您个人的域类上做一些元编程。
One of the most common metaprogramming scenarios is the creation of classes with attributes and methods that are dynamically generated. 使用元编程最普通的情况就是创建具有动态生成的属性和方法的类。
Unit tests are meant to run in isolation, which means that no database is running, no Web server is running, and most important no Grails-related metaprogramming occurs. 单元测试意味着在隔离环境中运行,所以不会运行数据库和Web服务器,最重要的是不会发生与Grails相关的元编程。
Metaprogramming offers a great way to differentiate pattern code from implementation code because you express your pattern by using code that is about code. 元程序设计提供一种不错的方式将模式代码与实现代码区分开来,因为您使用关于代码的代码来表达您的模式。
For a wide variety of metaprogramming tasks, this feature makes macros more predictable and easier to work with. 对于许多元编程任务,这个特性使宏更可预测并容易使用。
The Ruby language also has attributes ( although they don't have a special name like "attributes"& they are one of many metaprogramming techniques Ruby offers). Ruby语言也有属性(不过它们不像“属性”一样有特定名称&它们是Ruby提供的其中一种元程序设计方法)。
The bulk of the Ruby class Calc uses Ruby's metaprogramming features to define functions at run time for all the digit keys and for the math operation keys. 大多数Ruby类Calc使用Ruby的元编程功能,在运行时为所有数字键和数学操作键定义功能。
Over the past few Practically Groovy articles, you've seen how Groovy language features like closures and metaprogramming add new dynamic capabilities to Java ™ development. 在过去几期实战Groovy文章中,您已经了解了闭包和元编程之类的Groovy语言特性如何将动态功能添加到Java™开发中。
For making this both easier and more standardized, Embedded SQL is a metaprogramming system used to easily combine database access with C. 要让这个过程变得又简单、又标准化,那么嵌入式SQL就是一个很好的元编程系统,可以在C语言中简单地合并数据库访问的功能。
In "Metaprogramming with closures, ExpandoMetaClass, and categories," you were introduced to the notion of a delegate. 在“使用闭包、ExpandoMetaClass和类别进行元编程”一文中,您了解了delegate的概念。
In the end, when it came time to work on version two, one of the developers had come up with a clever way, using metaprogramming, to weave the internationalization code into the code base. 最后,当要使用版本2时,一个开发人员想出了一个聪明的办法,使用元编程设计将国际化代码植入代码库中。
In this Practically Groovy installment, you'll learn about metaprogramming& Groovy's ability to add new methods to classes dynamically at run time. 在这期实战Groovy文章中,您将了解元编程&Groovy在运行时向类动态添加新方法的能力。
Code-generating programs are sometimes called metaprograms; writing such programs is called metaprogramming. 用来生成代码的程序有时被称为元程序(metaprogram);编写这种程序就称为元编程(metaprogramming)。
This time, however, the failure isn't due to the lack of metaprogramming on a domain class. It's due to the lack of dependency injection. 但是,这次失败并不是因为域类上缺少元编程,而是因为缺少依赖性注入。
This is a metaprogramming method defined on the Class class that executes at interpretation time. 这是对在解释时执行的Class类定义的一个元编程方法。
You can define attributes to create declarative metaprogramming tags. 您可以通过定义属性来创建声明性元程序设计标记。
Developers who have worked in a limited number of languages ( especially languages that have anemic metaprogramming support, such as Java and C#) have an especially hard time seeing this problem. 使用有限的几种语言的开发人员(特别是那些只具备少量元编程支持的语言,比如Java和C)尤其容易出现这个问题。
While the ExpandoMetaClass is undeniably powerful, Groovy offers a second approach to metaprogramming with its own unique set of capabilities: categories. 尽管ExpandoMetaClass十分强大,但是Groovy提供了另一种元编程方法,使用了它独有的一组功能:类别(category)。
But what if you want your metaprogramming to be more limited ( especially important when writing unit tests)? 但是如果希望对元编程进行更多的显示该怎么做(对于编写单元测试尤其重要)?
First let's look at metaprogramming that involves textual macro languages. 首先让我们来看一下涉及文本宏编程的元编程。
Often, most of the code can use the metaprogramming tools available to accomplish the task. 通常,大部分代码都可以使用元编程工具来实现这个任务。
Generic programming invokes a metaprogramming facility within a language, in those languages supporting it. 泛型编程调用一个设施内的元编程语言,这些语言支持。
Without it we would not have Grails: Groovy metaprogramming makes convention over configuration possible. 没有它就没有Grails:Groovy元编程(metaprogramming)让“惯例优于配置”成为了可能。
Macros allow compile time metaprogramming, which brings even more opportunities to offload code generation to the computer ( instead of writing boilerplate or repetitive code in Java by hand). 宏可以实现编译期的元编程(compile-timemetaprogramming),帮你你把生成代码的工作扔给计算机(而不是写样板文件或者反复手工写Java代码)。
It uses metaprogramming to generate the view model and allow you to bind to the objects you define in your controller. 它使用元编程来生成视图模型,使你能够绑定至你在控制器中定义的对象。
If your metaprogramming requires eval, it's subject to the same requirements. 如果你的元编程需要eval,那它也必须遵循相同的要求。
It is rooted in a strong tradition of metaprogramming and yet goes beyond traditional methods using its concept of platform-independent models. 这种思想起源于传统的元编程,但是通过使用平台无关模型已经超越了传统的方法。