From: Jeff Meister <nanaki@gmail.com>
To: 沈胜宇 <syshen@nudt.edu.cn>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] what is the application of class ref?
Date: Tue, 22 Dec 2015 19:57:29 -0800 [thread overview]
Message-ID: <CAHaHOqTMDVYU4bCbFGRA3S_+pQZgTJBuU8dokghs9hArytYvXw@mail.gmail.com> (raw)
In-Reply-To: <54dde531.10d.151cc657e75.Coremail.syshen@nudt.edu.cn>
[-- 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 --]
prev parent reply other threads:[~2015-12-23 3:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 1:13 沈胜宇
2015-12-23 3:57 ` Jeff Meister [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHaHOqTMDVYU4bCbFGRA3S_+pQZgTJBuU8dokghs9hArytYvXw@mail.gmail.com \
--to=nanaki@gmail.com \
--cc=caml-list@inria.fr \
--cc=syshen@nudt.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox