Yuvaraj Athur Raghuvir wrote: ... > Now an example... (caution - more a thought experiment...my J syntax might > be wrong....please bear with me) > > coclass 'customer' > customer__setname NB. setname is a verb in customer > customer__getname NB. getname is a verb in customer > ... > > coclass 'product' > product__getid NB. getid is a verb in product > product__getprice NB. getprice is a verb in product > > Now, I want: > > order =: customer *buys* product NB. implicit/tacit definition of new > object as an interaction between two objects > > The operator "buys" should be able to define how the new object order is in > terms of nouns & verbs that is inferred from customer & product. ...
It is important to see J objects in the context of the rest of the language. For example, in Smalltalk, a number is an object, so adding up a list of numbers is an iteration over a list of objects. In J, we would not do such a thing because it is more natural to use an array of numbers and add up the array. Similarly, we would not have a "prices" object and a "sales" object and derive an "income" object as prices * sales. Nor your example above - all these can be done with arrays. J provides no explicit support for iteration over objects (or an "algebra based on objects"), but in practice, what you might want to do is easily achieved. For example, suppose you have 3 plots, p0, p1 and p2. Then p=.p0,p1,p2 is a list of 3 plot objects. What kind of operation might be needed on p? You don't want to add it up, or get the maximum, or reshape it into a 2-d array. So the typical array-type operations are meaningless. However, you might want to apply a graphics verb to each plot. Suppose that f is a verb that flips a plot horizontally. Then the following expression will apply this verb to each object in p: f"0 p Again, I think the lab Object Oriented Programming should give you a good picture of this. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
