Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Interface with implied Constructor Date: Wed, 24 Jul 2013 17:42:11 -0400 Organization: A noiseless patient Spider Lines: 46 Message-ID: References: <925adeb1-65b5-4a50-86a8-4f04784f8da0@googlegroups.com> <1KhGt.130731$7o1.74691@fx17.iad> <852ru8909m1p1eqcnhpotjpbmv1dd5hmui@4ax.com> <230720131443488398%jimsgibson@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 24 Jul 2013 21:36:03 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="8303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4qf4f8VNVQXz3Qa8yudUe" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: Cancel-Lock: sha1:Q8RMR9kmiDN4W7YNs6d2iXf/7MQ= Xref: csiph.com comp.lang.java.programmer:24822 On 7/24/2013 5:18 PM, Martin Gregorie wrote: > On Wed, 24 Jul 2013 13:27:57 -0700, Gene Wirchenko wrote: > >> On Tue, 23 Jul 2013 14:43:48 -0700, Jim Gibson >> wrote: >>> Classes can implement more than one interface. What should the compiler >>> demand in the case of multiple, mutually-exclusive constructor >>> requirements? >> >> If they are really mutually exclusive, then that is an error. >> > I suspect he meant "mutually disjoint", i.e. have no arguments in common, > which is a distinct possibility. To me that sounds like a good argument > for excluding constructors from interface definitions. "Ayeh." It would be even more confusing, I think, if two interfaces specified constructors with identical signatures but different intent: interface Flexible { Flexible(double stiffness); // constructor spec. ... methods ... } interface Edible { Edible(double caloriesPerGram); // constructor ... methods ... } class LicoriceStick implements Flexible, Edible { // Constructor mandated by both interfaces: LicoriceStick(double whatAttributeDoesThisGovern) { > In any case, you can always lock down the whole interface by declaring > an abstract class that implements the methods in the interface(s) as > abstract methods and declares concrete constructor(s). That still doesn't mandate any particular form of constructor for concrete subclasses. It does, however, require that each subclass constructor have enough information available to use in an invocation of one of the abstract class' constructors, so a certain amount of influence is present. -- Eric Sosman esosman@comcast-dot-net.invalid