Thread overview
[Issue 4550] New: D2 Language Docs: http://www.digitalmars.com/d/2.0/statement.html
Aug 01, 2010
Andrej Mitrovic
May 20, 2011
Andrej Mitrovic
May 20, 2011
Andrej Mitrovic
Jan 15, 2012
Walter Bright
August 01, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4550

           Summary: D2 Language Docs:
                    http://www.digitalmars.com/d/2.0/statement.html
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2010-08-01 09:17:08 PDT ---
"Labeled Statements"

It states: "Labels are in a name space independent of declarations, variables, types, etc. Even so, labels *cannot* have the same name as local declarations."

These examples:

void main() {
    int t;
    t: {
        int xyz;
    }
}

void main() {
    int t;
    xyz: {
        int xyz;
    }
}

will compile. I'm not sure whether this is correct behavior.



"foreach_reverse"
AFAIK this is scheduled for removal. Maybe put the documentation for 'retro'
here?



"Foreach over Arrays of Characters"

In the first example, these lines:

char[] a = "\xE2\x89\xA0";      // \u2260 encoded as 3 UTF-8 bytes dchar[] b = "\u2260";           // prints 'a[] = 2260'

should be replaced with:

char[] a = "\xE2\x89\xA0".dup;  // \u2260 encoded as 3 UTF-8 bytes dchar[] b = "\u2260"d.dup;      // prints 'a[] = 2260'



"Foreach over Associative Arrays"

The first example code gives these compiler errors:
    foreach_test.d(38): Error: function
    object.AssociativeArray!(const(char)[],double).AssociativeArray.opApply
    (scope int delegate(ref const(char)[], ref double) dg) is not callable
    using argument types (int delegate(ref double __applyArg0,
    ref char[] __applyArg1))

    foreach_test.d(38): Error: cannot implicitly convert expression
    (__foreachbody524) of type int delegate(ref double __applyArg0,
    ref char[] __applyArg1) to int delegate(ref double)

Woah! :)

This probably has to do with trying to use a ref type in the foreach over AA, so replace the example with either this:

double[char[]] a;
...
foreach (const (char)[] s, ref double d; a)
{
    writefln("a['%s'] = %g", s, d);
}

Or let type inference do it's thing:

double[char[]] a;    // index type is char[], value type is double
...
foreach (s, double d; a)
{
    writeln(typeid(s));
    writefln("a['%s'] = %g", s, d);
}

The compiler could give a more sensible error message when trying to use a reference type for the key of an AA.



"Foreach over Tuples"

In the first example replace all 'writefln' with 'writeln'.

In foreach over tuples it states: "index must be of int or uint type."

Why is size_t disallowed as the index of a Tuple? This will not compile:

import std.stdio;
import std.typetuple;    // for TypeTuple

void main()
{
    alias TypeTuple!(int, long, double) TL;

    foreach (size_t index, T; TL)
    {
        writeln(typeid(T));
    }
}

But it will also give out the error:

test2.d(131): Error: foreach: key type must be int or uint, not size_t

I think this should be:

test2.d(131): Error: foreach: index type must be int or uint, not size_t



"Foreach Restrictions"

There are no compilation errors or warnings (even when a and b are
allocated) for the example code.



"Switch Statement"

There's this line:
"If none of the case expressions match, and there is not a default
    statement, a [std.switcherr.SwitchError] is thrown."

The link goes to a 404 page. Also, "std.switcherr.SwitchError" should be replaced with "core.exception.SwitchError"



"Scope Guard Statement" and "Mixin Statement"

Replace all 'writefln' with 'writeln', 'writef' with 'write' in the example code.

Also, in the example for "Mixin Statement" replace the line: char[] t = "y = 3;";

with:
char[] t = "y = 3;".dup;



"Foreach Range Statement"
This should be moved up next to the other foreach definitions.

In the example code replace 'writefln' with 'writeln', and 'writef' with 'write'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4550


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-19 21:11:33 PDT ---
Fixed in local branch, will issue pull request later.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4550


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-19 21:13:53 PDT ---
Reopening since I haven't merged anything yet. Sorry for the notification spam!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4550


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-15 14:19:42 PST ---
https://github.com/D-Programming-Language/d-programming-language.org/pull/53

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