[Issue 4427] __traits should have isFunction, isVariable, etc
http://d.puremagic.com/issues/show_bug.cgi?id=4427 --- Comment #14 from Rob T al...@ucora.com 2013-03-29 00:06:50 PDT --- (In reply to comment #13) I would like to see something like isNullable(T) that evaluates to true if the type value can be assigned a null. Eg, struct S { ... } S* s; class C { ... } isNullable( S ) is false isNullable( typeof(s) ) is true isNullable( C ) is true --rt -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9345] CTFE fails when using std.string.format with imported string enum
http://d.puremagic.com/issues/show_bug.cgi?id=9345 yazan.dab...@gmail.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #3 from yazan.dab...@gmail.com 2013-03-29 00:57:19 PDT --- Fixed on git HEAD by https://github.com/D-Programming-Language/dmd/pull/1804 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9826] import doesn't work with absolute paths
http://d.puremagic.com/issues/show_bug.cgi?id=9826 Andrej Mitrovic andrej.mitrov...@gmail.com changed: What|Removed |Added CC||andrej.mitrov...@gmail.com --- Comment #1 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-03-29 06:59:42 PDT --- Which OS? I'm seeing the opposite effect: dmd -J. main.d // works dmd -J/ main.d // CT error -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9826] import doesn't work with absolute paths
http://d.puremagic.com/issues/show_bug.cgi?id=9826 --- Comment #2 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-03-29 06:59:59 PDT --- (In reply to comment #1) Which OS? I'm seeing the opposite effect: dmd -J. main.d // works dmd -J/ main.d // CT error Mine using Win7. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9828] New: Inconsistent lowering of 1-element tuple to its element
http://d.puremagic.com/issues/show_bug.cgi?id=9828 Summary: Inconsistent lowering of 1-element tuple to its element Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: nob...@puremagic.com ReportedBy: andrej.mitrov...@gmail.com --- Comment #0 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-03-29 08:54:26 PDT --- template tuple(T...) { alias tuple = T; } template get(alias sym) { alias get = sym; } void main() { alias tuple!(int, float) IntFloat; // alias a = get!IntFloat; // does not match, OK alias tuple!(int) Int; // alias b = get!Int; // does not match, OK alias tuple!(foo, bar) FooBar; // alias c = get!FooBar; // does not match, OK alias tuple!(foo) Foo; alias d = get!Foo; // works, ?? if (d == foo) { } // works if (Foo == foo) { } // does not work } It's really strange that a 1-element tuple seems to be implicitly convertible to its element type when it's passed by alias, yet we cannot directly compare a 1-element tuple against another element of the same type. Either it should be consistently allowed to use a 1-element tuple as if it were the element itself, or it should never be implicitly convertible to the element type. It should be consistent. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9828] Inconsistent lowering of 1-element tuple to its element
http://d.puremagic.com/issues/show_bug.cgi?id=9828 --- Comment #1 from Andrej Mitrovic andrej.mitrov...@gmail.com 2013-03-29 08:59:30 PDT --- Here's an example of why it would be useful if it's consistently allowed: import std.typetuple; template getTypes(T...) { alias getTypes = T; } void test(T)(T t) { alias attributes = getTypes!(__traits(getAttributes, T)); // NG: Even if tuple length is 1 // static if (attributes == S1) { } // NG: '(string)' and '(string)' (why are they not comparable?) // static if (attributes == TypeTuple!(S1)) { } // Note: .length check is necessary, otherwise out of bounds errors occur static if (attributes.length attributes[0] == S1) { pragma(msg, T); } } void main() { @(S1) static struct S1 { } static struct S2 { } test(S1()); test(S2()); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9829] New: rdmd passes '--' to dmd
http://d.puremagic.com/issues/show_bug.cgi?id=9829 Summary: rdmd passes '--' to dmd Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: c...@dawg.eu --- Comment #0 from Martin Nowak c...@dawg.eu 2013-03-29 09:02:09 PDT --- ./rdmd bug.d Error: unrecognized switch '--' Failed: 'dmd' '--' '-v' '-o-' 'bug.d' '-I.' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9829] rdmd passes '--' to dmd
http://d.puremagic.com/issues/show_bug.cgi?id=9829 --- Comment #1 from Martin Nowak c...@dawg.eu 2013-03-29 09:14:03 PDT --- Ah, I see this is related to bug 9583 and bug 9622. So this only happens when using the unfixed getopt from 2.062. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9826] import doesn't work with absolute paths
http://d.puremagic.com/issues/show_bug.cgi?id=9826 --- Comment #3 from Timothee Cour timothee.co...@gmail.com 2013-03-29 10:26:53 PDT --- (In reply to comment #2) (In reply to comment #1) Which OS? I'm seeing the opposite effect: dmd -J. main.d // works dmd -J/ main.d // CT error Mine using Win7. OSX. also, I actually meant compile with absolute path to main.d given to dmd: dmd -J. /path/to/main.d //fails dmd -J/ /path/to/main.d //works so that __FILE__ is an absolute path -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9826] import doesn't work with absolute paths
http://d.puremagic.com/issues/show_bug.cgi?id=9826 --- Comment #4 from Timothee Cour timothee.co...@gmail.com 2013-03-29 10:36:53 PDT --- (In reply to comment #2) (In reply to comment #1) Which OS? I'm seeing the opposite effect: dmd -J. main.d // works dmd -J/ main.d // CT error Mine using Win7. OSX. also, I actually meant compile with absolute path to main.d given to dmd: dmd -J. /path/to/main.d //fails dmd -J/ /path/to/main.d //works so that __FILE__ is an absolute path -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9830] New: Wrong purity inference for a lambda?
http://d.puremagic.com/issues/show_bug.cgi?id=9830 Summary: Wrong purity inference for a lambda? Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2013-03-29 11:44:42 PDT --- I think foo2() too can be pure: void main() { immutable int x; int foo1() pure { return x; } // OK int delegate() pure foo2 = () = x; // error } But DMD 2.063alpha gives: test.d(4): Error: cannot implicitly convert expression (__lambda1) of type int delegate() nothrow @safe to int delegate() pure -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9831] New: Error message with failed lambda inference
http://d.puremagic.com/issues/show_bug.cgi?id=9831 Summary: Error message with failed lambda inference Product: D Version: D2 Platform: x86 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 2013-03-29 11:45:40 PDT --- void main() { immutable int c; int function(int x) func; func = x = c; } DMD 2.063alpha gives the error: temp.d(4): Error: cannot infer function literal type from int function(int x) But I expect an error similar to other cases of unfit lambdas, similar to: test.d(4): Error: cannot implicitly convert expression (__lambda1) of type int delegate(int) nothrow pure @safe to int function(int). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 596] Support array, arrayliteral and struct in switch and case
http://d.puremagic.com/issues/show_bug.cgi?id=596 --- Comment #13 from bearophile_h...@eml.cc 2013-03-29 15:51:03 PDT --- It's useful to switch on struct values: import std.bigint; void main() { auto x = BigInt(3); switch (x) { case BigInt(0): break; default: break; } } Other examples of Phobos structs that is useful to switch on are Nullable, Algebraic, etc. Switching on structs is more easy if the struct has no ctor. So it's a POD (despite having some other method). To support the general case of structs that have a constructor such structs need a standard method named like unapply, that is used by the switch itself. This is the solution used by Scala language: http://www.scala-lang.org/node/112 This example is in Scala language: object Twice { def apply(x: Int): Int = x * 2 def unapply(z: Int): Option[Int] = if (z%2 == 0) Some(z/2) else None } object TwiceTest extends Application { val x = Twice(21) x match { case Twice(n) = Console.println(n) } // prints 21 } It's equivalent to the D code: import std.stdio; import std.typecons: Nullable; struct Twice { int static opCall(int x) { return x * 2; } Nullable!int unapply(int z) { if (z % 2 == 0) return typeof(return)(z / 2); else return typeof(return).init; } } void main() { immutable int x = Twice(21); assert(x == 42); switch (x) { case Twice(n): writeln(n); // prints 21 break; default: } } A different example: import std.stdio; import std.typecons: Nullable; struct Foo { int x; this(int x_) { this.x = x_ * 2; } Nullable!int unapply(Foo f1) const { return typeof(return)(f1.x / 2); } } void main() { immutable Foo f2 = Foo(10); assert(f1.x == 20); switch (f2) { case Foo(5): writeln(First case: 5); break; case Foo(n): writeln(n); // Prints: 10 break; default: } } A third example: import std.stdio; struct Even { bool unapply(int x) { return x % 2 == 0; } } void main() { int x = 17; switch (x) { case Even(): writeln(even); break; default: writeln(odd); } } unapply() is allowed to return a bool or a Nullable (including a Nullable of a tuple). For more info: http://lamp.epfl.ch/~emir/written/MatchingObjectsWithPatterns-TR.pdf -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 9832] New: Partially library-defined stack-allocated variable length arrays
http://d.puremagic.com/issues/show_bug.cgi?id=9832 Summary: Partially library-defined stack-allocated variable length arrays 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 2013-03-29 16:04:25 PDT --- This ER comes from the ashes of Issue 5348 See there for more info. C99 VLAs have some problems, so this is a rough proposal for dynamic-size stack-allocated arrays (abbreviated to DSSAA) for D that avoid their problems. This idea comes from a C++ proposal: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3532.html Ada2012 has added stack-allocated collections. Rust allows any thing you want to be allocated on the stack, if you want. In certain cases heap allocations are bad for performance. Using DSSAA it will be possible to create several other stack-allocated collections for D, as in Ada (and in future probably Rust). An idea from Walter (from Issue 5348 ): 2. I'd prefer to deal with stack allocated arrays by optimization rather than new syntax semantics, i.e.: int[] array = new int[5]; and determining that array[] can never leave its scope, and so can be allocated on the stack. I think that has problems: 1) Since some time Java has added escape analysis to stack-allocate some objects and reduce a little the pressure on the GC. This feature is useful in Java, but also it shows its limits, in many cases it fails, so it doesn't bring a large improvement in Java. 2) I'd like DSSAA to be able to leave the scope (the simplest way to do this is to dup on them, copying them on the heap. Below I show another way to do it). A solution is to invent library-defined arrays that have a semantics different from the regular dynamic arrays. 3. Consider that static arrays are passed by value to functions, rather than by reference. VLAs for static arrays mess this up. A solution is to add a special value array to Phobos, as in that n3532, and then let the D compiler manage it in a special way, allocating it on the stack where possible (if you use it inside a struct its storage goes on the heap, like a dynamic array). D compilers are supposed to be able to stack-allocate them, and most of them will do it. But a conforming D compiler is not forced to stack allocate them. In the following case foo creates a DSSAA and returns it. A DSSAA keeps its lenght beside the data, in the stack frame. At the return point inside bar() bar allocates another DSSAA on the stack (increasing the size of the stack frame of bar) and copies the received data: import std.collections: ValArray; ValArray!int foo(int n) { auto a = ValArray!int(n); // on the stack. return a; } void bar() { ValArray!int b = foo(5); // copied on the stack. } In this case foo() creates the DSSAA and calls bar with it. D just returns pointer to the data on the stack frame plus length (so it's a kind of slice) and then under the cover the data is also copied inside the stack frame of bar: import std.collections: ValArray; void foo(int n) { auto a = ValArray!int(n); bar(a); } void bar(ValArray!int b) { } Inside the implementation of that ValArray happens a bit of magic. And the compiler should recognize it and manage its memory in a special way, like it does with the special function alloca(). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5348] Variable Length Arrays
http://d.puremagic.com/issues/show_bug.cgi?id=5348 --- Comment #11 from bearophile_h...@eml.cc 2013-03-29 16:05:41 PDT --- (In reply to comment #10) but I think this is complex enough that it should be done as a DIP, not a simple enhancement request. I agree. But at the moment I am not good enough to write a DIP, so for now I have opened just Issue 9832 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---