Thread overview
[Issue 1734] New: Inconsistant mixin behaviour
Dec 16, 2007
d-bugmail
Dec 21, 2007
d-bugmail
Dec 22, 2007
Bill Baxter
[Issue 1734] Inconsistent mixin behaviour
Dec 29, 2007
d-bugmail
Nov 12, 2012
Don
Feb 05, 2013
Andrej Mitrovic
December 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1734

           Summary: Inconsistant mixin behaviour
           Product: D
           Version: 2.008
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: aarti@interia.pl
 BugsThisDependsOn: 1732


Currently templates can consists only from declarations, so it's not possible
to put there statements. It causes following:
below does not compile:
-------------------
template init() {
   a = 5;
}

void main() {
  int a;
  mixin init;
}
-------------------

but below compiles:
-------------------
import std.stdio;

template init() {
   void func() {writefln(a);}
}

void main() {
  int a;
  mixin init;
  func();
}
--------------------

while both template bodies are syntacticly wrong.

------------

I think that statements should be allowed in templates or another mechanism should be introduced and template mixins should be depreciated.


-- 

December 21, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1734


davidl@126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |major




------- Comment #1 from davidl@126.com  2007-12-21 02:48 -------
It's quite critical in my opinion.
So I mark this severity to major


-- 

December 22, 2007
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1734
> 
> 
> davidl@126.com changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Severity|enhancement                 |major
> 
> 
> 
> 
> ------- Comment #1 from davidl@126.com  2007-12-21 02:48 -------
> It's quite critical in my opinion.
> So I mark this severity to major

Is that the right way to use the severity tags?  I was thinking that an enhancement, no matter how severely needed, was always marked as enhancement.  If I can mark enhancements as major then I'm going to go change a bunch of 'em!

--bb
December 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1734


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
            Summary|Inconsistant mixin behaviour|Inconsistent mixin behaviour




------- Comment #2 from smjg@iname.com  2007-12-29 12:47 -------
Depreciated?  What?

Or do you mean deprecated?  Still, I disagree.  Templates are designed to contain declarations, not statements.  Blocks of statements are a different concept from blocks of declarations.  Declarations can be in any scope; statements can only be within a function.

So my thought is that template mixins should remain for inserting declarations in whatever scope, and something new should be created for inserting statements in a function.


-- 

November 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=1734


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |enhancement


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2012-11-12 07:21:56 PST ---
Current behaviour is intentional.

Even this does not compile:
---------
template init() {
  a = 5;
}
---------
This is an enhancement request.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=1734


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-02-04 18:01:08 PST ---
Worst case scenario you can still use string mixins:

string init()
{
    return q{

    a = 5;

    };
}

void main()
{
    int a;
    mixin(init);
}

So it's not all bad.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------