caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] what is the application of class ref?
@ 2015-12-23  1:13 沈胜宇
  2015-12-23  3:57 ` Jeff Meister
  0 siblings, 1 reply; 2+ messages in thread
From: 沈胜宇 @ 2015-12-23  1:13 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

Dear all:

In ref manual of ocaml "3.10 Parameterized classes", there is a code segment liek this:

class ref (x_init:int) =
object
val mutable x = x_init
method get = x
method set y = x <- y
end;;

so what is the meaning of class ref?


Shen

[-- Attachment #2: Type: text/html, Size: 291 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] what is the application of class ref?
  2015-12-23  1:13 [Caml-list] what is the application of class ref? 沈胜宇
@ 2015-12-23  3:57 ` Jeff Meister
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Meister @ 2015-12-23  3:57 UTC (permalink / raw)
  To: 沈胜宇; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 764 bytes --]

The "built in" type 'a ref is implemented using a record with a mutable
field. This example from the manual is simply showing you how to implement
references using an object with a mutable instance variable instead. There
is no language construct "class ref", you are just defining a class that
happens to be named "ref". Since "ref" is just a normal identifier, not a
keyword, this is allowed.

On Tuesday, December 22, 2015, 沈胜宇 <syshen@nudt.edu.cn> wrote:

> Dear all:
>
> In ref manual of ocaml "3.10 Parameterized classes", there is a code
> segment liek this:
>
> class ref (x_init:int) =
> object
> val mutable x = x_init
> method get = x
> method set y = x <- y
> end;;
>
> so what is the meaning of class ref?
>
>
> Shen
>

[-- Attachment #2: Type: text/html, Size: 984 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-23  3:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-23  1:13 [Caml-list] what is the application of class ref? 沈胜宇
2015-12-23  3:57 ` Jeff Meister

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).