[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with field initialization: Proposal



 > > I would like to understand this remark better.  For example, the Java 
 > > constructor paradigm seems more similar to my suggestion than the draft.
 > 
 > I would think the opposite is true:
 > 
 > (define-type foo (a b)
 >   (fields
 >     (a (foo-a) a)
 >     (b (foo-b) b)))
 > 
 > class Foo {
 >   int a;
 >   int b;
 > 
 > 
 >   Foo(int a, int b) {
 >     this.a = a;
 >     this.b = b;
 >   }
 > }
 
 Again, the comparison breaks down with examples like:
 
  class Foo {
    int a;
    int b;
    
    public int foo-a () { return a }
    public int foo-b () { return b }
  
    Foo(int a, int b) {
      int common = gcd (a, b); 
      if (b == 0)
        { this.a = 1;
          this.b = 0 }
      else 
        { this.a = a / common;
          this.b = b / common}
    }
  }
  
  which cannot currently be accomodated with the draft suggestion.  Also, 
  the Java declarations of foo-a and foo-b are not interlaced with the
  initializations.
  
  Cheers
  Andre
  

------------- End Forwarded Message -------------