[Issue 3748] inout does not work properly

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3748


Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #6 from Walter Bright  2011-10-01 
22:10:12 PDT ---
https://github.com/D-Programming-Language/dmd/commit/07f719e5bd882b0e66e9759ed29319e2be93ef3c

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


[Issue 6756] New: Idea about std.stdio.chunks and std.range.chunks

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6756

   Summary: Idea about std.stdio.chunks and std.range.chunks
   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 2011-10-01 18:51:32 PDT ---
I'm finding the recently introduced std.range.chunks quite useful. In
Mathematica there is a similar function (but not lazy and even too much
powerful) named Partition:

http://reference.wolfram.com/mathematica/ref/Partition.html

Unfortunately the one in Phobos often causes a name collision in my code:


import std.stdio, std.range;
void main() {
auto ch = chunks(iota(15), 2);
writeln(ch);
}


It gives:

test.d(3): Error: std.stdio.chunks at ...\dmd2\src\phobos\std\stdio.d(2038)
conflicts with std.range.chunks(Source) at
...\dmd2\src\phobos\std\range.d(5261)


So you have to write:

import std.stdio, std.range;
void main() {
auto ch = std.range.chunks(iota(15), 2);
writeln(ch);
}



std.stdio.chunks is a struct with this constructor:

struct chunks {
private File f;
private size_t size;
this(File f, size_t size) {
...



While std.range.chunks is a helper function:

Chunks!(Source) chunks(Source)(Source source, size_t chunkSize) {
return typeof(return)(source, chunkSize);
}


That uses:

struct Chunks(Source) if(hasSlicing!Source && hasLength!Source) {
this(Source source, size_t chunkSize) {
this._source = source;
this._chunkSize = chunkSize;
}
...
}


I think you never call std.range.chunks with a File as first argument. The
cause of the problem is probably shown in this little test:


struct Foo {}

void bar(Foo x) {}
void bar(T)(T x) if (!is(T == Foo)) {}
//void bar(T)(T x) if (is(T == Foo)) {}

void main() {
bar([1, 2, 3]);
bar(Foo());
}


test.d(4): Error: template test.bar(T) if (!is(T == Foo)) conflicts with
function test.bar at test.d(3)


I don't know if in future DMD will allow overloading of functions with
templates, but in the meantime a possible solution is to rename the
std.stdio.chunks struct to a name that starts with upper case:


struct Chunks
{
private File f;
private size_t size;
// private string fileName; // Currently, no use

this(F f, size_t size)


To introduce a lowercase little helper function template with a template
constraint that the first template argument must be a File:


Chunks chunks(F)(F f, size_t size) if (is(F == File))
{
return Chunks(f, size);
}


(This doesn't cause a code bloat because std.stdio.range gets gets instantiated
with only one type for the first argument, so it's like a single regular
function.)


And then to add a negative template constraint to std.range.chunks:


Chunks!(Source) chunks(Source)(Source source, size_t chunkSize)
if (!is(Source == File) && hasSlicing!Source && hasLength!Source)
{
return typeof(return)(source, chunkSize);
}


I think this solves the name collision problem.

By the way, do you know why std.range.Chunks has a template constraint while
its helper function std.range.chunks doesn't have it? Most times you call
std.range.chunks. So if you call it with wrong arguments you receive a template
error inside std.range instead in your code. This is not good. So I think
std.range.chunks needs the same template constraint as std.range.Chunks (plus
!is(Source == File) at the start if you accept the idea shown here).

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


[Issue 6755] New: Better wrong function pointer error message

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6755

   Summary: Better wrong function pointer error message
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Keywords: diagnostic
  Severity: minor
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-10-01 17:26:10 PDT ---
void bar(void function(const int) f) {}
void foo(const float c) {}
void main() {
bar(&foo);
}


DMD 2.056head gives:

test.d(4): Error: function test.bar (void function(const const(int)) f) is not
callable using argument types (void function(const const(float) c))
test.d(4): Error: cannot implicitly convert expression (& foo) of type void
function(const const(float) c) to void function(const const(int))


I'd like it to print "const(int)" or "const int" instead "const const(int)".

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


[Issue 6754] New: extern() in a function signature

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6754

   Summary: extern() in a function signature
   Product: D
   Version: D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-10-01 17:22:06 PDT ---
This comes from code shown in D.learn:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=29886

You can't use extern(C) in a function signature:


void foo(extern(C) void function() f) {}
void main() {}


DMD 2.056head gives:

test.d(1): basic type expected, not extern
test.d(1): found 'extern' when expecting ')'
test.d(1): semicolon expected following function declaration
test.d(1): Declaration expected, not '('


Workaround: before the function definition you have to define the argument type
with an alias:


alias extern(C) void function() CF;
void foo(CF f) {}
void main() {}

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


[Issue 6672] [CTFE] ICE on compile time std.algorithm.sort

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6672



--- Comment #6 from Walter Bright  2011-10-01 
14:15:27 PDT ---
More fixes:

https://github.com/D-Programming-Language/dmd/commit/f680025e30b5423e2d2759e5c2f004cafb53e5ea

https://github.com/D-Programming-Language/dmd/commit/36d5b056a318698d392cc84db92282368092a533

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


[Issue 6749] [CTFE] problem with array of structs

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6749


Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #3 from Walter Bright  2011-10-01 
14:14:59 PDT ---
https://github.com/D-Programming-Language/dmd/commit/f680025e30b5423e2d2759e5c2f004cafb53e5ea

https://github.com/D-Programming-Language/dmd/commit/36d5b056a318698d392cc84db92282368092a533

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


[Issue 6753] New: "Reinterpret" cast of array to a tail const one doesn't work inside @trusted

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6753

   Summary: "Reinterpret" cast of array to a tail const one
doesn't work inside @trusted
   Product: D
   Version: D2
  Platform: Other
OS/Version: All
Status: NEW
  Severity: regression
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: dmitry.o...@gmail.com


--- Comment #0 from Dmitry Olshansky  2011-10-01 
14:09:34 PDT ---
This used to work on 2.055:

struct Interval{ int a,b; }
@safe struct S 
{
int[] arr;
@trusted @property auto byInterval() const
{
return cast(const(Interval)[])arr;
}
}

Now on 2.056head (on commit fac2d5107a003320ce5389de04fcb6705e3795c9)
it's rejected with:
Error: cast from const(int[]) to const(Interval)[] not allowed in safe code

Maybe byInterval somehow doesn't override it's safety level to "trusted".
The following workaround works which makes me think it's a bug in upcoming
2.056.

@safe struct S
{
int[] arr;
@trusted @property auto byInterval() const
{
const(int)[] tmp = arr;
return cast(const(Interval)[])tmp;
}
}

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


[Issue 6672] [CTFE] ICE on compile time std.algorithm.sort

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6672


bearophile_h...@eml.cc changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution||FIXED


--- Comment #5 from bearophile_h...@eml.cc 2011-10-01 13:56:47 PDT ---
https://github.com/D-Programming-Language/dmd/commit/e36f124bad9c67fa960adaeb40b7113152453d6e

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


[Issue 2006] Appending empty array using ~= doesn't work

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2006



--- Comment #6 from Stewart Gordon  2011-10-01 13:13:23 PDT ---
(In reply to comment #5)
> (In reply to comment #3)
>> At the very least I'd like the compiler to generate an error saying it 
>> doesn't
>> know how to interpret 'arr ~= []'.
> 
> Yes, ambiguity that is bug-prone, because both interpretations can run, must
> yield compiler error.

Yes, an uncast [] is ambiguous.  But the original bug report isn't about that,
but about

aas ~= cast (string []) [];

which is completely unambiguous.

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


[Issue 4909] Two suggestions for std.algorithm.schwartzSort()

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4909



--- Comment #6 from bearophile_h...@eml.cc 2011-10-01 12:58:40 PDT ---
In Clojure language the sort with a key function is named "sort-by":
http://clojuredocs.org/clojure_core/1.2.0/clojure.core/sort-by

In Mathematica it is named "SortBy":
http://reference.wolfram.com/mathematica/ref/SortBy.html

In Scala it is named "sortBy":
http://www.scala-lang.org/docu/files/collections-api/collections_5.html

I suggest to deprecate "schwartzSort" name. In Phobos the "sortBy" name (as in
Scala) will be better than "schwartzSort".

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


[Issue 6752] New: Add separate option to control stack frame generation

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6752

   Summary: Add separate option to control stack frame generation
   Product: D
   Version: D1 & D2
  Platform: x86
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: thecybersha...@gmail.com


--- Comment #0 from Vladimir Panteleev  2011-10-01 
09:50:23 PDT ---
Currently, stack frame generation is tied to the -release command-line option.
The -release option also controls other things, such as bounds checking,
inclusion of asserts/contracts/invariants etc.

It is sometimes useful to have stack frames in an optimized executable, for
example for usage with a 3rd-party profiler. Therefore, there should be an
additional option to control just stack frame generation.

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


[Issue 6751] New: [CTFE] ref argument of AA doesn't work

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6751

   Summary: [CTFE] ref argument of AA doesn't work
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: youx...@gmail.com


--- Comment #0 from Hisayuki Mima  2011-10-02 01:00:53 JST 
---
void f(ref int i, ref string str, ref int[int] aa){
i = 2;
str ~= "hello";
aa[1] = 2;
assert(aa[1] == 2);
}

static assert({
int[int] aa;
int i;
string str;
f(i, str, aa);
assert(i == 2);// OK
assert(str == "hello");// OK
assert(aa[1] == 2);// Error: cannot index null array aa
}());

The above code doesn't be compiled by the dmd v2.056 DEBUG built from github
after the commit 42fea4c1f2.
This means that ref argument of AA doesn't work well in CTFE.

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


[Issue 6672] [CTFE] ICE on compile time std.algorithm.sort

2011-10-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=6672


Don  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |


--- Comment #4 from Don  2011-10-01 00:02:48 PDT ---
(In reply to comment #3)
> Now the code gives a different error (this error is not produced if this
> sorting is done at run time):
> 
> ...\dmd2\src\phobos\std\algorithm.d(6662): Error: "Failed to sort range of 
> type
> string[]. Actual result is: [alias, align, asm, assert, auto, body, bool,
> break]..."
> test5.d(8):called from here: sort(kw)
> test5.d(12):called from here: foo()
> foo()

Aargh, I really fouled that up! Not fixed.
Here's a reduced test case.

void bug6672b(ref string lhs) 
{
string tmp = lhs;
lhs = "b";
assert(tmp == "a");
}

static assert( {
string q = "m";
bug6672b(q);
return true;
}());

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