digitalmars.D.bugs - [Issue 5217] New: Permit static+abstract
- d-bugmail puremagic.com (30/30) Nov 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
- d-bugmail puremagic.com (22/22) Nov 14 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
- d-bugmail puremagic.com (10/10) Nov 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
- d-bugmail puremagic.com (6/6) Nov 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
- d-bugmail puremagic.com (9/9) Nov 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
- d-bugmail puremagic.com (16/16) Nov 16 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5217
http://d.puremagic.com/issues/show_bug.cgi?id=5217 Summary: Permit static+abstract Product: D Version: D2 Platform: All OS/Version: Windows Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: ah08010-d yahoo.com PST --- The abstract keyword currently cannot be used with "non virtual" functions. IMO, this is an error. Non-virtual simply means that only one layer of implementation will be possible - since a vtable would be required to disambiguate multiple layers. It does not mean that the implementation is automatically obvious, nor does it mean that multiple layers of interfaces cannot be composed into the single layer of implementation. Factory methods, for example, are usually static. And in the presence of templates, the expectation should be for a high degree of fan-out, but not much depth. (That is, a template can be realized with many type parameters, but is less likely to be stacked up in a deep inheritance tree, although it does happen.) Thus, I would very much like to be able to require a static method, via the abstract keyword. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5217 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jmdavisProg gmx.com PST --- I'm afraid that you're going to have to be more clear in what you mean. abstract indicates that a function does not have a body and that derived types must give an implementation if they are to be instantiatable. static functions have nothing to do with the virtual table, and so they don't care about base or derived types. They're essentially just namespaced within a class or struct. abstract has no meaning for them. Templates _always_ result in code. What does it matter if that code is a static function, within a class, a struct, or whatever? An abstract template makes no sense. Even if you're instantiating a template within a base class, it must be fully instantiated within that class regardless of whether any classes will ever be derived from that class. What are you trying to do here? You need to be clearer, because as it stands, what you're asking for makes no sense. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5217 PST --- What I'm asking for is "abstract static". That is, a syntax for imposing a requirement that a class (or struct) provide a static member function before it can be instantiated. In my particular use case, I've got a template and would like to impose a requirement for a factory method on any realizations of the template. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5217 PST --- Do template constraints not work for you in this case? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5217 PST --- Template constraints do not work. The problem is not "The input type must behave in such-and-such manner," but rather "Here is a template for most, but not all, of the class: you must provide two static methods that I have marked as abstract." -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5217 PST --- Hmm. I think that I get what you're getting at, though it is a bit odd. Certainly, requiring static functions is something different. I've never seen a language do that. I'd still think that you could do it with a static if or template constraint, but without seeing the code, I'm not sure that it's clear enough exactly what you're trying to for me to give any kind of real suggestion about how to g about it with D as it is. In general, I don't think that I support the idea of enforcing that a type have a particular set of static functions, but it does seem like a perfectly legitimate enhancement request. I'm inclined to think that you should probably be doing things a different way. But I'm not familiar with your code, so I obviously can't say for sure. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2010