Showing posts with label package. Show all posts
Showing posts with label package. Show all posts

2012-11-08

obj'c categories and Ada's hierarchical pkg

8.14: adda/oop/obj'c categories and ada hierarchical libs:
reviewing:
2012-01-31 Objective-C Categories
1.20: adda/type/obj'c categories:
. Apple is using the obj'c Category for MVC separation;*
eg, string has many uses in a command-line interface,
so it exists in the core package without any methods for
drawing on a gui;
categories are then simply extending that string type,
instead of having sublclasses reuse that string type
in yet another type;
so just one type can exist
yet with  relevant parts in different packages .
* see { Buck, Yacktman}`Cocoa Design Patterns

todo:
. isn't that use of categories needed only because
the designers were assuming certain requirements
that are demanded only by the current oop model?

. if your string wants to express gui-specific tricks
such as appearing in a particular font,
or being arranged so as to follow a curve,
that need should be served by the use of a drawing record
which then has a string as one of it's parts .
(ie, it's ok to have 2 different classes !)
--
. a main point of the book"design patterns

was to critique oop's use of subclassing;
and, that criticism might apply equally well
to this use of categories;
but, generally, categories do have a good purpose:
they allow separate compilation of class extensions
without having to recompile the original interface
which might then require a recompile of
all the clients of that interface .

. this reminds of Ada's hierarchical libraries,
in Ada you can reuse oldlib's module
with the syntax:
package oldlib.additionalmethods
(by including oldlib's name like that
within your new package's name,
your new package includes the binaries of oldlib ).
. now current clients of oldlib
still don't have additional methods,
but, future clients of oldlib.additionalmethods
will have access to both modules
with that one import .
. obj'c categories by contrast,
allow you to add the same new modules
but this addition will also be affecting
current clients!
-- the category's method has access only to
the target's interface, not its internals;
so, a category can't fix every bug;
yet it can create bugs because it can
override system methods .

. I have 2 competing ideas on this:
# we should be able to describe in adda
any idea of any other language;
vs,
# we should not be supporting the use of ideas
that are either complicating or insecure .

here's how the the Category idea might be impl'd:
. when a datataype agrees to be modified by categories;
then at run-time, the type mgt is a modifiable object
and, it provides a dictionary
where you can see if it supports a message .
. it can dynamically add entries to this dictionary
(allowing it to support new messages),
and it can change method addresses
(allowing it to update the methods of old messages).
[10.8:
. now all we need is an uncomplicated way to
decide which types are so modifiable .
. perhaps a type wishing to participate
could declare one of its components to be
a dictionary with a standard name
(perhaps SEL, in honor of Obj'C);
then anytime a message is unrecognized,
the run-time would check SEL for the method .
11.8: correction:
. in order to work like an obj'c category,
it has to check SEL all the time,
not just when a message is unrecognized,
in case one of its methods got overridden .]

2012-03-31

packages compared to types

3.23: adda/type/packages compared to types:

. when were child packages needed by ada?
when you want to extend an existing package .
. the point is to reuse the parent package's object
without having to recompile .
. the child's object has links to the parent's object .
. parent package can be compared to supertypes;
they can use the same is.section syntax
to express the {super, parent} relation .

. adda records are not quite like ada packages,
so let us use the terms {record vars, record types};
record types allow you to include vars and subrograms
into an activation record;
each inclusion creates new instances of the vars .
. a record var at top level may be shared by
2 or more concurrently running subprograms .
. safely sharing a var requires the use of
a task's command queuing system .

. it seems possible to merge records and tasks;
ie, they don't need to differ in syntax;
every subprogram can be viewed as an entry;
and the default method for handling entry queues
is to select the queue with the longest line .
. if the compiler sees that vars aren't shared,
(ie, there is no sharing a top-level record instance,
then the optimizer can replace the queue with a direct call ).

2010-02-28

obj'c`categories vs ada`child pkg's

2.14: adda/cstr/obj'c`categories vs ada`child pkg's:
. obj'c`categories like ada`child pkg's ?
categories are more modifiable:
you can override old def's
even without a recompile of old clients,
because classes are linked at run time, not compile time .
. pkg's are hardwired
but the compiler keeps a record of how
compilation units are org'd,
and this record can be modified,
so a parent pkg body
stays uncompiled and un-overridden
while a parent pkg head
can have child pkg's appended to it .