Email list hosting service & mailing list manager

Re: Problems with field initialization: Proposal Andre van Tonder (16 Sep 2005 18:17 UTC)
Re: Problems with field initialization: Proposal Michael Sperber (20 Sep 2005 10:05 UTC)

Re: Problems with field initialization: Proposal Andre van Tonder 16 Sep 2005 18:17 UTC

 > > 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 -------------