Plug.st
changeset 162 cbbd2f3422a3
parent 137 449db28201ec
child 224 fe3164373601
--- a/Plug.st	Sun Feb 04 22:03:27 1996 +0100
+++ b/Plug.st	Sat Feb 10 14:11:10 1996 +0100
@@ -11,10 +11,10 @@
 "
 
 Model subclass:#Plug
-	 instanceVariableNames:'simulatedProtocol'
-	 classVariableNames:''
-	 poolDictionaries:''
-	 category:'Kernel-Objects'
+	instanceVariableNames:'simulatedProtocol'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Kernel-Objects'
 !
 
 !Plug class methodsFor:'documentation'!
@@ -38,8 +38,6 @@
     A Plug is an objcet which simulates a protocol and evaluates
     a corresponding block when receiving messages.
     Its main use is for the demo doIts, to play the role of a model.
-    Plugs are not used in the system and exist as a demo only.
-    This class may be changed/removed/replaced without notice.
 "
 !
 
@@ -53,6 +51,30 @@
 
     plug foo.
     plug foo:'some argument'
+
+
+  simulating ``instance variables'':
+  (actually, this is somewhat expensive - the contexts locals are used for them ...)
+  be careful with unintended variable sharing (if plugs are created in a loop ..)
+
+    |plug1 plug2 local1 local2|
+
+    plug1 := Plug new.
+    plug1 respondTo:#get  with:[local1].
+    plug1 respondTo:#set: with:[:arg | local1 := arg].
+
+    plug2 := Plug new.
+    plug2 respondTo:#get  with:[local2].
+    plug2 respondTo:#set: with:[:arg | local2 := arg].
+
+    Transcript show:'plug1''s value: '; showCr:plug1 get.
+    Transcript show:'plug2''s value: '; showCr:plug2 get.
+
+    plug1 set:5.
+    plug2 set:17.
+
+    Transcript show:'plug1''s value: '; showCr:plug1 get.
+    Transcript show:'plug2''s value: '; showCr:plug2 get.
 "
 ! !
 
@@ -99,5 +121,5 @@
 !Plug class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Plug.st,v 1.7 1995-12-07 21:25:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Plug.st,v 1.8 1996-02-10 13:11:10 cg Exp $'
 ! !