looking at the code for this lab
http://jsoftware.com/jwiki/JWebServer/EventHandler
there is a line like:
('in',":server)=: 'httpAccept ',":server
which I understand builds into something like:
in0 =: 'httpAccept 0'
which will later be fed to ". (do) to run, and seems fairly clever. Its not
very OOPy in that there is a fair bit of name cleaning up needed, but its still
mostly OOPy in that it provides "independent global" variables associated with
instances.
What is weird about the approach is that it was probably clever enough to
explicity rejected the following approach:
of =: 4 : 'x ,''_'',(> y),''_'''("1 0)
'field' of < '2' NB. Object instances are boxed string of a number afaik
(why string?)
field_2_
'method' of <"0 '012'
method_0_
method_1_
method_2_
The latter case seems suited to what you find in most other OOP paradigm
languages: Storing instances in lists,
and selecting and filtered applying functions to some of them.
While its possible to build execution strings on top of this approach,
including helper methods to make it look pretty, it will be very "interprety".
What I think "we'd" want is something that supports syntax (for selecting
objects where field__object > 0) like
(] #~ 0: < 'field'&magic) instance_list NB. not sure if works.
magic =: 4 : '(x of y)"_' NB. add & apply if you wanted to store verbs.
Is all of this a bad idea? Worth avoiding objects whenever possible including
the "hack" at the top of this post that creates and destroys top level verbs?
Are there other approaches that make managing lists of objects easy/possible?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm