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: Mon, 4 Apr 2005 23:59:26 -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>
- Reply-to: S D <s dot mailinglists at gmail dot com>
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/
>