--- "Miller, Raul D" <[EMAIL PROTECTED]> wrote:
> At least part of this would go away if
> coextend=: coinsert
Here is a proto of COCLASSPATH-less, coextend-less OOP.
coinsert and other co's still exist and used.
NB. =============================================[newshapes.ijs]===
class_z_=: 3 : 0
cocurrent f. <,> y
:
class y
coinsert x
cocurrent f. <,> y
)
new_z_=: 3 : 0
z=. cocreate''
((,y);copath <y) copath z
COCREATOR__z=: coname''
z
:
z=. new y
create__z x
z
)
nv_z_=: (> , '=: ' , (5!:5))"[EMAIL PROTECTED]
coerase ;:'prect ppoint pshape'
NB. =========================================================
class 'pshape'
TYPE=: 'SHAPE'
create=: 3 : 0
NAME=: y
)
destroy=: codestroy
NB. =========================================================
'pshape' class 'ppoint'
TYPE=: 'POINT'
create=: 3 : 0
create_pshape_ f. 0{::y
'X Y'=: 1{::y
)
sub=: 3 : 0
'ppoint'new~'';(X-X__y),(Y-Y__y)
)
norm=: 3 : 'X +&.*: Y'
NB. =========================================================
'pshape j' class 'prect'
TYPE=: 'RECT'
create=: 3 : 0
create_pshape_ f. 0{::y
p1=: 'ppoint'new~'p1';1{::y
p2=: 'ppoint'new~'p2';2{::y
)
destroy=: 3 : 0
codestroy_pshape_ f. ''
destroy__p1''
destroy__p2''
)
area=: 3 : 0
p=. sub__p2 p1
z=. norm__p ''
z [ destroy__p ''
)
NB. =========================================================
cocurrent 'base'
require 'coutil'
0!:101 (0 : 0)
sA=: 'A' new 'pshape'
pB=: ('B';10 20) new 'ppoint'
rC=: ('C';10 20;13 24) new 'prect'
TYPE__sA
copath sA
nv__sA''
TYPE__rC
copath rC
nv__rC''
nv__p1__rC''
area__rC''
PATHSEP__rC
costate''
destroy__sA''
destroy__pB''
destroy__rC''
costate''
)
NB. ==============================================[run]======
load 'd:\path\j601\user\newshapes.ijs'
sA=: 'A' new 'pshape'
pB=: ('B';10 20) new 'ppoint'
rC=: ('C';10 20;13 24) new 'prect'
TYPE__sA
SHAPE
copath sA
+------+-+
|pshape|z|
+------+-+
nv__sA''
COCREATOR=: <'base'
NAME=: 'A'
TYPE__rC
RECT
copath rC
+-----+------+-+-+
|prect|pshape|j|z|
+-----+------+-+-+
nv__rC''
COCREATOR=: <'base'
NAME=: 'C'
p1=: <'12'
p2=: <'13'
nv__p1__rC''
COCREATOR=: <'11'
NAME=: 'p1'
X=: 10
Y=: 20
area__rC''
5
PATHSEP__rC
\
costate''
+----+--+-------+----------------+
|refs|id|creator|path |
+----+--+-------+----------------+
| |0 |jijs |jijs j z |
+----+--+-------+----------------+
| |2 |jijs |jijs j z |
+----+--+-------+----------------+
|sA |9 |base |pshape z |
+----+--+-------+----------------+
|pB |10|base |ppoint pshape z |
+----+--+-------+----------------+
|rC |11|base |prect pshape j z|
+----+--+-------+----------------+
| |12|11 |ppoint pshape z |
+----+--+-------+----------------+
| |13|11 |ppoint pshape z |
+----+--+-------+----------------+
destroy__sA''
1
destroy__pB''
1
destroy__rC''
1
costate''
+----+--+-------+--------+
|refs|id|creator|path |
+----+--+-------+--------+
| |0 |jijs |jijs j z|
+----+--+-------+--------+
| |2 |jijs |jijs j z|
+----+--+-------+--------+
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm