www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1734] New: Inconsistant mixin behaviour

reply d-bugmail puremagic.com writes:
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.


-- 
Dec 16 2007
next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1734


davidl 126.com changed:

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





It's quite critical in my opinion.
So I mark this severity to major


-- 
Dec 21 2007
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
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
 
 
 
 

 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
Dec 21 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
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





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.


-- 
Dec 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1734


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Nov 12 2012
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 04 2013