简体   繁体   English

{<>}是什么意思?

[英]What does {< >} mean?

The ocaml objects tutorial contains this piece of code, but does not explain it. ocaml对象教程包含这段代码,但没有解释。

# class c0 = object method m = {< >} method n = 0 end;;
class c0 : object ('a) method m : 'a method n : int end

What does {< >} mean and where is it documented? {<>}是什么意思,在哪里记录?

There is an informal definition of this construct in Section 3.1.3 of the OCaml manual . OCaml手册的第3.1.3节对此结构进行了非正式定义。 It says: 它说:

The override construct {< ... >} returns a copy of “self” (that is, the current object), possibly changing the value of some instance variables. 覆盖构造{<...>}返回“ self”(即当前对象)的副本,可能会更改某些实例变量的值。

A more formal definition is given in Section 6.9.2 . 一个更正式的定义在6.9.2节中给出。

The expression {< >} contains no changes to instance variables, so it simply returns a copy of “self,” the current object. 表达式{< >}包含对实例变量的更改,因此它仅返回当前对象“ self”的副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM