www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4087] New: Static Node struct of std.range.SListRange

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4087

           Summary: Static Node struct of std.range.SListRange
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



(This is kind of my first patch. Not using a patch command yet.)

Inside the module std.range.SListRange, at about line 1586 there is:

struct SListRange(T, Topology topology = Topology.flexible)
{
private:
    struct Node { T _value; Node * _next; }
    Node * _root;



The D2 specs here say:
http://www.digitalmars.com/d/2.0/struct.html

A struct can be prevented from being nested by using the static attribute, but
then of course it will not be able to access variables from its enclosing
scope.

I think currently all D structs are static, that feature is not implemented
yet, but once that will be implemented the Node of SListRange will be 3 words
long instead of 2 (and probably in practice 4 words), so I suggest to modify
the code like this:


struct SListRange(T, Topology topology = Topology.flexible)
{
private:
    static struct Node { T _value; Node * _next; }
    Node * _root;


Likewise, I suggest to add the static attribute to nested structs in Phobos
everywhere it's not necessary to access outer names.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4087


Robert Clipsham <robert octarineparrot.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |robert octarineparrot.com



22:45:41 BST ---
Make sure you include the patch keyword when you add a patch, this way
Walter/Don/Andrei can find it more easily :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 13 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4087


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


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