This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: How to define constructors for classes defined using define-simple-class
- From: S D <s dot mailinglists at gmail dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Tue, 5 Apr 2005 00:23:02 -0700
- Subject: Re: How to define constructors for classes defined using define-simple-class
- References: <301e20f60503272330482cff2c@mail.gmail.com> <4247B59C.7070003@bothner.com> <301e20f605033015403c775034@mail.gmail.com> <424B3D0C.1070901@bothner.com> <301e20f605040423592c6817bc@mail.gmail.com>
- Reply-to: S D <s dot mailinglists at gmail dot com>
Actually, this doesn't seem to do with overloading. This seems to
happen to any method body calling another method of the class. If I
replace the (test (this) a a) with either the invoke or the
class:method notation, it compiles fine. This could be related to the
"The scope of the body of a method includes the field-decls of the
object. It does include the surrounding lexical scope. It sort-of also
includes the declared methods, but this is not working yet."
in the documentation?
On Apr 4, 2005 11:59 PM, S D <s.mailinglists@gmail.com> wrote:
> The following code
>
> (define-simple-class overloading-test ()
> ((test a :: <int>) :: <int>
> (test (this) a a))
> ((test a :: <int>
> b :: <int>) :: <int>
> (+ a b)))
>
> gives me
>
> class1.scm:4:2: call to 'test' has too many arguments (3; must be 2)
>
> If I interchange the two test methods,
>
> class1.scm:7:2: call to 'test' has too many arguments (3; must be 1)
>
>
> On Mar 30, 2005 4:58 PM, Per Bothner <per@bothner.com> wrote:
> > S D wrote:
> > > Will this be addressed in the future?
> >
> > I expect so.
> >
> > > Or is there any technical
> > > limitation in generating constructor byte code?
> >
> > It's partly a design issue. Any design will be a bit of a kludge:
> > what's a "constructor"? It's a special kind of beat: neither a
> > normal instance method nor a static method. I think having constructors
> > in a language is a mistake - one should use factory methods instead.
> >
> > What I think we'll do is define "constructors" as if they were methods
> > with a special name - perhaps "new", and a few special rules.
> >
> > Support for calling a super-constrcutor can be based on the existing
> > invoke-special.
> >
> > > Also, it doesn't seem
> > > to be possible to overload a method with different sets of parameters
> > > (I think the last definition definition is the one that is being
> > > created).
> >
> > That seems to work for me. If it doesn't work for you, submit a test
> > case - but please try the cvs verson of kawa first.
> > --
> > --Per Bothner
> > per@bothner.com http://per.bothner.com/
> >
>