[Issue 5395] New: Interval literals
http://d.puremagic.com/issues/show_bug.cgi?id=5395 Summary: Interval literals 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 2011-01-01 06:32:05 PST --- Sometimes it's positive to replace some language feature with good Phobos implementations (like complex numbers), but language design is an iterative process, so sometimes it's positive to go the other way too. Tuples and number intervals are two examples where I think it will be good to add some syntax sugar back into the front-end. This enhancement request is about the number intervals. I suggest for the two following syntaxes to be seen by the compiler as equivalent, as syntax sugar of each other: foreach (i; 0 .. 10) foreach (i; iota(0, 10)) So I suggest the x..y syntax to become first class and to mean std.range.iota(x,y). An extension of the interval literal may allow a step value too: 0 .. 10:2 Once present the interval literal becomes useful to remove a () from lazy expressions, making them more readable: reduce!max(map!foo(1 .. 1000)) Instead of: reduce!max(map!foo(iota(1, 1000))) If the interval literal becomes first class, it's possible to use it for ranged types, or interval tests too: if (x in 5 .. 20) {...} If iota becomes syntax sugar for the ranged sequence, then the compiler is able to compile better simple code like this: foreach (i; iota(0, 10, 2)) {...} See also bug 4603 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()
http://d.puremagic.com/issues/show_bug.cgi?id=4705 --- Comment #5 from bearophile_h...@eml.cc 2011-01-01 06:33:02 PST --- Another example to show why a better max() is useful. The task is ot show how the number less than 1000 which has the longest hailstone sequence. For the hailstone see: http://en.wikipedia.org/wiki/Collatz_conjecture The code, DMD 2.051: import std.stdio, std.algorithm, std.range, std.typecons; auto hailstone(int n) { auto result = [n]; while (n != 1) { n = n 1 ? n*3 + 1 : n/2; result ~= n; } return result; } void main() { auto r = reduce!max(map!((i){return tuple(hailstone(i).length, i);})(iota(1, 1000)))[1]; writeln(r); } With a max that supports a key function and iterables the line of code in the main() becomes just: auto r = max!hailstone(iota(1, 1000)); With the enhancement request 5395 it becomes even more readable: auto r = max!hailstone(1 .. 1000); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3804] Recent versions of GNU C Library have execvpe() implemented.
http://d.puremagic.com/issues/show_bug.cgi?id=3804 Iain Buclaw ibuc...@ubuntu.com changed: What|Removed |Added Status|NEW |RESOLVED CC||ibuc...@ubuntu.com Resolution||WONTFIX --- Comment #2 from Iain Buclaw ibuc...@ubuntu.com 2011-01-01 09:56:04 PST --- OK, closing then. The lack of any configure script makes it impossible to *probe* the system that phobos is being built on anyways... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5396] New: Invalid code with nested functions in CTFE
http://d.puremagic.com/issues/show_bug.cgi?id=5396 Summary: Invalid code with nested functions in CTFE Product: D Version: D1 D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: rob...@octarineparrot.com --- Comment #0 from Robert Clipsham rob...@octarineparrot.com 2011-01-01 18:54:57 GMT --- The following code: void outer(bool b) { string inner() { if (b) { return true; } else { return false; } } pragma(msg, inner()); } Compiles and evaluates without error, despite the dependence on the runtime value b. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 4494] ICE(cod1.c) Array literal filled with results of void function
http://d.puremagic.com/issues/show_bug.cgi?id=4494 Iain Buclaw ibuc...@ubuntu.com changed: What|Removed |Added CC||ibuc...@ubuntu.com OS/Version|Windows |All --- Comment #1 from Iain Buclaw ibuc...@ubuntu.com 2011-01-01 11:21:49 PST --- Changing platform to All (affects Linux too). Similar code: void[] p = [cast(void)42]; As of DMD-2.051, now prints: Internal error: ../ztc/cod1.c 3057 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5397] New: Compiler error on struct with invariant and postblitz
http://d.puremagic.com/issues/show_bug.cgi?id=5397 Summary: Compiler error on struct with invariant and postblitz Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: alex.khm...@gmail.com --- Comment #0 from Alex Khmara alex.khm...@gmail.com 2011-01-01 13:12:38 PST --- This code: module properties; struct PropertyList { invariant() { assert(1); } this(this) { _props = []; } string[] _props; } gives compiler error: Error: __result = this is not mutable Error: __result = this is not an lvalue Without invariant all works good. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5397] Compiler error on struct with invariant and postblitz
http://d.puremagic.com/issues/show_bug.cgi?id=5397 Alex Khmara alex.khm...@gmail.com changed: What|Removed |Added Platform|Other |x86 --- Comment #1 from Alex Khmara alex.khm...@gmail.com 2011-01-01 13:14:12 PST --- It seems that I cannot set proper DMD version - It was on DMD 2.0.51, Linux x86 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5398] New: Unterminated doc comment ignored
http://d.puremagic.com/issues/show_bug.cgi?id=5398 Summary: Unterminated doc comment ignored Product: D Version: D1 D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: rob...@octarineparrot.com --- Comment #0 from Robert Clipsham rob...@octarineparrot.com 2011-01-01 21:49:02 GMT --- When the following is compiled with dmd -unittest -c Sqlite.d Sqlite.d: module Sqlite; import Database; class SqliteDatabase { public Result!(T) execute(T)() { assert(0); } } unittest { auto db = new SqliteDatabase(); struct Test { } db.execute!(Test)(); } Database.d: module Database; class Result(T) { T[] mResults; //import tango.util.log.Trace; import tango.util.log.Log; size_t length() { return mResults.length; } } Log.d: module Log; /+/++/ --- dmd compiles without error, when it should complain about the unterminated documentation comment in Log.d. In LDC this leads to some weird semantic errors: http://dsource.org/projects/ldc/ticket/447 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5399] New: Return the result of a nonvoid function in a void function
http://d.puremagic.com/issues/show_bug.cgi?id=5399 Summary: Return the result of a nonvoid function in a void function Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bearophile_h...@eml.cc --- Comment #0 from bearophile_h...@eml.cc 2011-01-01 13:49:57 PST --- In D (rightly) you can't return a value different from void inside a void function. But this code compiles and runs with no errors in DMD 2.051 (bug found by Daren Scot Wilson): int foo() { return 1; } void main() { return foo(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5398] Unterminated doc comment ignored
http://d.puremagic.com/issues/show_bug.cgi?id=5398 Robert Clipsham rob...@octarineparrot.com changed: What|Removed |Added Keywords||accepts-invalid URL||http://dsource.org/projects ||/ldc/ticket/447 --- Comment #1 from Robert Clipsham rob...@octarineparrot.com 2011-01-01 22:06:36 GMT --- import tango.util.log.Log; = that line should be import Log; obviously, that's a remnant from an old version of the code before I narrowed it down. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2043] Closure outer variables in nested blocks are not allocated/instantiated correctly.
http://d.puremagic.com/issues/show_bug.cgi?id=2043 Witold Baryluk bary...@smp.if.uj.edu.pl changed: What|Removed |Added CC||bary...@smp.if.uj.edu.pl --- Comment #6 from Witold Baryluk bary...@smp.if.uj.edu.pl 2011-01-01 18:20:46 PST --- I today hit this bug. It really isn't obvious how to workaround this problem. It is not possible to easly just allocate variable or struct with variable's value manually, as it still will just by single identifier, and it will at the end still point to single entity. Simplified case, which returns array of delegates each printing next integer. import std.stdio; alias void delegate() D; /* do not work, */ auto f(int n) { auto tab = new D[n]; for (int i = 0; i n; i++) { // invariant ii = i; // will not help // struct S { int i_; }; S x = new S; x.i_ = i; // will also not help, as x is on stack tab[i] = delegate void() { writefln(i=%d, i); }; // also using nested function, and taking address do not work } return tab; } void main() { auto tab = f(10); foreach (k, ref x; tab) { writef(%d : , k); x(); } } It currently will print in all cases: 0 : i=10 1 : i=10 2 : i=10 3 : i=10 4 : i=10 5 : i=10 6 : i=10 7 : i=10 8 : i=10 9 : i=10 My current workaround involves looping using recursion (and be sure that compiler do not make it tail-recursive probably): /* recursive loop version will work */ auto f2(int n) { auto tab = new D[n]; void f2r(int i) { tab[i] = delegate void() { writefln(i=%d, i); }; if (i n-1) { f2r(i+1); /* recursion */ } } f2r(0); /* enter recursion */ return tab; } Which will make our constructed delegates work as desired: 0 : i=0 1 : i=1 2 : i=2 3 : i=3 4 : i=4 5 : i=5 6 : i=6 7 : i=7 8 : i=8 9 : i=9 (I tested if this is not just a a coincidence, but overwriting stack by random values, and it works still correctly. BTW. switch for compiler which will show what local variables are/will automatically allocated on heap will be usefull). As of definitive solution, i think invariant which is referenced by escaping delegate should be allocated on heap, and its addresses should be remembered immediately in constructed delegate. Other possibility is separate syntax, like new delegate void() ... , which will make all variables referenced by delegate a copies of current values of variables with the same names (considering scoping rules). Hope this will be helpful for somebody. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5316] std.getopt with associative arrays
http://d.puremagic.com/issues/show_bug.cgi?id=5316 Andrei Alexandrescu and...@metalanguage.com changed: What|Removed |Added Status|NEW |ASSIGNED AssignedTo|nob...@puremagic.com|and...@metalanguage.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 620] Can't use property syntax with a template function
http://d.puremagic.com/issues/show_bug.cgi?id=620 Alex Khmara alex.khm...@gmail.com changed: What|Removed |Added CC||alex.khm...@gmail.com --- Comment #4 from Alex Khmara alex.khm...@gmail.com 2011-01-01 22:22:42 PST --- (In reply to comment #3) Some hacking about showed me that opDispatch has a workaround for this problem, by using a two-layer approach: template opDispatch( string name ) { auto opDispatch( T... )( T args ) { // Do something! } } This workaroung is only partial. This code produces Error: s.opDispatch(T...) has no value. import std.stdio; struct S { template opDispatch( string name ) { string opDispatch( T... )( T args ) { return bar; } } } void main() { S s; string str = s.foo; } Same if I try auto opDispatch instead of string. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5397] Compiler error on struct with invariant and postblitz
http://d.puremagic.com/issues/show_bug.cgi?id=5397 Don clugd...@yahoo.com.au changed: What|Removed |Added Status|NEW |RESOLVED CC||clugd...@yahoo.com.au Resolution||DUPLICATE --- Comment #2 from Don clugd...@yahoo.com.au 2011-01-01 22:26:12 PST --- (In reply to comment #1) It seems that I cannot set proper DMD version - It was on DMD 2.0.51, Linux x86 You should just set version = D2 (the exact release number is useless information). Same issue as bug 3273. *** This issue has been marked as a duplicate of issue 3273 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 3273] Regression(2.031): struct invariant + dtor fails to compile (no line number)
http://d.puremagic.com/issues/show_bug.cgi?id=3273 Don clugd...@yahoo.com.au changed: What|Removed |Added CC||alex.khm...@gmail.com --- Comment #7 from Don clugd...@yahoo.com.au 2011-01-01 22:26:12 PST --- *** Issue 5397 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5399] Return the result of a nonvoid function in a void function
http://d.puremagic.com/issues/show_bug.cgi?id=5399 bearophile_h...@eml.cc changed: What|Removed |Added Severity|normal |enhancement --- Comment #1 from bearophile_h...@eml.cc 2011-01-01 23:00:02 PST --- This isn't a bug, I was wrong. D2 specs clearly show this is working as expected: http://www.digitalmars.com/d/2.0/statement.html ReturnStatement: return; return Expression ; Expression is allowed even if the function specifies a void return type. The Expression will be evaluated, but nothing will be returned. If the Expression has no side effects, and the return type is void, then it is illegal. Indeed, this too compiles: void main() { int x; return x++; } But this is a potentially dangerous corner case in the return rules. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5399] Return the result of a nonvoid function in a void function
http://d.puremagic.com/issues/show_bug.cgi?id=5399 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||INVALID --- Comment #2 from Walter Bright bugzi...@digitalmars.com 2011-01-01 23:33:12 PST --- It is not a dangerous corner case, it is a deliberate design choice. It is meant to facilitate writing generic code so that the same code can be generated for void and non-void return values. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---