[Issue 4345] New: std.range.take!string: Nonsensical finite range with slicing but no length

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4345

   Summary: std.range.take!string: Nonsensical finite range with
slicing but no length
   Product: D
   Version: D2
  Platform: Other
OS/Version: Mac OS X
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: michel.for...@michelf.com


--- Comment #0 from Michel Fortin michel.for...@michelf.com 2010-06-19 
08:39:44 EDT ---
This code triggers a static assert called Nonsensical finite range with
slicing but no length in std.range.take!string:

string str = abcdef;
string result = str.take(3);
assert(array(result) == abc);

It probably has something to do with strings which have no length defined to so
they work with code units instead of code points.

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


[Issue 4346] New: More flexible std.array.array

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4346

   Summary: More flexible std.array.array
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-06-19 06:32:28 PDT ---
Dmd v2.047 rejects all the following programs:


import std.array: array;
void main() {
int[2] a = [1, 2];
assert(array(a) == [1, 2]);
}


import std.container: SList;
import std.array: array;
void main() {
auto l = SList!int(1, 2);
assert(array(l) == [1, 2]);
}


import std.container: SList;
import std.array: array;
void main() {
auto l = SList!int(1, 2);
assert(array(l[]) == [1, 2]);
}


If a collection can be iterated with foreach, and its items can be copied, then
array() has to work on it (and use the Appender for performance where the
length of the collection is not known).

See also bug 4114

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


[Issue 3961] Error with to!(somestruct)

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3961


Lars T. Kyllingstad bugzi...@kyllingen.net changed:

   What|Removed |Added

 CC||bugzi...@kyllingen.net


--- Comment #2 from Lars T. Kyllingstad bugzi...@kyllingen.net 2010-06-19 
08:05:21 PDT ---
http://www.dsource.org/projects/phobos/changeset/1589

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


[Issue 4347] New: foreach over range should save range.

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4347

   Summary: foreach over range should save range.
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: dsim...@yahoo.com


--- Comment #0 from David Simcha dsim...@yahoo.com 2010-06-19 08:49:42 PDT ---
To be consistent with the old definition of forward ranges, and with arrays and
opApply-based ranges, a foreach loop should call save() if it's available.  The
example below demonstrates why not doing so is problematic.

import std.stdio;

class SomeRange {
uint num;

uint front() {
return num;
}

void popFront() {
num++;
}

bool empty() @property {
return num = 10;
}

typeof(this) save() @property {
auto ret = new typeof(this);
ret.num = num;
return ret;
}
}

void main() {
auto r = new SomeRange;
foreach(elem; r) {
writeln(elem);  // Prints numbers 0-9.
}

foreach(elem; r) {
writeln(elem); // Nothing.
}
}

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


[Issue 4348] New: std.container.SList append

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4348

   Summary: std.container.SList append
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-06-19 12:52:03 PDT ---
This shows how you can append to a std.container.SList:

import std.container: SList;
void main() {
auto l = SList!int(1, 2);
l.insertAfter(l[], 3);
}


But the standard D syntax too can be supported, despite it's O(n):

import std.container: SList;
void main() {
auto l = SList!int(1, 2);
l ~= 3;
}


(The member function insertFront might be named prepend, that is shorter ,
equally readable and contains no upper case letters).

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


[Issue 4349] New: Deprecate automatic case fallthrough

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4349

   Summary: Deprecate automatic case fallthrough
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-06-19 13:06:48 PDT ---
Bugs caused by unwanted fall-through between cases in switch statement are
common enough to push designers of other languages (like C#) to find ways to
avoid them.

D2 has already in place all is necessary to avoid this source of problems. The
only missing part is to disallow cases that miss an explicit return, goto,
break, assert(0), exit(), or similar.

C code ported to D that assumes the fall-through will just raise errors that
can be solved adding goto case; at the end of the cases.

The usage of goto case; will not be excessive because D allows both ranged
cases and multiple with a comma that allow to compress switch code.

case 1, 2, 3:
case 1: .. case 3:

As for the multiple returns in a function this kind of code needs some care:

switch (x) {
case 0:
if (y)
goto case;
else
return x;
default:
break;
}


Bug 3536 shows an alternative proposal.

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


[Issue 3536] [patch] Make switch case error at unintentional fallthrough. (allow intentional fallthrough)

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3536


bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc


--- Comment #9 from bearophile_h...@eml.cc 2010-06-19 13:07:18 PDT ---
See also bug 4349

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


[Issue 4350] New: (mixin) mixed in template identifier is not accessible by with statement

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4350

   Summary: (mixin) mixed in template identifier is not accessible
by with statement
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: michal.min...@gmail.com


--- Comment #0 from Michal Minich michal.min...@gmail.com 2010-06-19 13:32:14 
PDT ---
dmd 2.047

template Bar () { int bar; }

struct Foo {
int foo;
mixin Bar mix;
}


void main () {

Foo f;

f.foo = 1;
f.mix.bar = 1;

with (f) {
foo = 2;
mix.bar = 2; // Error: type Foo is not an expression
}
}

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


[Issue 4351] New: string literal postfix

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4351

   Summary: string literal postfix
   Product: D
   Version: unspecified
  Platform: Other
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: www.digitalmars.com
AssignedTo: nob...@puremagic.com
ReportedBy: ellery-newco...@utulsa.edu


--- Comment #0 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-06-19 
14:06:20 PDT ---
is missing for DelimitedString and TokenString

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


[Issue 4351] string literal postfix

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4351



--- Comment #1 from Ellery Newcomer ellery-newco...@utulsa.edu 2010-06-19 
14:07:17 PDT ---
Created an attachment (id=667)
adds postfix to productions

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


[Issue 4348] std.container.SList append

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4348


Andrei Alexandrescu and...@metalanguage.com changed:

   What|Removed |Added

 CC||and...@metalanguage.com


--- Comment #1 from Andrei Alexandrescu and...@metalanguage.com 2010-06-19 
14:51:02 PDT ---
~= is only for containers that can implement it in time independent of the size
of the container. Writing s.insertAfter(s[], value) hints the user that the
cost is higher (i.e. proportional to the length of s[]).

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


[Issue 4348] std.container.SList append

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4348



--- Comment #2 from bearophile_h...@eml.cc 2010-06-19 15:20:42 PDT ---
Answer to Comment 1: thank you for your answer, I didn't know about this rule.

In arrays the append can require a full array copy, so it can be O(n), but it's
(hopefully) O(1) on amortized time.

If this rule is present and well established then you can close this bug report
(the suggestion about the prepend name is for you, but you can ignore it if
you don't like it).

Another possibility is to find a compromise: instead of writing something hairy
like:
s.insertAfter(s[], value)
You can use:
s.linearAppend(value)
That is less noisy and equally clear in its complexity :-)

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


[Issue 4352] New: Destructor of inner struct not callale

2010-06-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4352

   Summary: Destructor of inner struct not callale
   Product: D
   Version: D2
  Platform: Other
OS/Version: Linux
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: and...@metalanguage.com


--- Comment #0 from Andrei Alexandrescu and...@metalanguage.com 2010-06-19 
22:49:47 PDT ---
Compiling this:

struct Array(T)
{
struct Payload
{
~this()
{
}
}
RefCounted!(Payload, RefCountedAutoInitialize.no) _data;
}

unittest
{
Array!int a;
}

ends with error message:

/home/andrei/code/dmd/phobos/std/typecons.d(365): Error: destructor
test.Array!(int).Array.Payload.~this () is not callable using argument types ()

The reported location is mistaken too.

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