Re: List of Dynamic Arrays
On Thursday, 17 June 2021 at 15:58:40 UTC, Adam D Ruppe wrote: On Thursday, 17 June 2021 at 15:57:46 UTC, Justin Choi wrote: I want to write something like `DList!int[]()` DList!(int[])() ? Thanks I've mentally slapped myself a hundred times for this mistake :D
List of Dynamic Arrays
If I wanted to create a DList (or any similar data structure) of multiple integers, how would I accomplish this? I want to write something like `DList!int[]()` but the best I can do for now is a format such as `DList!(Tuple(int, int))()` which confines me to a fixed number of integers.
Unpacking Slices
Is there any shortcut for unpacking slices like I'd want to do in a scenario like this? `info = readln.strip.split;` `string a = info[0], b = info[1], c = info[2];`
Predicates Within Strings
Could somebody explain or point me to documentation that helps to explain the usage of strings in predicates? My main question is how D infers the omitted variable specifications given otherwise - for example: `filter!(a => a < 3)(arr);` and `filter!"a < 3"(arr);` produce the same result.
Inclusion of Parenthesis on Certain Functions
I'm currently learning D right now, and I was wondering why certain functions like std.stdio.readln can work both with and without parenthesis for the function call. I've tried looking through the documentation but can't find an explanation for why you can use it without parenthesis.
Re: dub build doesn't work
On Tuesday, 22 October 2019 at 22:14:02 UTC, OiseuKodeur wrote: Hello, i am having a problem with dub build with this project https://github.com/OiseauKodeur/cervelet/tree/master/source when i try to compile everything go well but when i click to run the .exe it give my an error missing msvcr100.dll, but with rdmd the program run fine Hi. The link you provided is invalid (is your repository private?), but I'll try my best to help. This is a problem with your system being unable to locate "msvcr100.dll", which it needs to load for your application. From what I have found from a quick search, this .dll is a part of Microsoft Visual C++. You should try installing Visual C++ and see if that solves the problem. Best
Re: run.dlang.io can now display ASM + AST + IR
Very cool features! Due to template expansion, even very simple D programs won't display their AST, e.g. https://run.dlang.io/is/yVsPsH gives me a "Compilation or running program took longer than 25 seconds. Aborted!" Not sure what can be done about this, but it certainly limits the usefulness for now.
Re: [your code here] minimal hex viewer
On Thursday, 4 January 2018 at 00:54:12 UTC, Seb wrote: On Thursday, 4 January 2018 at 00:35:56 UTC, H. S. Teoh wrote: On Thu, Jan 04, 2018 at 12:25:59AM +, Justin Whear via Digitalmars-d wrote: // Reads bytes from stdin and writes a hexadecimal view like a no-frills xxd. // All the actual formatting work is done by format's sweet range syntax Mmm, I like this! Care to submit a PR for this in the dlang.org repo? @Justin: Thanks a lot for your suggestion, but don't we already have a "Print hex dump" example on dlang.org? Looks like we do, I had not noticed it previously. Naturally I prefer my implementation, ;)
[your code here] minimal hex viewer
// Reads bytes from stdin and writes a hexadecimal view like a no-frills xxd. // All the actual formatting work is done by format's sweet range syntax void main(string[] args) { import std.getopt; uint bytesPerLine = 8; args.getopt( "cols|c", ); import std.stdio; import std.range : chunks; import std.algorithm : map, copy; import std.string : format; import std.ascii : newline; stdin.byChunk(bytesPerLine) .map!(bytes => bytes.format!"%(%02X %)%s"(newline)) .copy(stdout.lockingTextWriter()); }
Audio to text files
Is there a resource that explains how to create a file that stores a response to a question. say I want to introduce a program like this "Hi, my name is "", what's yours"? I want to generate an audio profile that's interactive and store data for access like a personal assistant. Any suggestions are appreciated, please and thanks.
Saving code for personal developement
How to save your work to email? Anyone know? I use my mobile to write.
[your code here]
8 4
Re: Speed of csvReader
On Thu, 21 Jan 2016 18:37:08 +, data pulverizer wrote: > It's interesting that the output first array is not the same as the > input byLine reuses a buffer (for speed) and the subsequent split operation just returns slices into that buffer. So when byLine progresses to the next line the strings (slices) returned previously now point into a buffer with different contents. You should either use byLineCopy or .idup to create copies of the relevant strings. If your use-case allows for streaming and doesn't require having all the data present at once, you could continue to use byLine and just be careful not to refer to previous rows.
Re: Index a parameter tuple with a run-time index
On Fri, 15 Jan 2016 20:52:46 +, Meta wrote: > And of course I'm proven wrong as soon as I post :) Sometimes I forget > how powerful D's code generation abilities are. Username doesn't check out, :(
Re: GC greediness
On Tue, 05 Jan 2016 16:07:36 +, Jack Applegame wrote: > On a server with 4GB of RAM our D application consumes about 1GB. > Today we have increased server memory to 6 Gb and the same application > under the same conditions began to consume about 3Gb of memory. > Does GC greediness depend on available RAM? My understanding is that the GC won't return collected memory to the OS unless a threshold relative the system total is crossed. You can use GC.minimize() from core.memory to decrease this. This could result in degraded performance.
Re: Palindromes
On Thu, 03 Dec 2015 21:40:05 +, Jim Barnett wrote: > TL;DR I couldn't figure out how to write `isPalindrome` in terms of > std.algorithm.mutation.reverse > > I recognize it's more efficient in terms of CPU time and memory than my > C++ solution, but I suspect there is a shorter expression to detect > palindromes if efficiency isn't the primary concern. So I am interested > in seeing implementations of `isPalindrome` that utilize > `std.algorithm.mutation.reverse`, or anyone who cares to enlighten me > why that might be a misguided thing to want. Thanks for reading. I don't think you want reverse because it works in-place; you'd need to make a copy to compare against. std.range.retro is probably what you're looking for: bool isPalindrome(R)(R range) if (isBidirectionalRange!R) { return range.equal(range.retro); } Obviously this does more work than strictly necessary, but has the brevity you're looking for.
Re: GTKD TreeView - Delete TreeView SubItem with Button?
On Fri, 20 Nov 2015 18:57:10 +, TheDGuy wrote: > Thanks for your reply, > > now it gets more clear for me but how am i able to access the TreeView > within the CustomButton-Class? If i declare TreeView and TreeStore > public i get "static variable list cannot be read at compile time"? > > auto list = new List(); > auto treeView = new LanguageTree(list); You need to declare them at the module scope but initialize them inside your main function, so: List list; LanguageTree treeView; then inside your main function: list = new List(); treeView = new LanguageTree(list);
Re: GTKD TreeView - Delete TreeView SubItem with Button?
On Fri, 20 Nov 2015 19:34:01 +, TheDGuy wrote: > Thanks for your reply, > > is it also possible to do it like this? > Yeah, that'll work. > but now i get the error: > > "rowDeleted is not callable using argument types (TreeIter)"? rowDeleted is just to emit the signal that a row has been removed, not actually remove it. You probably want to use the ListStore's remove method.
Re: GTKD TreeView - Delete TreeView SubItem with Button?
On Fri, 20 Nov 2015 19:45:25 +, TheDGuy wrote: > So like this? > > public void remove(TreeIter iter) > { > this.remove(iter); > } > > If i do this, i get a stackoverflow error :( That's creating an infinite recursion as the method simply calls itself. Assuming the class inherits from ListStore, you can just erase the remove method entirely and let the base class handle it. If you want to do something extra, use: override void remove(TreeIter iter) { // Anything custom super.remove(iter); // Anything custom }
Re: Compile time strings auto concatenation!?
On Fri, 20 Nov 2015 20:39:57 +, Ilya wrote: > Can DMD frontend optimize > string concatenation > ``` > enum Double(S) = S ~ S; > > assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); > ``` > > to > > ``` > assert(condition, "Text ++_function_name_"); > > ``` > ? Yes this occurs as part of the constant folding I believe. $ cat test.d enum Double(string S) = S ~ S; void main(string[] args){ assert(args.length, "Text " ~ Double!"+" ~ __FUNCTION__); } $ dmd test.d $ strings test | grep Text Text ++test.main
Re: linux inotify on a std.process.ProcessPipes ?
On Mon, 16 Nov 2015 23:08:46 +, opla wrote: > Does anyone know if it's possible to monitor the events that happen on > the output stream of a piped process ? > > I'm stuck on doc: > > - https://www.win.tue.nl/~aeb/linux/lk/lk-12.html - > http://www.ibm.com/developerworks/library/l-ubuntu-inotify/ > - http://linux.die.net/man/2/inotify_add_watch > > inotify_add_watch second argument seems to be a file name. The only > thing available is a std.stdio.File with a handle. > > The goal is to create an asynchronous process with a least one > notification that would happen when the process terminates, maybe when > the output stream is written too. You can use poll on the file descriptor (which can be gotten with File.fileno). Basically something like this (untested): while (ImWaiting) { if (processPipes.stdout.eof) { // The child is done writing (has exited, generally speaking) } //TODO set up poll items pollfd pfd = { processPipes.stdout.fileno, POLLIN }; // Use 0 for timeout so that we don't wait; if you don't have anything else // to do, you can use a real timeout value if (1 == poll(, 1, 0)) { // New data is available on the child's stdout, do something with it } // Do other things, sleep, etc. }
Re: What does the -betterC switch in dmd do?
On Thu, 12 Nov 2015 19:37:41 +, TheFlyingFiddle wrote: > The description in dmd help says: omit generating some runtime > information and helper functions. > > What runtime information are we talking about here? My > understanding is that it's basically an experimental feature but > when (if) completed what subset of the language would still be > usable? I believe the purpose of the switch is to help folks who are trying to write for bare or embedded systems by not emitting references to the D runtime library and runtime module information. Whether it actually does that in its current implementation is another question.
Re: Problem Benchmarking HashSet from containers-em
On Thu, 22 Oct 2015 11:55:37 +, Nordlöw wrote: > What's wrong? HashSet has a disabled default constructor; you need to supply the allocator instance to the constructor here https://github.com/nordlow/ justd/blob/master/containers_ex.d#L17
Re: Problem Benchmarking HashSet from containers-em
On Thu, 22 Oct 2015 19:41:08 +, Nordlöw wrote: > My existing call to > > auto set = HashSet!(E, Allocator)(); > > works for Mallocator as in > > https://github.com/nordlow/justd/blob/master/containers_ex.d#L17 > > but not for > > InSituRegion!(1024*1024, T.alignof) > > Why? Please, help. The HashSet defines different constructors based on the nature of tha allocator: https://github.com/economicmodeling/containers/blob/master/src/containers/hashset.d#L30 Specifically, if the allocator has zero state (like Mallocator), you do not pass an instance. If the allocator does have state, like InSituRegion, you need to pass an instance to the container's constructor.
Re: Check Instance of Template for Parameter Type/Value
On Mon, 19 Oct 2015 14:51:28 +, Stewart Moth wrote: > I'm working with a library that has template structs of mathematical > vectors that can sometimes be the type of an array I'm passing to a > function. > > The definition of the struct is like this: > > struct Vector(type, int dimension_){ ... } > > Where type is going to be an int/float/etc and dimension_ is 2/3/4. > > I could write a bunch of functions for each case, but I'd rather not... > I'd like to use something like the following: > > void foo(T)(Array!T array){ > if(isInstanceOf!(Vector, T)){ > //get type of T or check it //test if dimension_ is 2 or 3 or 4 > ... > } else { > //Non-vector stuff ... > } > } > > But to do that I need to check that parameters of T as if it were an > instantiated instance of Vector and I'm not sure how to accomplish > that... Can anyone help me out with what I need to do? Pattern matching! void foo(ArrayT : Array!VectorT, VectorT : Vector!(T, dimension), T, int dimension)(ArrayT arr) { static if (dimension >= 2 && dimension <= 4) { } else { } }
Re: Is there a smart way to process a range of range by front ?
On Wed, 23 Sep 2015 21:17:27 +, BBasile wrote: > On Wednesday, 23 September 2015 at 21:04:44 UTC, Justin Whear wrote: >> On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: >> >>> I was thinking to a general *interleave()* algorithm for any >>> compatible Range of Range but I can't find any smart way to process >>> each sub range by front >> >> Can you show a sample input and output to clarify what you mean by >> interleave? It's possible that what you want is >> std.range.frontTransversal, std.range.transversal, or >> std.range.transposed. > > --- > auto r0 = [[0,2],[1,3]]; > auto r1 = interleave(r0); > assert(r1 = [0,1,2,3]); > auto r2 = [[0,3],[1,4],[2,5]]; > auto r3 = interleave(r2); > assert(r3 = [0,1,2,3,4,5]); > --- > > the fact that the numbers are ordered is just an helper. OK, I think what you're after is std.range.roundRobin.
Re: Is there a smart way to process a range of range by front ?
On Wed, 23 Sep 2015 20:48:03 +, BBasile wrote: > I was thinking to a general *interleave()* algorithm for any compatible > Range of Range but I can't find any smart way to process each sub range > by front Can you show a sample input and output to clarify what you mean by interleave? It's possible that what you want is std.range.frontTransversal, std.range.transversal, or std.range.transposed.
Re: foreach automoatic counter?
On Mon, 21 Sep 2015 15:38:38 +, French Football wrote: > Going through a book on coding in D, > http://ddili.org/ders/d.en/foreach.html , I find the following very > useful feature: > > When two names are specified in the names section [with a plain array], > they represent an automatic counter and the value of the element, > respectively: > foreach (i, element; array) { > writeln(i, ": ", element); > } > > I understand that foreach is built on top of a for loop... I'm just > wondering why I can't access the automatic counter from a doubly linked > list, or an associative array, or some range? It's pretty common for me > to have to rewrite foreach loops to be for loops when I get to the > bottom and realize I need to know where in the sequence I am... With an associative array the foreach becomes: foreach (key, value; aa) For arbitrary ranges you can use std.range.enumerate like this: foreach (i, element; someRange.enumerate)
Re: Template Oriented Programming
On Thu, 17 Sep 2015 20:41:11 +, Adam wrote: > Is this the basic idea? > > Use templates when you want more power? That is, TOP can do everything > OOP can do but more? Or are these ultimately two orthogonal concepts? I think you've got the right idea. Some unordered thoughts: * OOP provides run-time dynamism while TOP is strictly compile-time. This means that TOP can produce optimal code via inlining and no indirections, but also means that it can't do plugin systems via dynamic libraries. You may, of course, mix the two. * static if allows features to be enabled inline based on the capabilities of the input types * Since D code can generate entirely new code in the compiler, TOP offers some serious potential for cool magic. Use wisely, of course. * TOP moves the information bar back a step--instead of runtime reflection the compiler provides compile-time reflection, allowing runtime reflection to become a userspace library.
Re: Canvas in Gtk connected to D?
On Mon, 14 Sep 2015 17:05:16 +, Mike McKee wrote: > Is there a way to do a canvas in GTK3 so that I can use chart.js, Mike, as this is really a GTK3 question and not specific to D (if GTK will let you do it in C, you can do it in D), you might have better success asking the GTK forum (gtkforums.com). Another avenue of research would be to look at CEF (D bindings here: http://code.dlang.org/packages/ derelict-cef) and see if that will integrate with your toolkit.
Re: spawn X different workers & wait for results from all of them
On Sat, 05 Sep 2015 12:21:33 +0200, Robert M. Münch wrote: > My "pieceOfWork" is not the same. So I don't have the case: Do 4 time > this 1thing. Instead, do 1 time these 4 things. Ah, so you want to receive one each of various types? Something like this might work (untested): // These could be inferred using std.traits.ReturnType alias ResultTypes = AliasSeq!(int, float, Baz); bool received(T) = false; bool receivedAll() { foreach (T; ResultTypes) if (!received!T) return false; return true; } while (!receivedAll) { receive( (int x) { received!int = true; /* other work... */ }, (float x) { received!float = true; /* other work... */ }, (Baz x) { received!Baz = true; /* other work... */ } ); }
Re: spawn X different workers & wait for results from all of them
On Thu, 03 Sep 2015 18:50:21 +0200, Robert M. Münch wrote: > Hi, I'm not sure how to best implement the following: > > 1. I have 4 different tasks to do. > 2. All can run in parallel 3. Every task will return some result that I > need > > Now how to best do it? When using receive() it fires on the first hit > and the function continues. It's like a receive(OR), one hit and it's > done. So, I would need something like a receive(ALL) that continues only > of all results (messages) have been received. > > Is something like this available or do I have to build it myself? How would receive know? If you're using std.concurrency, the receiving function needs to encode doneness, e.g. const numJobs = 4; foreach (_; 0 .. numJobs) receive(...); Or you could use std.parallelism: foreach (pieceOfWork; parallel(listOfWork)) doIt(pieceOfWork);
Re: interprocess communication and sharing memory
On Thu, 03 Sep 2015 01:27:14 +, j55 wrote: > I've read many posts about shared memory and interprocess communication > in D, but I didn't see any conclusive information about whether this > type of interprocess memory sharing will be convenient or practical in > D. If it doesn't work out, I have some prototype already working in c++ > with boost interprocess, but I'd prefer to use a native D solution if > possible. I really like ZeroMQ for messaging--it scales transparently from IPC to TCP and packages lots of smart topologies for you. There's a D wrapper here: https://github.com/kyllingstad/zmqd For shared memory, it's pretty easy to do with std.mmfile.
Re: Why ElementType!(char[3]) == dchar instead of char?
On Tue, 01 Sep 2015 19:40:24 +0300, drug wrote: > I'm just trying to automatically convert D types to hdf5 types so I > guess char[..] isn't obligatory some form of UTF-8 encoded text. Or I > should treat it so? Because of D's autodecoding it can be problematic to assume UTF-8 if other encodings are actually in use. If, for instance, you try printing a string stored as char[] that is actually Latin-1 encoded and contains characters from the high range, you'll get a runtime UTF-8 decoding exception. If you don't know ahead of time what the encoding will be, using ubyte[] will be safer. The other option is to dynamically reencode strings to UTF-8 as you read them.
Re: LLVM 3.7 released - LDC is ready to use it!
On Tue, 01 Sep 2015 21:45:30 +, Kai Nacke wrote: > This is the 7th time that LDC and D are mentioned in the LLVM release > notes! Fantastic work keeping LDC bleeding edge!
Re: Why ElementType!(char[3]) == dchar instead of char?
On Tue, 01 Sep 2015 19:18:42 +0300, drug wrote: > http://dpaste.dzfl.pl/4535c5c03126 Arrays of char are assumed to be UTF-8 encoded text and a single char is not necessarily sufficient to represent a character. ElementType identifies the type that you will receive when (for instance) foreaching over the array and D autodecodes the UTF-8 for you. If you'd like to represent raw bytes use byte[3] or ubyte[3]. If you'd like other encodings, check out std.encoding.
Re: Why ElementType!(char[3]) == dchar instead of char?
On Tue, 01 Sep 2015 19:21:44 +0300, drug wrote: > On 01.09.2015 19:18, drug wrote: >> http://dpaste.dzfl.pl/4535c5c03126 > > Should I use ForeachType!(char[3]) instead of ElementType? Try std.range.ElementEncodingType
Re: Why ElementType!(char[3]) == dchar instead of char?
On Tue, 01 Sep 2015 16:25:53 +, Justin Whear wrote: > On Tue, 01 Sep 2015 19:18:42 +0300, drug wrote: > >> http://dpaste.dzfl.pl/4535c5c03126 > > Arrays of char are assumed to be UTF-8 encoded text and a single char is > not necessarily sufficient to represent a character. ElementType > identifies the type that you will receive when (for instance) foreaching > over the array and D autodecodes the UTF-8 for you. If you'd like to > represent raw bytes use byte[3] or ubyte[3]. If you'd like other > encodings, check out std.encoding. I should correct this: * ForeachType is the element type that will inferred by a foreach loop * ElementType is usually the same as ForeachType but is the type of the value returned by .front One major distinction is that ElementType is only for ranges while ForeachType will work for iterable non-ranges.
Re: NYT data article based on work of EMSI, who I think are a D shop
On Tue, 25 Aug 2015 04:55:12 +, Laeeth Isharc wrote: http://www.nytimes.com/2015/08/23/magazine/the-creative-apocalypse-that- wasnt.html Interesting article as it corrects misconceptions of a few years back by looking at the data. This is based on tools from EMSI, who are a D shop. Congratulations to EMSI, and it would be great to hear more from them sometime about how they use D (I know they spoke at dconf once) Hi, I'm the Data group lead at EMSI; my group is the primary user of D in the organization and I can confirm that we are doing some interesting things with it that really leverage D's strengths. I will work on putting together a piece highlighting some of those things--any suggestions for venue? We don't have a public tech blog, so the wiki is the only thing coming to mind. P.S. Lots of other great mentions if you're interested in the work we do: http://www.economicmodeling.com/press/
Re: Casting double to ulong weirdness
On Mon, 24 Aug 2015 18:06:07 +, rumbu wrote: BTW, 1.2 and 12.0 are directly representable as double In C++: printf(%.20f\r\n, 1.2); printf(%.20f\r\n, 12.0); will output: 1.2000 12. Either upcasting to real is the wrong decision here, either the writeln string conversion is wrong. No it's not, this must be some sort of constant-folding or precision increase. $ cat test.c #include stdio.h int main(int nargs, char** args) { double x = 1.2; printf(%.20f\n, x); } $ clang test.c ./a.out 1.19995559
Re: How do I find the actual types of the elements in a list of classes?
On Thu, 13 Aug 2015 21:42:52 +, Jack Stouffer wrote: foreach (item; parent_list) { string class_name = (cast(Object) item).classinfo.name; if (class_name == test.A) { (cast(A) item).method(); } else if (class_name == test.B) { (cast(B) item).method2(); } } } This is a dirty hack, but I don't care, it works :) Casting actually performs this check for you, returning null if the object can't be casted, so I'd do this: foreach (item; parent_list) { if (auto asA = cast(A)item) { asA.method(); } else if (auto asB = cast(B)item) { asB.method2(); } }
Re: Hello Assembly!
On Wed, 12 Aug 2015 22:10:30 +, Taylor Hillegeist wrote: I figure this should do it. but i'm running into problems. Anybody know why? Describe problems
Re: Calling Syntax (no, not UFCS)
On Mon, 03 Aug 2015 22:42:14 +, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see this practice even in the official Phobos documentation: ``` foreach (result; [ 1, 2, 3, 4 ].map!(a + a, a * a)) ... ``` The code `.map!(a + a, a * a)()` also compiles and works as expected, of course. Opinions vary, but I think it's generally idiomatic to omit empty parens when chaining but otherwise include them. E.g.: void foo() { ... } void main() { foo; // don't do this foo(); // do this // Empty parens in a chain are just noise: [1,2,3].map!(i = i + 1)() .reduce!`a+b`() .writeln(); // This is better [1,2,3].map!(i = i + 1) .reduce!`a+b` .writeln(); // you may or may not want to conclude with parens } One gotcha that still gets me is with sort: somearray.sort; // calls the builtin property sort left over from D1, don't use! somearray.sort(); // calls std.algorithm.sort with default `ab` comparator So: somearray.map(i = i+1).array.sort().reduce!`a+b`.writeln();
Re: Why Java (server VM) is faster than D?
Java being fastest at running Java-style code is not too surprising. My guess is that Java is hotspot inlining the calls to `bar`, getting rid of the dynamic dispatch overhead. I think that for real systems D will generally beat out Java across the board, but not if the D version is a straight up transliteration of the Java--expect Java to be the best at running Java code.
Re: Rant after trying Rust a bit
On Fri, 24 Jul 2015 22:07:12 +, Jonathan M Davis wrote: On Friday, 24 July 2015 at 21:48:23 UTC, Tofu Ninja wrote: On Friday, 24 July 2015 at 21:32:19 UTC, Jonathan M Davis wrote: This is exactly wrong attitude. Why on earth should we make life easier for folks who don't bother to get 100% unit test coverage? Because that is 99% of D users... If so, they have no excuse. D has made it ridiculously easy to unit test your code. And I very much doubt that 99% of D users don't unit test their code. There are cases where 100% isn't possible - e.g. because of an assert(0) or because you're dealing with UI code or the like where it simply isn't usable without running the program - but even then, the test coverage should be as close to 100% as can be achieved, which isn't usually going to be all that far from 100%. We should be ashamed when our code is not as close to 100% code coverage as is feasible (which is usually 100%). - Jonathan M Davis Commercial (though in-house) D library and tools writer here. We run code-coverage as part of our CI process and report results back to Gitlab (our self-hosted Github-like). Merge requests all report the code coverage of the pull (haven't figured out how to do a delta against the old coverage yet). I regularly test code to 100% of coverable lines, where coverable lines are all but: assert(0, ...) Test case lines that aren't supposed to execute (e.g. lambdas in a predSwitch) I agree that there's really no excuse and think we ought to orient the language towards serious professionals who will produce quality code. Bad code is bad code, regardless of the language.
Re: Rant after trying Rust a bit
On Thu, 23 Jul 2015 13:46:16 -0700, Walter Bright wrote: like implicit declaration of variables. Trigger warning needed!
Re: really good talk about the Hotspot VM
On Thu, 16 Jul 2015 17:30:05 +, Benjamin Thaut wrote: The speaker has 30 years of experience working on javas hotspot vm How is this possible? Time travel?
Re: How to get value of enum without casting
On Thu, 09 Jul 2015 16:20:56 +, tcak wrote: Is there any way to get the type of enum without interacting with its items? std.traits.OriginalType Is there any way to get string representation of an item of enum without casting? I think casting to the OriginalType and then using to!string is the correct way to do this.
Re: Voting for std.experimental.allocator
Yes.
Re: Creating a future/promise object
On Mon, 06 Jul 2015 20:56:03 +, Frank Pagliughi wrote: Hello All, I'm trying to figure out how to create a shared object that can be used to track asynchronous operations. Something that can be used like: Token tok = mything.start_something(); // do something else for a while int n = tok.get_result(); // Block until result is ready std.parallelism.Task implements the high-level pattern you're looking for: http://dlang.org/phobos/std_parallelism.html#.Task
Re: lovely compiler error message - incompatible types
On Thu, 02 Jul 2015 17:33:28 +, Laeeth Isharc wrote: FixedDecimal is a fixed decimal point struct that stores values as an int or long and takes number of decimal places as the second compile term argument. It's possible, if not likely I have made a mistake in implementing operator overloads. Any thoughts on whether this is the likely cause, and if so which ones are likely to be the problem? Can you show the signature for FixedDecimal's opBinary?
Re: lovely compiler error message - incompatible types
On Thu, 02 Jul 2015 21:03:37 +, Laeeth Isharc wrote: Can you post the signature to the operator overload? I have an idea of what it might be, but it's difficult to explain without context. -Steve https://gist.github.com/Laeeth/6251fa731e4cee84bcdc not really a proper implementation. I wanted something as a placeholder today that I could implement properly later... I think the issue is that your opBinary requires that isNumeric!T be true. This is the case if FixedDecimal is allowed to decay to the underlying int which is why it works when you use the alias this. I recommend removing the alias this and adding another overload like this: FixedDecimal opBinary(string s, T : FixedDecimal)(const T rhs)
Re: Multi-dimensional fixed arrays
On Tue, 30 Jun 2015 21:02:37 +, DLearner wrote: Out of curiosity, why can't D define a 2-dim array by something like: int(2,1) foo; which defines two elements referred to as: foo(0,0) and foo(1,0)? Work is being done on multidimensional slicing, see this thread: http://forum.dlang.org/post/dyvzmjfcjzoxvitwb...@forum.dlang.org It just seems unnatural (if not actually dangerous) to me to have the array index order reverse between definition and use. Think about it this way: alias IntList = int[10]; IntList[3] myIntLists; int[10][3] myOtherIntLists; // same type as above You build the type up from the innermost layer to the outermost and when you access the data you reverse that operation, slicing deeper and deeper.
Re: Multi-dimensional fixed arrays
On Tue, 30 Jun 2015 20:09:50 +, DLearner wrote: Suppose: 'int [1][2] foo;' Probably I misunderstand, but TDPL seems to say that foo has two elements: foo[0][0] and foo[1][0] as opposed to two elements: foo[0][0] and foo[0][1] Is this correct? No. The order of braces when indexing is the opposite of the order when declaring. The declaration int [1][2] foo; reads innermost to outermost, ((int [1] ) [2]) When indexing foo, you index from outermost to innermost, so foo[1] means the second one-element array and foo[1][0] means the first element of the second one-element array.
Re: Why aren't Ranges Interfaces?
On Fri, 26 Jun 2015 19:26:56 +, Jack Stouffer wrote: Thanks for the reply! I understand the reasoning now. On Friday, 26 June 2015 at 18:46:03 UTC, Adam D. Ruppe wrote: 2) interfaces have an associated runtime cost, which ranges wanted to avoid. They come with hidden function pointers and if you actually use it through them, you can get a performance hit. How much of a performance hit are we talking about? Is the difference between using an interface and not using one noticeable? For some real numbers, a while back I wrote up several variations on a big data type process for a presentation on memory performance and the importance of cache hits. The classic Java-style class-based version ran in 4 seconds while the lazy range struct version ran in 0.83 seconds. Using LDC to inline (impossible with interfaces) brought the runtime down to 0.38 seconds.
Re: Return types of the methods of a struct
On Fri, 19 Jun 2015 13:27:13 +, Quentin Ladeveze wrote: Is there any way to have a asTuple method in this struct that would returns something like : Tuple!(int, a, float, b, string, c) and that will contain the values of the methods of the struct ? Thanks. You'll want to work your way through this example carefully as it's basically template-based functional programming, but I think does what you want: http://dpaste.dzfl.pl/b048ea3adb93
Re: Process a TypeTuple
On Mon, 15 Jun 2015 04:06:12 +, Baz wrote: On Monday, 15 June 2015 at 03:53:35 UTC, Yuxuan Shui wrote: Is it possible to apply some operation on every member of a TypeTuple, then get the result back? Say I have a TypeTuple of array types, and I want a TypeTuple of their element types, how could I do that? For this particular example you use std.range.ElementType: import std.typecons, std.range; alias Elements = staticMap!(ElementType, MyRangeOrArrayTypes);
Re: Casting MapResult
On Mon, 15 Jun 2015 15:10:20 +, jmh530 wrote: So I suppose I have two questions: 1) am I screwing up the cast, or is there no way to convert the MapResult to float[], 2) should I just not bother with map (I wrote an alternate, longer, version that doesn't use map but returns float[] properly). MapResult is a wrapper around your original range that performs the mapping operation lazily. If you want eagerly evaluate and get back to an array use the std.array.array function: import std.array : array; auto y = x.map!(a = exp(a)).array; Or if you have already allocated an array of the appropriate size you can use std.algorithm.copy: import std.algorithm : copy; float[] y = new float[](appropriate_length); x.map!(a = exp(a)).copy(y);
Re: Right after allocators: containers or database connectivity?
On Tue, 09 Jun 2015 10:05:24 -0700, Andrei Alexandrescu wrote: One would be a good pass of std.container, in particular (a) a design review with the DbI glasses on; (b) better documentation - sadly it seems to me so inadequate as to make containers themselves unusable; (c) investigate use of UFCS - std.container's design predates UFCS yet is a perfect fit for it, and most likely other cool language improvements we've added since. The other would be database connectivity. Erik Smith has shown some cool ideas at DConf, and I encourage him to continue working on them, but it seems to me this is an area where more angles mean more connectivity options. My vote would be for containers. At EMSI we do make heavy use of MySQL but have our own idiomatic D wrapper around the C library and would have little incentive to switch to a generic ODBC implementation.
Re: D looses in speed to Common Lisp
All those allocations aren't helping. Here's a much more idiomatic D version: import std.stdio, std.bigint; import std.range; void main() { int n = 10; auto fib1 = recurrence!(a[n-1] + a[n-2])(BigInt(0), BigInt (1)).takeExactly(n); auto fib2 = recurrence!(a[n-1] + a[n-2])(BigInt(0), BigInt (1)).takeExactly(n); BigInt sumFib1; foreach (e; fib1) sumFib1 += e; BigInt sumFib2; foreach (e; fib2) sumFib2 += e; writeln(sumFib2 - sumFib1); // 0 } Timing on my box: $ time ./fib 0 real0m1.520s user0m1.520s sys 0m0.000s Compiling with `ldmd2 fib.d -inline -noboundscheck -O -release`: $ time ./fib 0 real0m0.784s user0m0.776s sys 0m0.000s
Re: Baffled by compilation error for formattedRead
On Thu, 07 May 2015 23:10:26 +, PhilipDaniels wrote: Why do the first two fail to compile but the last one does?! I cannot see any difference between the 's2' case and the second case, it is a completely mechanical source code transformation I have made. formattedRead takes its input by ref and consumes it. Your first two attempts are both passing the result of functions (dropExactly and opSlice) which are temporary rvalues and can thus not be passed by reference. Here's more reading on the subject of rvalues: http:// ddili.org/ders/d.en/lvalue_rvalue.html
Re: Bitfield-style enum to strings?
On Thu, 07 May 2015 16:55:42 -0400, Nick Sabalausky wrote: // There's gotta be a better way to convert EnumMembers!T // to a range, right? But std.range.only() didn't work, // due to a template instantiation error. T[] members; foreach(m; EnumMembers!(T)) members ~= m; T[] members = [ EnumMembers!T ];
Re: Linker command
On Wed, 06 May 2015 19:52:42 +, Paul wrote: On Wednesday, 6 May 2015 at 19:30:33 UTC, anonymous wrote: On Wednesday, 6 May 2015 at 19:26:40 UTC, Paul wrote: but I don't understand the syntax. dmd --help mentions -Llinkerflag but what is '-L-L.' doing?? Passes '-L.' to the linker. :D I can see that, but what does '-L.' mean exactly? It adds '.' to the list of directories which the linker will search when looking for the required libraries.
Re: Good examples of value types
On Wed, 06 May 2015 16:54:46 +, Luís Marques wrote: * Regular expressions - I have no idea what you have in mind for this one; even after looking at std.regex... I meant both patterns and matches/captures. * Tokens - On the one hand, I think this could be an excellent example, since it's a case where the bit pattern is arbitrary (because it generally has no numeric properties). On the other hand, I could see people arguing that just using an int is perfectly fine, so it doesn't benefit from a custom type. Do notice that, even in D, an enum converts without a cast to an int, so the fact that an enum might be used to list the possible abstract values (the tokens) doesn't quite make it a completely independent type, IMHO. By tokens I mean the output of a lexer, usually looking like: struct Token { Type type; uint line, uint col; string captured; } * lazy generators - explain, please? Phobos is full of these. A simple example is the result of std.range.iota. The motivation is that a generator is actually an algorithm which happens to be wrapped up as a value. * digests - do you mean the digest output, or the digest function state? Certainly the output, haven't given much thought to the intermediate state. Frankly, the real divide in my mind is polymorphic/non-polymorphic, not by-reference vs by-value, though I will occasionally use `final class` if I want a convenience reference type around a resource. Aren't you arguing against yourself? In those cases you wanted your type to have reference semantics, even though it wasn't a polymorphic type. Doesn't that counterexample prove that polymorphic/non-polymorphic is just an heuristic, while the value/ref distinction is more fundamental? Ideally they're orthogonal, though you need reference types to do true dynamic polymorphism. Using `final class` is a pragmatic move given that D conflates reference types with polymorphic types, i.e. if there were a `ref struct` I'd use it.
Re: type switch
How's this? http://dpaste.dzfl.pl/d6643ec8ccd3
Re: Good examples of value types
On Tue, 05 May 2015 20:40:58 +, Luís Marques wrote: could you come up with some type that would really benefit from being a value type but that isn't numeric (or otherwise similar)? Dates, times, durations, regular expressions, tokens, lazy generators, digests, vectors, really any type that provides a interpretation/behavior wrapper around one or more trivially copyable types. Frankly, the real divide in my mind is polymorphic/non-polymorphic, not by-reference vs by-value, though I will occasionally use `final class` if I want a convenience reference type around a resource.
Re: [your code here] Rounding real numbers
Arrrg, formatting got torn up. Here's a Dpaste: http://dpaste.dzfl.pl/ca190950f199
[your code here] Rounding real numbers
A process for rounding numbers. This incarnation can be run like round 1.23 3.4 4 or by reading lines from stdin. It could be simplified as an example by getting rid of the argument-processing form. It shows off templated function composition using std.functional.pipe, ct-regexes, and component programming. I wrote this after realizing that there wasn't a convenient UNIX utility for doing this and use it regularly. - import std.algorithm, std.conv, std.functional, std.math, std.regex, std.stdio; // Transforms input into a real number, rounds it, then to a string alias round = pipe!(to!real, lround, to!string); // Matches numbers that look like they need rounding static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`; void main(string[] args) { // If arguments, process those and exit, otherwise wait around // for input on stdin if (args.length 1) args[1..$].map!round.joiner( ).writeln; else // Replace anything that looks like a real number with the // rounded equivalent. stdin.byLine(KeepTerminator.yes) .map!(l = l.replaceAll!(c = c.hit.round)(reFloatingPoint)) .copy(stdout.lockingTextWriter()); } -
Re: Example from d-idioms is incorrect
On Thu, 30 Apr 2015 21:30:34 +, TheGag96 wrote: Was the behavior of the remove() function changed recently? Thanks guys. I believe remove has always worked this way. What you're seeing is explained by this note in the documentation for remove: The original array has remained of the same length because all functions in std.algorithm only change content, not topology. The value 8 is repeated because std.algorithm.move was invoked to move elements around and on integers move simply copies the source to the destination. To replace a with the effect of the removal, simply assign a = remove(a, 1). The slice will be rebound to the shorter array and the operation completes with maximal efficiency.
Re: Create a case-insensitive startsWith
Note that my solution relies on the pre-release version of std.uni, those lazy functions aren't in the latest release.
Re: Create a case-insensitive startsWith
On Tue, 28 Apr 2015 21:45:07 +, PhilipDaniels wrote: Beginner question. Given if (startsWith(input, 0x, 0X)) How do I turn that into a case-insensitive startsWith? startsWith says it takes a predicate but I can't figure out how to pass it one. The examples all use a == b !? These attempts below, and other things I have tried, fail with cannot deduce function from argument types. if (startsWith!icmp(a, b) == 0(input, 0x)) if (startsWith!std.uni.icmp(a, b) == 0(input, 0x)) if (startsWith!((a,b) = icmp(a,b) == 0)(input, 0x)) The issue is that those icmp functions take strings as arguments while startsWith expects the predicate to take individual characters. I believe the best solution here is to use the lazy toLowerCase function in std.uni and the default predicate: if (startsWith(input.toLowerCase, 0x.toLowerCase))
Re: Readonly-to-outside variable
On Tue, 28 Apr 2015 19:30:04 +, tcak wrote: Is there any way to define a variable or an attribute as read-only without defining a getter function/method for it? Thoughts behind this question are: 1. For every reading, another function call process for CPU while it could directly read the value from memory. 2. Repetition of same name for variable and getVariableName. (Some might not agree with this but I like the code when it looks nice.) 1. I wouldn't worry too much about the performance--compiling with gdc or ldc with inlining should reduce it to a simple access. 2. You can clean it up if it annoys you with something like this: mixin template readonly(T, string name) { mixin(`private T _`~name~`;T `~name~`()@property{return _`~name~`;}`); } Use it like: class Foo { // injects a private int _x, public int x() mixin readonly!(int, x); }
Re: Interrogative: What's a good blog title?
On Mon, 27 Apr 2015 23:30:11 +, Anonymouse wrote: assumeBlog Or perhaps, getting D-syntax specific, assumeUnique(wisdom)
Re: Interrogative: What's a good blog title?
On Mon, 27 Apr 2015 15:54:09 -0700, Andrei Alexandrescu wrote: the metareferential You Are Reading This Blog's Title is perhaps intriguing but difficult to talk about). Any thoughts? If you like meta-meta-referential, The Latter of the Two Hardest Things[1] The Internet Anagram Server, when fed Alexandrescu suggests Caldera Nexus or possibly Sexual Dancer, pick the more appropriate. [2] [1] http://martinfowler.com/bliki/TwoHardThings.html [2] http://wordsmith.org/anagram/anagram.cgi? anagram=alexandrescut=1000a=n
Re: Example for Documentation?
On Tue, 21 Apr 2015 18:34:35 +, Chris wrote: Yeah, but I have to ask a stupid question. How do I add a PR? I've never done it before. This wiki page will walk you through it: http://wiki.dlang.org/Pull_Requests
Re: Structural exhaustive matching
On Tue, 21 Apr 2015 15:36:27 +, Jadbox wrote: What's the best equivalent to Rust's structural enum/pattern (match)ing? Is it also possible to enforce exhaustive matches? Basically, I'm curious on what the best way to do ADTs in D. std.variant.Algebraic implements ADTs: import std.variant, std.string; struct Foo { ... } alias A = Algebraic!(int, double, Foo); A a = 1; // std.variant.visit enforces that all possible types are handled, so this // is an error: auto res = a.visit!( (int x) = format(Got an int: %s, x), (double x) = format(Got a double: %s, x), (Foo x) = Got a Foo ); You can also dispatch to a function with the appropriate overloads/ template instantiations like so: foreach (T; A.AllowedTypes) if (a.type is typeid(T)) myfunc(a.get!T); This also exhaustively guarantees that myfunc can be called with all possible types of a.
Re: Duplicate another function's parameters in a template function
On Mon, 20 Apr 2015 22:50:52 +, Tofu Ninja wrote: I am trying to write a template function that can take another function as an alias template argument and duplicate its parameters for it self. I tried.. auto pass(alias f, T...)(T t) { // other stuff... return f(t); } but that does not work if there is a ref parameter. Thanks See std.functional.forward: http://dlang.org/phobos/std_functional.html#.forward
Re: ctags
On Mon, 20 Apr 2015 20:14:34 +0200, Robert M. Münch wrote: Hi, is there anything for D that supports generating tags files like ctags does for C etc. ? Dscanner: https://github.com/Hackerpilot/Dscanner#ctags-output
Re: EMSI is hiring a D developer
On Wed, 15 Apr 2015 07:27:49 +, Abdulhaq wrote: On Tuesday, 14 April 2015 at 16:17:37 UTC, Justin Whear wrote: EMSI is hiring for an Engineer II to work on D codebases: https:// emsi.bamboohr.com/jobs/view.php?id=30 When it said Moscow I was thinking mmmh lots of traffic, a bit difficult to live in then I saw it was Moscow, Idaho. We have traffic! If I leave work at exactly 5 it takes me an extra three minutes to get home!
Re: How about appender.put() with var args?
Appender will take a range, so you can also do: app.put([foo, var, bar]); or app.put(chain(foo, var, bar)); But yes, a variadic put would be convenient so long as it wasn't ambiguous in some way.
Re: EMSI is hiring a D developer
On Wed, 15 Apr 2015 20:11:39 +, Ola Fosheim Grøstad wrote: That fact puts Orwell's writings in a new light. Oooh, an Animal Farm reference; spooky.
Re: Pitching an investment bank on using D for their bond analytics
On Tue, 14 Apr 2015 12:08:53 +, D Denizen since a year wrote: I lead a group that uses D pretty much 100% for a number of different kinds of projects, so I've seen many sides to D's advantages. That said, I don't enough about investment banking analytics to know exactly what they value. Here are some suggestions: What are the sine qua nons of the project? * Are there hard performance requirements? * Are there specific hardware requirements? * Are there software/library requirements (e.g. you must use our proprietary ...) These are areas where you must prove that D is adequate, but not necessarily where you should focus. What characterizes 80% of the code? * Large linear algebra problems? * High-level business logic that needs to be maintained by an analyst? * Database operations? As an example, if the high-level business logic is the bulk of the codebase, demonstrate how D's cleaner syntax lowers the bar for code review by analysts. Show how UFCS and pipeline programming allow intuitive and highly-legible composition. Find some key pain points that D is particularly amenable to solving. If you can list a few of these sorts of points I might have more concrete suggestions. Cheers Justin
EMSI is hiring a D developer
EMSI is hiring for an Engineer II to work on D codebases: https:// emsi.bamboohr.com/jobs/view.php?id=30
Re: Float to string with more digits?
On Tue, 24 Feb 2015 20:04:04 +, Almighty Bob wrote: Is there a more accurate way to do a float and or double to string than... to!string(float); As that seems to limit itself to 6 digits. Use std.string.format or std.format.formattedWrite. std.format contains a description of the various format specifiers. You'll probably want something like %.12f, which formats a floating point number with 12 digits of precision.
Re: Let's Play Code Golf
On Mon, 23 Feb 2015 20:21:19 +, Charles wrote: My solution (150 characters, 15 points): void main(){import std.stdio;int t,n;readf( %d,t);while(t--){readf( %d,n);real a=0,i=0;for(;in;i++)a+=(i%2?-1:1)/(i+i+1);writefln(%.15f,a);}} Link to problem site: https://www.hackerrank.com/challenges/leibniz Anyone care to do better? :) Minor refactorings of your solution to get 15.7: https:// www.hackerrank.com/challenges/leibniz/submissions/code/11073459 Dirty solution (read and decrement a real as if it's a int), but passes the test cases.
Re: DIP56 - inlining
On Tue, 03 Feb 2015 23:34:15 +, an wrote: Pragmas can be used as attribute that doesn't affect the semantics. This syntax is not supported in this DIP? pragma(inline, true) { void foo() { } void bar() { } } I assume it's covered by If this pragma is outside of a function, it affects the functions in the block it encloses.
Re: About variant
On Tue, 27 Jan 2015 20:46:59 +, bioinfornatics wrote: void main(){ auto a = Alpha!(int)( 6); auto b = Alpha!(string)( hello); The Alpha struct is not a template, only the constructor is. Remove the explicit instantiations and IFTI does the work: void main(){ auto a = Alpha( 6); auto b = Alpha( hello);
Re: [WORK] groupBy is in! Next: aggregate
On Fri, 23 Jan 2015 10:08:30 -0800, Andrei Alexandrescu wrote: So H.S. Teoh awesomely took https://github.com/D-Programming-Language/phobos/pull/2878 to completion. We now have a working and fast relational group by facility. This is great news. It seems like every time I make use of component programming, I need groupBy at least once. I have a D file with an old copy of a groupBy implementation (I think it's Andrei's original stab at it) and it gets copied around to the various projects.
Re: sortUniq
On Thu, 22 Jan 2015 13:40:56 -0800, Andrei Alexandrescu wrote: There's this classic patter on Unix: |sort|uniq, i.e. sort some data and only display the unique elements. What would be a better integrated version - one that does sorting and uniq in one shot? I suspect the combination could be quite a bit better than doing the two in sequence. A few google searches didn't yield much. Ideas? Thanks, Andrei Efficiency improvement-wise, perhaps a generalization of a counting sort (http://en.wikipedia.org/wiki/Counting_sort), see Variant algorithms.
Re: Data-Oriented Demo: SOA, composition via crazy 'using'
On Thu, 22 Jan 2015 21:04:04 +, Kiith-Sa wrote: Could you put this up on GitHub/dub? Even if simple this could be very useful. Added some features and a dynamic array implementation, put it up here: https://github.com/economicmodeling/soa
Re: generate an array of 100 uniform distributed numbers
On Thu, 22 Jan 2015 19:26:44 +, ddos wrote: hi guys, firstly this has no direct application, i'm just playing around and learning i want to create 100 uniform distributed numbers and print them my first attempt, just written by intuition: [0 .. 100].map!(v = uniform(0.0, 1.0).writeln); i found out i can't write [0 .. 100] to define a simple number range, but is there a function to do so? The iota function from std.range: iota(0, 100).map!(...) second attempt, replacing the range with an simple array [0,1,2].map!(v = uniform(0.0,1.0).writeln); this does compile and run, but doesn't print anything, just an empty string, why is that? Two issues: 1) The function supplied to map should be a projection function, e.g. it takes a value and returns a value. Your lambda returns void (the result of writeln). 2) map is lazy--it doesn't do any work until something consumes it. This is awesome for many reasons (e.g. you can process infinite ranges). Nothing in your code is causing the result of map to be consumed, so it does no work. finally i got it working with this: auto t = [0,1,2].map!(v = uniform(0.0,1.0)); writeln(t); This works because writeln eagerly consumes the result of map, causing the work to actually be done. If you like, you can tack the writeln to the end of the pipeline: auto t = [0,1,2].map!(v = uniform(0.0,1.0)).writeln;
Re: Data-Oriented Demo: SOA, composition via crazy 'using'
On Thu, 22 Jan 2015 18:03:31 +, Justin Whear wrote: On Thu, 22 Jan 2015 17:40:17 +, Justin Whear wrote: I just whacked this out in D: http://dpaste.dzfl.pl/90d96cf05792 Remembered the allMembers trait, using a pointer to parent, etc: http:// dpaste.dzfl.pl/6fd66ae9b767 OK, I'm done now. 100% better: http://dpaste.dzfl.pl/4ac987a0fc5a
Re: Data-Oriented Demo: SOA, composition via crazy 'using'
On Thu, 22 Jan 2015 17:40:17 +, Justin Whear wrote: I just whacked this out in D: http://dpaste.dzfl.pl/90d96cf05792 Remembered the allMembers trait, using a pointer to parent, etc: http:// dpaste.dzfl.pl/6fd66ae9b767
Re: Data-Oriented Demo: SOA, composition via crazy 'using'
On Wed, 21 Jan 2015 19:12:20 +, Fool wrote: Jonathan Blow published another video [1] presenting the progress of his language. He is treating two main topics: - a keyword preliminary called 'using' which seems to be quite close to 'alias this'; - an annotation SOA for pointers and arrays which allow high level treatment of structures of arrays; Jonathan does not seem to be aware of 'alias this' in D. I just whacked this out in D: http://dpaste.dzfl.pl/90d96cf05792 The string mixin for the members is only necessary because there's no other way to initialize the arrays (can't use parameterless constructor, no init() function, etc.)
Re: For those ready to take the challenge
On Fri, 09 Jan 2015 13:50:28 +, eles wrote: https://codegolf.stackexchange.com/questions/44278/debunking- stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro Was excited to give it a try, then remembered...std.xml :(
Re: For those ready to take the challenge
On Fri, 09 Jan 2015 17:18:42 +, Adam D. Ruppe wrote: Huh, looking at the answers on the website, they're mostly using regular expressions. Weaksauce. And wrong - they don't find ALL the links, they find the absolute HTTP urls! Yes, I noticed that. `script src=http://app.js`/script` isn't a hyperlink. Wake up sheeple!
Re: Game development
On Thu, 08 Jan 2015 23:02:26 +0200, ketmar via Digitalmars-d wrote: but yes, i want to create an impression that timewasters are not welcome. Ironically this is exactly why I'm putting you on my ignored authors list. --Justin
Re: string concatenation with %s
On Wed, 07 Jan 2015 16:38:23 +, Suliman wrote: I except that writefln have some behavior as string concatenation, but it does not. IS there any way to put needed values in place of %s in string? std.string.format interpolates string with the same behavior as writefln but returns the resulting string instead of printing it.
Re: Conditional functions
On Mon, 05 Jan 2015 17:47:09 +, Dominikus Dittes Scherkl wrote: Is it possible to use static if in a template structure to have some member functions only for specific types? Yep. This is actually a frequently used pattern in functions that return ranges.
How to share modules when using -shared?
I'm trying to build components that I can dynamically link and keep running into an issue with sharing modules between the host and the pluggable components. Assuming a layout like this: host.d -- loads components at runtime a.d -- a module that builds to `a.so` b.d -- a module that builds to `b.so` common.d If a.d and b.d both import common.d, all is well. If host.d imports common.d as well, I get this at runtime: Fatal Error while loading 'a.so': The module 'common' is already defined in 'host'. Test session with sources here: http://pastebin.com/LxsqHhJm Some of this can be worked around by having host.d use its own extern definitions, but how does this work with interfaces? My tests thus far have resulted in object invariant failures.