4.24: adda/oop/delegates/delegates in obj'c:
. in the model-view-controller pattern
the model is acting as a server .
. some servers expect you to
provide as input for their startup
an object that serves as your delegate,
the delegate class provided by the client
conforms to the interface expected by the server
and when the server has to provide
some client-specific processing
it is launching one of the client's delegate's methods .
. this is just like if the server
expected the client to input
a set of pointers to subprograms
but by supplying an object instead,
the included set of subprograms can share some variables
whose state persists between subprogram calls
(instance vars of the obj).
Showing posts with label obj'c. Show all posts
Showing posts with label obj'c. Show all posts
2014-12-20
2014-12-17
concurrency ideas inspired by obj'c
4.13: adda/oop/co/concurrency ideas inspired by obj'c:
. obj'c has a callback pattern
where a service provider is customizable
by expecting the clients to provide certain functions
that the service provider will call at special times .
. obj'c's callbacks will have a param indicating
which object is the service provider doing the callback
-- apple calls that the msg sender --
but that is generalizable as the caller:
each call is part of a call stack,
and we don't need to include the caller in the parameter
because the system can provide that as stack(-1),
eg, the adda language could reserve the term:
self`caller
( however, notice in pure oop, callers are
always obj's, not subprograms .
when a service provider is calling you back,
you don't want to know which of its subprogram's called you back;
you want a way to refer back to the service provider .
. the key to sorting this out is noticing
when there is cross-module communications .
. are all objects to be treated as separate processes?
)
. is there a distinction between caller and msg sender?
are objects async'ly called ? generally not,
since the call's parameters could be
references to caller's internals;
so, the caller is going to want to
wait for the call to finish .
. even if the callee is not writing to a shared object
the caller has to avoid writing until callee is done,
or it has to be a dynamically updateable type
(2 threads must agree to release as often as possible).
. if not waiting for callee to return,
there must be a lock on the refs target,
when callee is done handling the msg
the system has to notice if any params are pointers
and unlock the targets when the call is done;
ie,
the caller usually knows when a call is done,
because it wouldn't be runnable
unless all its callees had returned;
so, during an async call, the caller is still running
until it bumps into a locked resource,
and when the async callee returns,
the system must provide a notification,
and upon notification the caller can unlock the resources
that it had let that callee borrow,
or the system's notification could consist of
auto'ly unlocking what was shared with the callee .
. unlocking means decrementing an [in use by a callee].counter,
since with async calling concurrently,
there could be multiple readers locking out writers .
... may want to review
what's already been written about this;
but generally,
it would be nice to have a way for the caller
to know when an async callee is done
the async syntax could be
has-returned.flag`= async y`= f(x) .
. obj'c has a callback pattern
where a service provider is customizable
by expecting the clients to provide certain functions
that the service provider will call at special times .
. obj'c's callbacks will have a param indicating
which object is the service provider doing the callback
-- apple calls that the msg sender --
but that is generalizable as the caller:
each call is part of a call stack,
and we don't need to include the caller in the parameter
because the system can provide that as stack(-1),
eg, the adda language could reserve the term:
self`caller
( however, notice in pure oop, callers are
always obj's, not subprograms .
when a service provider is calling you back,
you don't want to know which of its subprogram's called you back;
you want a way to refer back to the service provider .
. the key to sorting this out is noticing
when there is cross-module communications .
. are all objects to be treated as separate processes?
)
. is there a distinction between caller and msg sender?
are objects async'ly called ? generally not,
since the call's parameters could be
references to caller's internals;
so, the caller is going to want to
wait for the call to finish .
. even if the callee is not writing to a shared object
the caller has to avoid writing until callee is done,
or it has to be a dynamically updateable type
(2 threads must agree to release as often as possible).
. if not waiting for callee to return,
there must be a lock on the refs target,
when callee is done handling the msg
the system has to notice if any params are pointers
and unlock the targets when the call is done;
ie,
the caller usually knows when a call is done,
because it wouldn't be runnable
unless all its callees had returned;
so, during an async call, the caller is still running
until it bumps into a locked resource,
and when the async callee returns,
the system must provide a notification,
and upon notification the caller can unlock the resources
that it had let that callee borrow,
or the system's notification could consist of
auto'ly unlocking what was shared with the callee .
. unlocking means decrementing an [in use by a callee].counter,
since with async calling concurrently,
there could be multiple readers locking out writers .
... may want to review
what's already been written about this;
but generally,
it would be nice to have a way for the caller
to know when an async callee is done
the async syntax could be
has-returned.flag`= async y`= f(x) .
Labels:
adda,
concurrency,
obj'c,
oop
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 .]
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 .]
Labels:
ada,
adda,
Category,
dyna'linking,
frameworks,
library,
obj'c,
oop,
package,
type
2011-07-30
including obj'c features
7.23: adda/oop/including obj'c features:
. in the expression"( a`b(x)`c ),
the ( a`b(x) ) means
the object"a has a procedure b(x)
that returns an object location
whose available functions include c .
. the syntax"(a`b) is not necessarily
involving self-modification;
it simply means subprogram"b has access to (a)
as an inout parameter
(the subprogram's object parameter).
. is there some efficient way of doing a`b`c
without passing pointers ?
I was thinking there was some virtual way
that doesn't really need pointers
(oop doesn't really need
all the pointers it thinks it needs)...
. if a subprogram's object param
returns a reference to something other than
the object param,
then in the c translation of same
this subprogram takes a destination param;
ie, a param that inputs a destination address
showing where the caller wants the return placed .
. why wouldn't it always take a destination param
even when returning self? ...
because the caller is already housing that obj .
7.26:
. my original concern here
was allowing the passing of references
and the use of object param's,
just like obj'c oop does,
while still using the sort of oop system
that did not generate garbage .
todo:
. I think obj'c has the convention that
even if ( a`b(x) doesn't return anything
if an object reference is expected as a return,
as is the case in "( a`b(x)`c ),
then it will use a reference to (a);
ie, ( a`b(x)`c ) would equal:
( a`b(x); a`c ) .
. in the expression"( a`b(x)`c ),
the ( a`b(x) ) means
the object"a has a procedure b(x)
that returns an object location
whose available functions include c .
. the syntax"(a`b) is not necessarily
involving self-modification;
it simply means subprogram"b has access to (a)
as an inout parameter
(the subprogram's object parameter).
. is there some efficient way of doing a`b`c
without passing pointers ?
I was thinking there was some virtual way
that doesn't really need pointers
(oop doesn't really need
all the pointers it thinks it needs)...
. if a subprogram's object param
returns a reference to something other than
the object param,
then in the c translation of same
this subprogram takes a destination param;
ie, a param that inputs a destination address
showing where the caller wants the return placed .
. why wouldn't it always take a destination param
even when returning self? ...
because the caller is already housing that obj .
7.26:
. my original concern here
was allowing the passing of references
and the use of object param's,
just like obj'c oop does,
while still using the sort of oop system
that did not generate garbage .
todo:
. I think obj'c has the convention that
even if ( a`b(x) doesn't return anything
if an object reference is expected as a return,
as is the case in "( a`b(x)`c ),
then it will use a reference to (a);
ie, ( a`b(x)`c ) would equal:
( a`b(x); a`c ) .
Labels:
adda,
dev.obj'c,
obj'c,
oop,
translation
2010-08-30
lang's for supercomputer concurrency
adda/concurrency/lang's for supercomputer concurrency
7.27:
. the DARPA`HPCS program
(High Productivity Computing Systems)
is meant to tame the costs of HPC
(High Performance Computing)
-- HPC is the use of supercomputers for
simulations to solve problems in
chemistry, physics, ecology, sociology,
and esp'ly warfare .
. programmer productivity
means making it easier to develope
code that can make full use of
a supercomputer's concurrency .
. the main source of the cost
is a lack of smart software tools
that can turn science experts
into computer coders .
. toward this end, they are funding
the design of new concurrency lang's .
7.28:
. the DoD and DARPA already made
quite an investment in the
Ada concurrency lang',
a language designed for expressing
the sort of concurrency needed by
embedded system engineers; 7.31:
but, the software developer community
spurned Ada as soon as there was
something better ...
. pascal was popular before '85,
and when Ada arrived '83,
it was popular too;
then came the Visual version
of Basic (familiar and slick).
. the top demanded langs by year were:
'85: C, lisp, Ada, basic;
'95: v.basic, c++, C, lisp, Ada;
'05: Java, C, c++, perl, php,
. the only currently popular lang's
meant for exploiting multi-core cpu's
if not other forms of concurrency, are:
(3.0% rating) obj'c 2.0 (with blocks)
(0.6% rating) Go
(0.4% rating) Ada
7.29:
. whether or not Ada's concurrency model
is well-suited for supercomputers
as well as embedded systems,
it is not increasing coder'productivity .
. while Ada boosted productivity beyond
that offered by C,
it was nevertheless proven to do
less for productivity than Haskell .
HPC Productivity 2004/Kepner{ 2003(pdf), 2004(pdf) }:
. lang's were compared for
expressiveness vs performance:
. the goal of a high-performance lang'
is to have the expressiveness
of Matlab and Python,
with the performance of VHDL
(VHDL is a version of Ada for ASICs ).
. UPC (Unified Parallel C) and Co-array Fortran
are half way to high-productivity
merely by using PGAS
(Partitioned global address space)
rather than MPI
(Message Passing Interface).
. the older tool set: C, MPI, and openMP
is both slow and difficult to use .
. the 2 lang's that DARPA is banking on now
are Cray`Chapel, and IBM`X10 Java .
. they were also funding Sun`Fortress
until 2006,
which features a syntax like advanced math
-- the sort of greek that physics experts
are expected to appreciate .
7.27:
. the DARPA`HPCS program
(High Productivity Computing Systems)
is meant to tame the costs of HPC
(High Performance Computing)
-- HPC is the use of supercomputers for
simulations to solve problems in
chemistry, physics, ecology, sociology,
and esp'ly warfare .
. programmer productivity
means making it easier to develope
code that can make full use of
a supercomputer's concurrency .
. the main source of the cost
is a lack of smart software tools
that can turn science experts
into computer coders .
. toward this end, they are funding
the design of new concurrency lang's .
7.28:
. the DoD and DARPA already made
quite an investment in the
Ada concurrency lang',
a language designed for expressing
the sort of concurrency needed by
embedded system engineers; 7.31:
but, the software developer community
spurned Ada as soon as there was
something better ...
. pascal was popular before '85,
and when Ada arrived '83,
it was popular too;
then came the Visual version
of Basic (familiar and slick).
. the top demanded langs by year were:
'85: C, lisp, Ada, basic;
'95: v.basic, c++, C, lisp, Ada;
'05: Java, C, c++, perl, php,
. the only currently popular lang's
meant for exploiting multi-core cpu's
if not other forms of concurrency, are:
(3.0% rating) obj'c 2.0 (with blocks)
(0.6% rating) Go
(0.4% rating) Ada
7.29:
. whether or not Ada's concurrency model
is well-suited for supercomputers
as well as embedded systems,
it is not increasing coder'productivity .
. while Ada boosted productivity beyond
that offered by C,
it was nevertheless proven to do
less for productivity than Haskell .
HPC Productivity 2004/Kepner{ 2003(pdf), 2004(pdf) }:
. lang's were compared for
expressiveness vs performance:
. the goal of a high-performance lang'
is to have the expressiveness
of Matlab and Python,
with the performance of VHDL
(VHDL is a version of Ada for ASICs ).
. UPC (Unified Parallel C) and Co-array Fortran
are half way to high-productivity
merely by using PGAS
(Partitioned global address space)
rather than MPI
(Message Passing Interface).
. the older tool set: C, MPI, and openMP
is both slow and difficult to use .
. the 2 lang's that DARPA is banking on now
are Cray`Chapel, and IBM`X10 Java .
. they were also funding Sun`Fortress
until 2006,
which features a syntax like advanced math
-- the sort of greek that physics experts
are expected to appreciate .
2009-12-28
unicode.org misunderstands the apply character
9.16: unicode.org misunderstands the apply character:
"(
. U+2061 function application is used for an implied function dependence,as in f(x + y).To indicate that this is the function f of the quantity x + yand not the expression fx + fy,one can insert the nondisplaying function application symbolbetween the f and the left parenthesis.
) [@] chapt15`page#508 .
. unicode has an implied (invisible)
apply operator f(x) => f[apply](x)
unicode.org's description doesn't quite get that:
they thought it was for noting f(x+y) meant that rather than fx+fy
but in that example, the paren's do that!
the point is that in any situ' where it's not clear that f is a function,
the apply character lets the editor know
that the terms {f, arg} should be kept together
so that the arg is not wrapped on the next line,
or that the parenthetical belongs to the previous name,
not the previous phrase .
2009-12-27
an obj'c 3.0
8.10: co.net/linkedin.com/obj'c/Objective-C 3.0 in the works?:
Does anyone know if there is an Objective-C 3.0 in the works?
I appreciate any info. Thanks so much.
Started by Jennifer Blaney, Editorial at Charles River Media/Course PTR- Cengage Learning
web.addn/dev.obj'c/3.0 in the pipes?,
. here was a thread interested in an obj'c 3.0:
. Nu is a version of obj'c reverting to simple lisp-like syntax .
"(
Nu is implemented in Objective-Cand is designed to take full advantange of the Objective-C runtime.Nu code can fully interoperate with code written in Objective-C;
)
. the language I'm designing, adda,
will include objective-c's semantics
but will be simpler, without hanging onto c or smalltalk syntax .
10.19: pos.adda/plain old c -centric:
. if thinking how to master obj'c,
keep in mind that it's better to stay in c when possible,
pos:
. adda wants to be for c
what qt is for c++ .
10.19: adda/dynamic without vm:
. with the libffi
-- a portable foreign function interface library --
. it could be possible to minimize dependency on addm
by providing either a calculator;
or, for thick code,
do a compilation with ada-class safety checks
and then call out to what the system just compiled .
10.23: pos.adda/plain old C:
. of course you should you minimize the use of obj'c,
(because there will be other platforms)
but esp'ly minimize the use of apple-obj'c blocks
to just places in obj'c where they are required:
in the new grand central system for threading .
(blocks are complicated)
...
. it's not easy dev'ing for older versions of mac .
Labels:
adda,
obj'c,
translation
2009-10-15
booking obj'c
[10.15:
. notes from reading to learn to obj'c .
. the adda compiler is actually translating the adda language to
the preferred language of the intended platform .
. my first such platform will be mac's objective-c with cocoa libraries .]
. notes from reading to learn to obj'c .
. the adda compiler is actually translating the adda language to
the preferred language of the intended platform .
. my first such platform will be mac's objective-c with cocoa libraries .]
7.12: biblio:
11.1: Programming in Objective-C 2.0 -- links
11.1: Cocoa Recipes old downloads:
11.2: Cocoa Recipes current downloads:
-- can only be opened in older versions of Xcode.
Subscribe to:
Posts (Atom)