digitalmars.D - mixins as inline functions
- Serg Kovrov (8/8) Aug 18 2006 First time I looked at mixins in D reference, I thought that it could be...
- Craig Black (6/14) Aug 18 2006 There should definitely be plans for the evolution of mixins. The featu...
- Walter Bright (2/9) Aug 18 2006 Why not just use inline functions?
- Serg Kovrov (5/15) Aug 18 2006 Er... Because there is no inline functions? =)
- Sean Kelly (14/29) Aug 18 2006 In some cases, yes, if the compiler can determine that the result will
- Walter Bright (5/19) Aug 18 2006 Functions accessed through the virtual function pointer table cannot be
First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution? -- serg.
Aug 18 2006
There should definitely be plans for the evolution of mixins. The feature is way jacked up and unusable for a lot of things that should work. I don't forsee anything changing for 1.0 though. -Craig "Serg Kovrov" <kovrov no.spam> wrote in message news:ec402d$pgv$1 digitaldaemon.com...First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution? -- serg.
Aug 18 2006
Serg Kovrov wrote:First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution?Why not just use inline functions?
Aug 18 2006
Walter Bright wrote:Serg Kovrov wrote:Er... Because there is no inline functions? =) But if seriously, does virtual methods (accessing 'this') can be inlined? -- serg.First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution?Why not just use inline functions?
Aug 18 2006
Serg Kovrov wrote:Walter Bright wrote:In some cases, yes, if the compiler can determine that the result will be correct. However, use of function pointers and delegates is not inlined. For this reason, I sometimes use a struct with opCall defined instead (as these calls are inlined by DMD in many cases). I haven't figured out the magic formula for having an opCall be inlined however (I should really look at the DMD front-end code and figure it out). Sometimes simply adding "static" to the opCall declaration is enough to have the function go from inlined to not, and in other cases an opCall that is inlined in one routine is not inlined in another. I'm currently wrestling with this in a quicksort implementation I've been tweaking. If you don't mind the work, the best thing is to simply experiment (compile with "-inline -release -O") and view the output with obj2asm. SeanSerg Kovrov wrote:Er... Because there is no inline functions? =) But if seriously, does virtual methods (accessing 'this') can be inlined?First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution?Why not just use inline functions?
Aug 18 2006
Serg Kovrov wrote:Walter Bright wrote:All functions are candidates for inlining.Serg Kovrov wrote:Er... Because there is no inline functions? =)First time I looked at mixins in D reference, I thought that it could be used as inline function. Like a big C macro. But better =) It has its own scope, it has access to parent scope, everything seems fit. Except that in mixins it is not possible to use assign operations. Could this restriction be removed in future? Is there any plans for mixins evolution?Why not just use inline functions?But if seriously, does virtual methods (accessing 'this') can be inlined?Functions accessed through the virtual function pointer table cannot be inlined. Mixins can't fix that. To access a function directly, rather than through virtual dispatch, declare it to be 'final'.
Aug 18 2006