Permalink
Browse files

[doc] stdlib,reference,mutable: advise the use of Mutable instead of …

…Reference
  • Loading branch information...
1 parent 507a4b4 commit 3bb1e06d7fbbe82dd8b5553f80a9a1d4cd3d72c4 @OpaOnWindowsNow OpaOnWindowsNow committed Feb 16, 2012
Showing with 29 additions and 24 deletions.
  1. +21 −12 stdlib/core/mutable.opa
  2. +8 −12 stdlib/core/reference.opa
View
@@ -1,5 +1,5 @@
/*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of OPA.
@@ -16,19 +16,31 @@
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * {1 About this module}
- *
- * {1 Where should I start?}
- *
- * {1 What if I need more?}
- */
/**
* {1 Types defined in this module}
*/
+/**
+ * The type of mutable element.
+ * @param 'a The type contained in the element.
+ * get returns the content of the mutable element.
+ * set changes the content of the mutable element.
+ */
type Mutable.t('a) = {get: -> 'a; set: 'a -> void}
+
+/**
+ * {1 About this module}
+ *
+ * It provides a way to have a mutable state.
+ *
+ * e.g.
+ *
+ * state = Mutable.create("initial state content")
+ * println(state.get())
+ * state.set("new state content")
+ *
+ */
Mutable =
{{
make(init:'a): Mutable.t('a) =
@@ -40,10 +52,7 @@ Mutable =
}}
-/**
- * {1 Interface}
- */
-
@opacapi
Mutable_make = Mutable.make
+
@opacapi Mutable_set(mutable,v) : Mutable.t('a) = mutable.set(v)
View
@@ -1,5 +1,5 @@
/*
- Copyright © 2011 MLstate
+ Copyright © 2011, 2012 MLstate
This file is part of OPA.
@@ -16,24 +16,20 @@
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*/
-/**
- * {1 About this module}
- *
- * {1 Where should I start ?}
- *
- * {1 What if I need more?}
- */
-
/**
* {1 Types defined in this module}
+ * CAUTION : Being a memory location, this type cannot exchanged between client and server.
+ * Consider using a Mutable.t of the Mutable module instead.
*/
-
type reference('a) = external
/**
- * {1 Interface}
+ * {1 About this module}
+ *
+ * It provides a way to have a mutable state.
+ *
+ * But please consider using module Mutable instead or at least read the description of the type reference.
*/
-
Reference =
{{
create = %% BslReference.create %% : 'a -> reference('a)

0 comments on commit 3bb1e06

Please sign in to comment.