Subject: Re: Observer-Subject
From: Vassily Litvinov (vass@cs.washington.edu)
Date: Thu Jul 27 2000 - 16:20:57 PDT
I am not familiar with the Propagator pattern, but I'll try to address the
particular problem you are describing.
Cecil does not have lazy evaluation (it is a usual eagerly-evaluated
language).  However, Cecil provides closures (or, first-class functions)
which can be used to address your example.  The solution is not implicit,
though, as the programmer must specify the freeze/thaw points as explicit
closures and evaluations.  Due to the fact that Cecil implements static
scoping (which C++ doesn't), the solution is much shorter in Cecil (I am
using "lambda" instead of the "&" in Cecil's syntax):
   a = lambda() { 1 };
   b = lambda() { 2 };
   c = lambda() { eval(a) + eval(b) };
   print(eval(c));
   a = lambda() { 3 };
   b = lambda() { 4 };
   print(eval(c));
This prints 3 and 7, as desired.
Does this answer your question?
Vassily
On Thu, 27 Jul 2000, Kelemen Csaba wrote:
> Dear Vassily,
> 
> > Could you rephrase your question?
> 
>     Okay, I was too shortly and inaccurate. I think, the Observer-Subject
> pattern is not too flexible, but important in conventional OO language. In
> my practice ( C++) , the major disadvantages are in the manualy "update" and
> "actualize" calling and transitive nature of Subject-Observer relation in
> complex object dependency graph ( see Propagator Pattern. That is a
> generalized Observer-Subject pattern.)
> Simple example with a hypothetical language:
> 
>     a = 1;
>     b = 2;
>     c = a + b;
>     print( c);
>     a = 3;
>     b = 4;
>     print( c);
> 
> where c is an observer to a and b. Let output  3 and 7. This is a very
> simple and desirable behavior, but the effective C++ implementation is not
> so simple. ( with Adaptive Propagator.)
>     As I know, Cecil's lazy evaulation is general and transparent. The
> problem in C++ with lazy evaulation and observing are similar. The tasks
> seem so simple, but the implementatation is unnatural, spreaded through many
> code lines. The effective solution is not in my hand. Both are handled by my
> dreamed language.
>     Could Cecil solve Observer-Subject ( more exactly "Adaptive Propagator")
> problem in implicit manner?
> 
> Best regards,
>     Csaba
> 
> 
> 
> Referenece:
>     Propagator - a Family of Patterns
>     Peter H. Feilers and Walter F. Tichy
> 
> 
> 
This archive was generated by hypermail 2b25 : Tue Oct 03 2000 - 15:21:46 PDT