我想称之为副作用编程,但必须有一个更好的术语来形容它
以下编程范例的名称是什么:
代码是基于一组解析为 true(子句)的逻辑测试来执行的。该子句由运算符和操作数组成。每个操作数都是一个值/对象。
不像命令式语言那样显式评估子句(例如,像 if(){}
这样的正常流程控制),而是声明该子句并将其绑定到结果代码。当满足该子句时,在将来的任何时候,代码都会执行。
因此,它基本上是一个依赖关系树,每当依赖关系更改状态时,它都会重新评估代码是否应该执行。
例如,
when(a && b && c < 3 && d.changes())
{
runThisCode();
}
我正在寻找一个更正式的名称和定义,但在搜索后我还没有想出任何东西。它介于声明式和命令式之间,但我从未见过一种语言或范例可以让人们做到这一点。
谢谢, 肖恩
What is the name of the following programming paradigm:
Code is executed based on a set of logical tests resolving to true (the clause). The clause is comprised of operators and operands. Each operand is a value/object.
Instead of evaluating the clause explicitly, as is done in imperative languages (e.g., normal flow control like if(){}
), the clause is declared and bound to the resulting code. When the clause is satisfied, at any point in the future, the code will execute.
So, it's basically a dependency tree that re-evaluates whether the code should execute whenever a dependency changes state.
E.g.,
when(a && b && c < 3 && d.changes())
{
runThisCode();
}
I'm looking for a more formal name and definition, and I haven't come up with anything after searching for it. It's somewhere between declarative and imperative, but I've never seen a language or paradigm that lets one do this.
Thanks,
Sean
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许它是数据流编程?或者响应式编程?
Maybe it is dataflow programming? Or reactive programming?
对我来说听起来像是一个规则引擎。例如,在 Jess 中,您可以定义此类声明性规则并调用命令式或面向对象的 Java 代码。
Sounds like a Rule engine to me. E.g. in Jess you can define such declarative rules and call into imperative or object-oriented Java code.