www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Q 4 W: Declarative M.I, for concepts

reply "Matthew" <matthew hat.stlsoft.dot.org> writes:
Just wondered whether there's a technical reason why D could not support
multiple inheritance for the sole purpose of declaring concepts, a la C++.

I'm *NOT* talking about any implementation of any sort here, only type and
possibly member constants (which would be resolved at compile-time; no
reflection-like complexities suggested).

I'm not interested, at this stage, in whether anyone thinks it's a good or
bad idea. I just want to know whether it's possible within the current
object model of D, or whether it would be possible to add it without
disturbing anything or bringing along any of the nasty baggage from "full"
M.I.

Walter?
Feb 06 2006
next sibling parent reply "Kris" <fu bar.com> writes:
I'm not sure how far you want to take it, but is it not possible to do much 
of that (right now) via multiple interfaces?


"Matthew" <matthew hat.stlsoft.dot.org> wrote in message 
news:ds8j7h$q2i$1 digitaldaemon.com...
 Just wondered whether there's a technical reason why D could not support
 multiple inheritance for the sole purpose of declaring concepts, a la C++.

 I'm *NOT* talking about any implementation of any sort here, only type and
 possibly member constants (which would be resolved at compile-time; no
 reflection-like complexities suggested).

 I'm not interested, at this stage, in whether anyone thinks it's a good or
 bad idea. I just want to know whether it's possible within the current
 object model of D, or whether it would be possible to add it without
 disturbing anything or bringing along any of the nasty baggage from "full"
 M.I.

 Walter?

 

Feb 06 2006
parent reply "Matthew" <matthew hat.stlsoft.dot.org> writes:
Can interfaces declare member constants?

Also, don't they grow the objects footprint?

(There are not rhetorical. I've been moi D for so long I have no idea.)

"Kris" <fu bar.com> wrote in message news:ds8jjd$qel$1 digitaldaemon.com...
 I'm not sure how far you want to take it, but is it not possible to do

 of that (right now) via multiple interfaces?


 "Matthew" <matthew hat.stlsoft.dot.org> wrote in message
 news:ds8j7h$q2i$1 digitaldaemon.com...
 Just wondered whether there's a technical reason why D could not support
 multiple inheritance for the sole purpose of declaring concepts, a la


 I'm *NOT* talking about any implementation of any sort here, only type


 possibly member constants (which would be resolved at compile-time; no
 reflection-like complexities suggested).

 I'm not interested, at this stage, in whether anyone thinks it's a good


 bad idea. I just want to know whether it's possible within the current
 object model of D, or whether it would be possible to add it without
 disturbing anything or bringing along any of the nasty baggage from


 M.I.

 Walter?


Feb 06 2006
parent "Kris" <fu bar.com> writes:
"Matthew" <matthew hat.stlsoft.dot.org> wrote...
 Can interfaces declare member constants?

I think so. Both const and enum can be used. Static-finals seems to be ok too.
 Also, don't they grow the objects footprint?

I've seen some odd results in this regard. It seems that deep Object hierarchies combined with interfaces generates notable baggage. I switched 3 of the key Mango interfaces to abstract-classes instead, and noted a sizeable difference in the resultant executables. I suspect there's a relationship to the extent of the interfaces, but don't really know. The upshot is that small interfaces in shallow hierarchies are probably nothing to be bothered about. Perhaps Walter might look into this?
Feb 06 2006
prev sibling next sibling parent reply Sean Kelly <sean f4.ca> writes:
Matthew wrote:
 Just wondered whether there's a technical reason why D could not support
 multiple inheritance for the sole purpose of declaring concepts, a la C++.

I proposed concepts recently but didn't get a reply. Here's a link: digitalmars.D/32178 Basically, I'm not sure whether the best approach is to shoehorn concept support into the MI model, particularly since it seems a lot more common to use scoped templates than to use class templates. Rather, I would like to see an actual language extension that ties into the specialization mechanism, much like the C++ 0x proposals suggest. I think this would make for a cleaner and more flexible design. Sean
Feb 06 2006
parent "Matthew" <matthew hat.stlsoft.dot.org> writes:
"Sean Kelly" <sean f4.ca> wrote in message
news:ds8nac$t0v$1 digitaldaemon.com...
 Matthew wrote:
 Just wondered whether there's a technical reason why D could not support
 multiple inheritance for the sole purpose of declaring concepts, a la


 I proposed concepts recently but didn't get a reply.  Here's a link:

 digitalmars.D/32178

I know. It's marked unread and in red in my newsreader; I'm yet to get to a point where I can make a sensible reply.
 Basically, I'm not sure whether the best approach is to shoehorn concept
 support into the MI model, particularly since it seems a lot more common
 to use scoped templates than to use class templates.  Rather, I would
 like to see an actual language extension that ties into the
 specialization mechanism, much like the C++ 0x proposals suggest.  I
 think this would make for a cleaner and more flexible design.

Sure. I'm just weighing options at the moment. (Anything but work on the last 4 difficult chapters of my sodding book <g>)
Feb 06 2006
prev sibling parent "Walter Bright" <newshound digitalmars.com> writes:
"Matthew" <matthew hat.stlsoft.dot.org> wrote in message 
news:ds8j7h$q2i$1 digitaldaemon.com...
 Walter?

I haven't studied the issue, and so don't have anything intelligent to say about it. I can say, though, that this would be very unlikely to get in 1.0.
Feb 06 2006