Summary: D2 Language Docs:
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2

--- Comment #0 from Andrej Mitrovic <> 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

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.

AFAIK this is scheduled for removal. Maybe put the documentation for 'retro'

"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
    (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)
    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)

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

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

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

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to