扩展和/或参数对象作为属性

发布于 01-22 09:12 字数 484 浏览 5 评论 0原文

正如我现在从 array作为对象,因为使用非参数logtalk对象意味着我必须使用断言,即任何更改/设置重写整个数组。

问题是:

  • 您如何扩展数组类..
  • 或将其实例化为主机类

点1

:- object(a2d, instantiates(array)).

:- end_object.
  • 中的属性
     引用未知对象:数组
     

即使有效,您如何在内部访问它。

Point2

意味着以某种方式修改术语?

As I understand now from Array as object I have to use parametric object, because using non-parametric Logtalk objects implies that I have to use assert i.e. any change/set rewrites the whole array.

The problem is then :

  • how do you EXTEND the Array class..
  • OR instantiate it as ATTRIBUTE in the host class

Point 1

:- object(a2d, instantiates(array)).

:- end_object.
  • Reference to unknown object: array
    

even if it works, how do u access it internally .

Point2

means modifying the Term somehow ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆2025-01-29 09:12:09

在该参数对象解决方案中,该对象用于封装在数组表示上工作的谓词,而对象参数用于保留代表数组本身的(化合物)项。

在这种情况下,参数对象,a prototype 可以是扩展作为任何其他原型:

:- object(a2d(_Array_), extends(array(_Array_)).

:- end_object.

请注意,参数对象的标识符是array(_)(即一个复合术语)。因此,数组(_)数组是不同对象的标识符。

In that parametric object solution, the object is used to encapsulate the predicates working on the array representation and object parameter is used to hold the (compound) term representing an array itself.

The parametric object, a prototype in this case, can be extended as any other prototype:

:- object(a2d(_Array_), extends(array(_Array_)).

:- end_object.

Note that the identifier of the parametric object is array(_) (i.e. a compound term). Thus, array(_) and array are identifiers for different objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文