Hello, I have been experimenting with locales and OO programming.
I want to, at runtime, a) create a class (can be done by creating a locale) b) create a base class for the created class working at the instance level. c) have access to instances that belong to a certain class. (a) works fine with the creation of boxed locales and inserting the create & destroy verbs (See mail chain following [1]). However, when I view the contents of the locale created dynamically using the view utility verb in Learning J [2], I am not able to see the verbs I created in the locale. Why is that so? (b) would mean that I should be able to simulate the verb coinsert at runtime effectively changing the type hierarchy. In J, I assumed that would mean inserting a new locale in the the locale path. (note that at this point, I am not looking at factoring the methods but more at the level of fields) I used the dyad copath to change the path of the locale. But I am not seeing the effect at the instance level. So, even if I successfully create a base class, I am not able to "link" it correctly in the inheritance hierarchy in a way that reflects immediately in the copath of the instance. Also, further assignments should search the new path before creating new fields in the most derived class/object. In a previous post [3] Raul commented as follows: "J allows the class of an object to be changed at run-time (though you have to have a deep understanding of J to pull this off, and I've not seen it used)." Well, this is not changing the class but rather refactoring it at runtime. (c) should be possible as I believe the J runtime keeps track of this. Clearly I could also maintain this information (by overwriting the conew verb) but I wanted to reuse what the system has as long as there is access to that information. Regards, Yuva [1] http://www.jsoftware.com/pipermail/programming/2006-December/004423.html [2] To view the internals of a locale/class VIEW_z_ =: 3 : '(> ,. ('' =: ''&,)@:(5!:5)"0) nl ''''' view_z_ =: 3 : 'VIEW__lo '''' [ lo =. < y' [3] http://www.jsoftware.com/pipermail/programming/2006-December/004424.html ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
