Re: abstract static?
Without wanting to harp on about C++ templates, they do do the job, but
clearly they do have the drawback that there is not an explicit listing of
what is required from a class, it's implicit from the various things that
you ask the class to do.
This does mean, however, that the specification of requirements is bound
inextricably with its usage. This gives us a couple of advantages:
1) The specification can't go 'over-the-top' asking for requirements that
are never used and therefore wasting implementer's time and causing code
bloat. The C++ template mechanism is very good at not forming instantiations
that can never be called.
2) There is no risk that (as there would be with specification plus
reflection) that at runtime a requirement will be discovered that was
missing from the specification.
Templates give a full list of non-compliance at compile-time. The problem is
that this list is unclear and scattered about the full error list. It might
be useful to develop a tool which strips out all those non-compliances from
the error list and presents a summary of why a class fails to comply. (Some
C++ compilers may already do this.)
Regards,
Jasper Kent.
"Daniel O'Connell" <onyxkirx@comca st.net> wrote in message
news:N_66b.3679 30$Ho3.53743@sc crnsc03...[color=blue]
> Since I'm still researching alot of what I was babbling about, do you know
> of any languages that support the level of a contract that requires
> specification of constructors and the like? I've yet to find one that
> explicit.
> I'm still playing with some random syntaxes to simplify(or remove the need
> for) reflection in many cases and allow a specification of a number of
> things an object needs to be aware of...not that it'll ever get[/color]
implemented,[color=blue]
> but I find it an interesting research project
> "Jasper Kent" <jasper_kent@ho tmail.com> wrote in message
> news:eZkJNP9cDH A.3992@TK2MSFTN GP11.phx.gbl...[color=green]
> > It's not just that static methods can't be abstract, they can't be[/color][/color]
virtual[color=blue][color=green]
> > (which all abstract methods, by definition, are).
> >
> > The reason is simple.
> >
> > A virtual method is one whose implementation is selected on the basis of[/color]
> the[color=green]
> > type of the object on which it is called. Static methods are not called[/color][/color]
on[color=blue][color=green]
> > an object, therefore that sort of determination cannot be made.
> >
> > What you may be after is what might be called a 'contract' rather than[/color][/color]
an[color=blue][color=green]
> > interface. This isn't available in C#. There's quite a lot of discussion[/color]
> on[color=green]
> > that in another thread, under the title of 'Re: C# language feature
> > proposal' on this newsgroup, dated 1/9/03.
> >
> > Regards,
> >
> > Jasper Kent.
> >
> >
> >
> >
> > "Chris Capel" <chris@ibanktec h.comnet> wrote in message
> > news:%23h4xIX8c DHA.3708@tk2msf tngp13.phx.gbl. ..[color=darkred]
> > > What is the rationale behind the decision not to allow abstract static[/color]
> > class[color=darkred]
> > > members? It doesn't seem like it's a logically contradictory concept,[/color][/color][/color]
or[color=blue][color=green][color=darkred]
> > > that the implementation would be difficult or near-impossible. It[/color][/color][/color]
seems[color=blue][color=green]
> > like[color=darkred]
> > > it would be useful. In fact, there's a place in my code that I could[/color][/color]
> make[color=green][color=darkred]
> > > good use of it. So why not?
> > >
> > > Chris
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]
Without wanting to harp on about C++ templates, they do do the job, but
clearly they do have the drawback that there is not an explicit listing of
what is required from a class, it's implicit from the various things that
you ask the class to do.
This does mean, however, that the specification of requirements is bound
inextricably with its usage. This gives us a couple of advantages:
1) The specification can't go 'over-the-top' asking for requirements that
are never used and therefore wasting implementer's time and causing code
bloat. The C++ template mechanism is very good at not forming instantiations
that can never be called.
2) There is no risk that (as there would be with specification plus
reflection) that at runtime a requirement will be discovered that was
missing from the specification.
Templates give a full list of non-compliance at compile-time. The problem is
that this list is unclear and scattered about the full error list. It might
be useful to develop a tool which strips out all those non-compliances from
the error list and presents a summary of why a class fails to comply. (Some
C++ compilers may already do this.)
Regards,
Jasper Kent.
"Daniel O'Connell" <onyxkirx@comca st.net> wrote in message
news:N_66b.3679 30$Ho3.53743@sc crnsc03...[color=blue]
> Since I'm still researching alot of what I was babbling about, do you know
> of any languages that support the level of a contract that requires
> specification of constructors and the like? I've yet to find one that
> explicit.
> I'm still playing with some random syntaxes to simplify(or remove the need
> for) reflection in many cases and allow a specification of a number of
> things an object needs to be aware of...not that it'll ever get[/color]
implemented,[color=blue]
> but I find it an interesting research project
> "Jasper Kent" <jasper_kent@ho tmail.com> wrote in message
> news:eZkJNP9cDH A.3992@TK2MSFTN GP11.phx.gbl...[color=green]
> > It's not just that static methods can't be abstract, they can't be[/color][/color]
virtual[color=blue][color=green]
> > (which all abstract methods, by definition, are).
> >
> > The reason is simple.
> >
> > A virtual method is one whose implementation is selected on the basis of[/color]
> the[color=green]
> > type of the object on which it is called. Static methods are not called[/color][/color]
on[color=blue][color=green]
> > an object, therefore that sort of determination cannot be made.
> >
> > What you may be after is what might be called a 'contract' rather than[/color][/color]
an[color=blue][color=green]
> > interface. This isn't available in C#. There's quite a lot of discussion[/color]
> on[color=green]
> > that in another thread, under the title of 'Re: C# language feature
> > proposal' on this newsgroup, dated 1/9/03.
> >
> > Regards,
> >
> > Jasper Kent.
> >
> >
> >
> >
> > "Chris Capel" <chris@ibanktec h.comnet> wrote in message
> > news:%23h4xIX8c DHA.3708@tk2msf tngp13.phx.gbl. ..[color=darkred]
> > > What is the rationale behind the decision not to allow abstract static[/color]
> > class[color=darkred]
> > > members? It doesn't seem like it's a logically contradictory concept,[/color][/color][/color]
or[color=blue][color=green][color=darkred]
> > > that the implementation would be difficult or near-impossible. It[/color][/color][/color]
seems[color=blue][color=green]
> > like[color=darkred]
> > > it would be useful. In fact, there's a place in my code that I could[/color][/color]
> make[color=green][color=darkred]
> > > good use of it. So why not?
> > >
> > > Chris
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]
Comment