Re: CTFE Memory Hogging Workaround?
Maxime Chevalier: One of the reasons I chose to use D for my project is that I was very excited about the prospect of using CTFE in mixin code. Unfortunately, there seems to be one (or several?) bugs causing CTFE to be very slow and to hog a huge amount of memory (multiple gigs of RAM and swap). Is there some known fix for this? I need this to work now. Otherwise, I'm going to have to rewrite my CTFE/mixin code in Python or something, which would be a shame, and a waste of time on my part. Please use D.learn newsgroup for similar questions, this group is not for discussions. There are coding strategies to partially reduce the memory used during CTFE, but in general it uses lot of memory, sometimes too much. This problem is well known and Don is working on it and he has improved the situation a little, but it will take time to fix it well, possibly some months or more. Currently CTFE is not fit for heavy computations. Bye, bearophile
Regarding hex strings
Maybe hex strings were invented in D1 when strings were convertible to char[]. But today strings are an array of immutable UFT-8, so I think this default type is now less useful: void main() { string data1 = xA1 B2 C3 D4; // OK immutable(ubyte)[] data2 = xA1 B2 C3 D4; // error } Gives: test.d(3): Error: cannot implicitly convert expression (\xa1\xb2\xc3\xd4) of type string to ubyte[] Generally I'd like to use hex literals to put binary data nicely in a program, so usually I need an ubyte[] or uint[]. So I have to use something like: auto data3 = cast(ubyte[])(xA1 B2 C3 D4.dup); So maybe the following literals are more useful in D2: ubyte[] data4a = x[A1 B2 C3 D4]; ubyte[4] data4b = x[A1 B2 C3 D4]; uint[] data5a = x[A1 B2 C3 D4]; uint[2] data5b = x[A1 B2 C3 D4]; ulong[] data6a = x[A1 B2 C3 D4 A1 B2 C3 D4]; ulong[1] data6b = x[A1 B2 C3 D4 A1 B2 C3 D4]; Bye, bearophile
Re: Regarding hex strings
Jonathan M Davis: You posted to the wrong list. - Jonathan M Davis Right Jonathan, I am sorry :-) I will try again in the main D newsgroup. Bye, bearophile
Re: Access Violation Problems in DMD 2.060
Raphael Basso: I'm having serious problems with Access Violation to create programs that make use of C DLLs in DMD 2060. After all, integration with DLLs in C DMD is fully functional? Try asking in D.learn, and to give more infomation. Bye, bearophile
Re: [Issue 8672] %% operator
On Monday, 17 September 2012 at 01:15:56 UTC, ixid wrote: Is there any use for the way C-style modulus interacts with negative numbers? It seems little more than broken on the basis of making positive number modulus operations efficient back when C was created. This is not a group for discussions. If you want to comment you have to add it to the bug report.
Re: [Issue 8634] Anonymous function parameters
On Sunday, 9 September 2012 at 19:59:02 UTC, Namespace wrote: BTW dmd doesn't produce any warning for unused variable. And this will never change. ;) Who knows, maybe eventually I'll be able to convince GDC maintainers to introduce this warning :-)
Re: compiler can't deduce template function
Zhenya wrote: ... I suggest to minimize your code, and then show this problem again in the D.learn newsgroup. Bye, bearophile
Re: Cast Object - get null
Namespace: Vector2D is my own class. If i compare vs2 with vs it works fine, but if i compare vs or vs2 with vf, the cast fail and i get a null-reference. How can i avoid this? I suggest to ask such questions in D.learn. Bye, bearophile
Re: 2.056: EXE size on Windows
pvy Wrote: Hello, I'm newbie. I have been switched to 2.056 from 2.054 (I've been deleted its distro, so can't test it) and see that .exe file after compilation of Hello World now is about 1Mb! It's a known problem, but I don't expect significant improvements soon. Something funny on this topic: http://prog21.dadgum.com/116.html Bye, bearophile
Ada, HCSS and more
This looks mostly like Ada advertisement, but it's readable (May 2008): http://www.mil-embedded.com/articles/id/?3277 The Reddit thread about it: http://www.reddit.com/r/programming/comments/lol4l/ccjava_a_gazillion_features_and_still_suck_at/ From the article: Last year's High Confidence Software and Systems (HCSS) conference, sponsored by NSA to address security-critical issues, featured an interesting presentation from Microsoft addressing such issues in the context of Windows. The primary sources of problems in Microsoft's experience are buffer overruns and integer overflow problems. I have done some searching, but I have not found this presentation. Bye, bearophile
Re: Ada, HCSS and more
Sorry, wrong place. I'll try again elsewhere.
Re: Possible bug with dynamic rectangular array initialization
Robert: When I try to initialize a dynamic rectangular array, the length of the inner arrays does not seem to be preserved outside the scope of initialization. I'm not proficient enough in D to say that my code is completely correct, but if I am correct this might be a serious bug. See attached test code. Even when you think you have found a bug in D, I suggest you to ask first in D.learn newsgroup. D.bugs is not meant for free discussions. Regarding your code, you have hit a bug-prone spot of D, but I think D is correct here. This code of yours: foreach (i, r; grid) { r.length = width; Write it like: foreach (i, ref r; grid) { r.length = width; Because D arrays are value types that contain a pointer to the storage. So the r inside the foreach is a copy, you aren't modifying the original. See the D ABI to see how D dynamic arrays are implemented on their surface (it doesn't explain how array append is managed at runtime). Bye, bearophile
Expose the CTFE interpter in Phobos?
(This post is related to something I have suggested time ago, to offer some parts of the D compiler through the D standard library itself (to use the compiler at run-time for some purposes), as recent versions of C#-dotnet too do.) There is a part of the D compiler that to me seems more useful than other ones, I mean the D interpreter used for CTFE. People often add Lua, Python, MiniD, JavaScript to large C/C++/D programs (I think most video games contain some kind of interpreter). So is it possible to offer this part alone to the D programmer? With it you are allowed to create at runtime small strings of D code and interpret it. No need to learn and add a second scripting language to do it. Just import a function execute() from a Phobos module :-) The (hopefully) introduction of some writing function (http://d.puremagic.com/issues/show_bug.cgi?id=3952 https://github.com/D-Programming-Language/dmd/pull/237 ) will make run-time D interpretation even more useful. There are disadvantages: - Even with some printing function, CTFE interpreter is limited. Don will remove some more CTFE limitations like allowing classes and exceptions, but a scripting language that can't read and save files is less useful; so maybe it can't fully replace a Lua interpreter. - If you want to use this feature you need the whole D compiler at run time too. The D compiler is probably much bigger than a Lua interpreter. On the other hand maybe it's possible to push the CTFE interpreter in a DLL that is normally used by the D compiler, that the D standard library uses if you want to interpret D code at run time. I don't know if this DLL is going to be small enough. - CTFE is currently much slower than dynamic/scripting languages like LuaJIT (that are becoming almost as fast as well compiled D). But in LDC with the LLVM back-end you have all the tools to create a JIT for interpted D code too :-) LLVM is not a compiler, it's an aggregate of parts. - D language is not as simple as a scripting language. In video games the people that write the 3D engine in C++ are not the same people that program game logic in Lua. The second group of people has different skills, and they often are not good programmers able to write C++ code too. So among other things Lua is used to allow a large number of people to write how the game has to act, not just hard-core C++ programmers. Do you know/have use cases for running D code (with current or near-future CTFE limitations) at run-time? Bye, bearophile
Re: Expose the CTFE interpter in Phobos?
Please ignore this post, the web interface is now more buggy than it used to be. Sorry, bearophile
Re: D2 dynamic array on Win32 exception
Gleb: void main() { int[][5] a; a[0][0] = 1; } Compiling this code compiler (D 2.051, Win32) generates an error: core.exception.RangeError@aaa(4): Range violation With D v.1 it's all rigth. I guess it's a bug in D v.2 Are you sure it is not a bug on D1? For further posts, I suggest you the D.learn newsgroup. Bye, bearophile
Re: auto return type inheritance not covariant
iLewis: Maybe this has been brought up before, but i could find no previous submissions. It looks like a bug fit for Bugzilla: class Foo { int fun1() { return 1; } auto fun2() { return 1; } auto fun3() { return 1; } } class Bar : Foo { override auto fun1() { return 1; } override int fun2() { return 1; } override auto fun3() { return 1; } } void main() {} Bye, bearophile
Re: overloading template functions it not always allowed
Steven Schveighoffer: so even though I feel this is a bug (it should be silently ignored), Generally silently ignoring attributes is exactly the opposite you want from a modern compiler. See bug 3934. Bye, bearophile
Re: ubyte in for loops
Your code works, here too: http://ideone.com/Taq71 So maybe it's the 64 bit system that gives problems. Are you able to minimize your code, to show just the problem? So it will become a bug report for bugzilla. By the way, the D.bugs group is not for general chat, use D.learn instead. Bye, bearophile
Re: ubyte in for loops
A different version of your code with some improvements: import std.stdio, std.cstream, std.random; void main() { uint chosen = uniform(1, 21); writeln(This is a guessing game); writeln(I have chosen a number between 1 and 20 ~ which you must guess); int guess = 0; foreach_reverse (i; 1 .. 4) { writefln(You have %s tr%s left., i, i == 1 ? y : ies); write(enter a guess: ); // prompt for a guess scanf(%d, guess); // Read a guess // check if guess correct if (guess == chosen) { writefln(\nYou guessed it!); return; } // Check for an invalid guess if (guess 1 || guess 20) // you can add brackets here if you want writeln(I said between 1 and 20.); else writefln(Sorry. %s is wrong., guess); } writefln(You have had three tries and failed. The number was %s, chosen); din.getc(); // useless? } Bye, bearophile
Re: C1X features
Please ignore this post, my error, I am sorry. I'll post it elsewhere again.
Re: ubyte in for loops
DBloke: The code was for(ubyte cnt = 3; cnt 0; --cnt) { ... code here } This program: import std.stdio: writeln; void main() { for (ubyte i = 3; i 0; --i) { writeln(i); } } Prints with dmd 2.047: 3 2 1 It's better to use the D.learn newsgroup for such questions. Bye, bearophile
Re: [Issue 4111] New: Foreach ranges accept floating-point extrema
Aelxx: foreach(i; 2.1 .. 4.10001) { writeln(typeid(typeof(i))); // Output: double break; } I'd like MATLAB style more: foreach (f; linspace (0.0, 1.0, 100)) {...} here f gets values 0, 0.0101.., 0.0202..., ..., 0.98989..., 1.0 foreach (f; logspace (1.0, 1e6, 7)) {...} here f gets values 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6. If you have comments on a bug report, it's quite better if you write them in Bugzilla, because here they will probably be lost/ignored. Phobos has iota() that's similar to what you ask, a FP version is easy to create. Bye, bearophile