From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] question: what is the recommended use case of `val` in class type
Date: Mon, 4 Jul 2016 12:19:18 +0200 [thread overview]
Message-ID: <20160704101918.GB7663@frosties> (raw)
In-Reply-To: <9F10B996-F8B0-48A7-A5A9-21A05EE54AB1@math.nagoya-u.ac.jp>
On Sun, Jul 03, 2016 at 03:23:35PM +0900, Jacques Garrigue wrote:
> Hi Hongo,
>
> You may want to have a look at a small camlp4 syntax extension I wrote a long time ago,
> which allows to do what you say.
> Using it, one would write:
>
> val mutable x with accessor
>
> to say that it can be accessed through the x and x_set methods.
>
> The code is here:
> http://www.math.nagoya-u.ac.jp/~garrigue/code/ocaml.html
>
> Note that I didn’t try to support functional state changes, i.e. adding a method
> method x_upd x’ = {< x = x’ >}
>
> Jacques
What's the point of x then? Wouldn't it make more sense to only expose
the accessors so even derived classes will go through them instead of
accessing x directly?
Question: Can ppx attributes generate the accessors but also hide the
"val mutable x" when no mli file is present?
MfG
Goswin
next prev parent reply other threads:[~2016-07-04 10:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-02 17:23 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2016-07-03 6:23 ` Jacques Garrigue
2016-07-04 10:19 ` Goswin von Brederlow [this message]
2016-07-04 21:56 ` Jacques Garrigue
-- strict thread matches above, loose matches on Subject: below --
2016-07-05 13:00 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2016-07-02 17:02 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2016-07-02 17:07 ` Nicolas Ojeda Bar
2016-07-02 16:45 Hongbo Zhang (BLOOMBERG/ 731 LEX)
2016-07-02 16:59 ` Gabriel Scherer
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=20160704101918.GB7663@frosties \
--to=goswin-v-b@web.de \
--cc=caml-list@inria.fr \
/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