Friday, March 11, 2011

ideal programming language thoughts

I think things like strong and weak references have to be brought into the programming language.

so in the definition
class Telephone 

  public: 
       
      Number phoneNumberDigit ; // normal 
      String weak name ;
      String  lazy phoneNumber ; // regenerable 
 } 


So when you assign elements you have

  thing.phoneNumberDigit = new Number( 230033) ; // normal 
 name <- "bob" ; // weak reference and don't forget it. 
 phoneNumber <- thing.phoneNumber.toString();// we can regenerate on demand 

   when you accesses them you get the same kind of thing.
  
    this->name.something(); 
   if( this->phoneNumber != null )  this->phoneNumber.something() ; // forced by compiler

naturally you would put the access to a lazy value in an accessor to make sure it was there when
you needed it.

Basically weak things say - if everyone else has stopped looking at this then its OK to loose the object. I don't own this I just know about it.
Lazy objects say - hay if your short of space its OK to loose this reference too I will check each time I need it.  Good for compact low memory environments.
  

No comments: