Re: How to Unqual an array?
On 11/16/19 10:20 AM, James Blachly wrote: On 11/16/19 9:48 AM, James Blachly wrote: I am trying to write templated code that will take a character array -- mutable, const, or immutable (string). I am aware of isSomeString, but I am still curious about Unqual array from a learning perspective. Thank you both Steve and Anonymouse! Regarding Steve's comment -- this should be made clear in documentation no? Regarding Anonymouse's code snippet, I've definitely saved that for future. thank you. James
druntime 2.087 regression? (was: Old codebase stops compiling at 2.087)
TL;DR druntime regression? https://gist.github.com/jblachly/78c5762bbfea65b09e7a1417ad763019 --- Our team has an older codebase that compiled fine up until frontend version 2.087 (builds with 2.086.1). Now, compiler (DMD2 and LDC2) complains about implicit conversion of shared(AA) to const(shared(AA)). The codebase is private (could possibly make it public soon) but the error involves an AA inside a shared struct. ``` /home/james/dmd2.087/dmd2/linux/bin64/../../src/druntime/import/object.d(3453,36): Error: cannot implicitly convert expression aa of type shared(GSeqAllele[string]) to const(shared(GSeqAllele)[string]) source/polytyper/gseq.d(231,33): Error: template instance `object.values!(shared(GSeqAllele[string]), shared(GSeqAllele), string)` error instantiating /home/james/dmd2.087/dmd2/linux/bin64/../../src/druntime/import/object.d(3402,36): Error: cannot implicitly convert expression aa of type shared(GSeqAllele[string]) to const(shared(GSeqAllele)[string]) source/polytyper/gseq.d(280,35): Error: template instance `object.keys!(shared(GSeqAllele[string]), shared(GSeqAllele), string)` error instantiating ``` (line breaks added for clarity) The two triggering lines both iterate over a built-in AA gseq.d:231:foreach (a; this.alleles.values) gseq.d:208:foreach (key; this.alleles.keys) Looking at the changelog for 2.087 ( https://dlang.org/changelog/2.087.0.html ) I do not see any obvious culprits. git blame suggests this is the responsible commit: https://github.com/dlang/druntime/commit/af86e7db58f4b792e45bdc3ee43c17aadc9d54ab#diff-a68e58fcf0de5aa198fcaceafe4e8cf9L3430-R3454 From this change, it looks like the runtime now cannot handle a shared AA -- is this right? A minimal reproducible example is here: https://gist.github.com/jblachly/78c5762bbfea65b09e7a1417ad763019 Thanks in advance for help James PS: Why is this commit ("object: Declare private struct AA and fix aaA function signatures ") not mentioned in the changelog?
Re: D vs Java which is more powerful
On Saturday, 16 November 2019 at 22:25:46 UTC, bauss wrote: On Saturday, 16 November 2019 at 07:24:50 UTC, GreatSam4sure wrote: [...] Java as a language in itself is not more powerful than D regardless of opinions. [...] Thanks, I am really shock about the claim that Java is move powerful than D since I have a working knowledge of both languages. You are right in your analysis. Thanks
Re: druntime 2.087 regression? (was: Old codebase stops compiling at 2.087)
On 11/17/19 10:45 AM, James Blachly wrote: /home/james/dmd2.087/dmd2/linux/bin64/../../src/druntime/import/object.d(3453,36): Error: cannot implicitly convert expression aa of type shared(GSeqAllele[string]) to const(shared(GSeqAllele)[string]) There's a subtle removing of the shared from the entire AA. Is that on purpose? i.e. I see shared(GSeqAllele[string]) in one, and shared(GSeqAllele)[string] in another. -Steve
dmd memory usage
I'm fighting some out of memory problems using DMD and some super-template heavy code. I have ideas on how to improve the situation, but it involves redesigning a large portion of the design. I want to do it incrementally, but I need to see things improving. Is there a straightforward way to figure out how much memory the compiler uses during compilation? I though maybe /usr/bin/time, but I feel like I don't trust the output to be the true max resident size to be what I'm looking for (or that it's 100% accurate). Is there a sure-fire way to have DMD print it's footprint? -Steve
Re: dmd memory usage
On Monday, 18 November 2019 at 00:20:12 UTC, Steven Schveighoffer wrote: Is there a straightforward way to figure out how much memory the compiler uses during compilation? So this isn't a great solution but what I have done in the past is just have a little script running ps aux | grep dmd sleep 1 # or whatever time you want in a loop running in the background to gather some data as it goes. If combined with dmd -v you can interpolate the -v and ps output to get an idea of what the memory use is at a certain point of what the compiler is working on. again i know it isn't great but it is easy to play with and better than nothing
Re: dmd memory usage
On Monday, 18 November 2019 at 00:20:12 UTC, Steven Schveighoffer wrote: I'm fighting some out of memory problems using DMD and some super-template heavy code. I have ideas on how to improve the situation, but it involves redesigning a large portion of the design. I want to do it incrementally, but I need to see things improving. Is there a straightforward way to figure out how much memory the compiler uses during compilation? I though maybe /usr/bin/time, but I feel like I don't trust the output to be the true max resident size to be what I'm looking for (or that it's 100% accurate). Is there a sure-fire way to have DMD print it's footprint? -Steve Hello, You can look at http://man7.org/linux/man-pages/man2/getrusage.2.html But, probably /usr/bin/time already use it.
Parsing with dxml
I can only parse one row successfully. I tried increasing the popFronts, till it said I'd gone off the end. Running ./app core.exception.AssertError@../../../../.dub/packages/dxml-0.4.1/dxml/source/dxml/parser.d(1457): text cannot be called with elementEnd ??:? _d_assert_msg [0x104b3981a] ../../JMiscLib/source/jmisc/base.d:161 pure @property @safe immutable(char)[] dxml.parser.EntityRange!(dxml.parser.Config(1, 1, 1, 1), immutable(char)[]).EntityRange.Entity.text() [0x104b2297b] source/app.d:26 _Dmain [0x104aeb46e] Program exited with code 1 ``` http://www.w3.org/2001/XMLSchema-instance";> 01001001 1 1 1 In the beginning God created the heavens and the earth. 01001002 1 1 2 And the earth was waste and void; and darkness was upon the face of the deep: and the Spirit of God moved upon the face of the waters. ``` ```d void main() { import std.stdio; import std.file : readText; import dxml.parser; import std.conv : to; struct Verse { string id; int b, c, v; string t; } auto range = parseXML!simpleXML(readText("xmltest.xml")); // simpleXML skips comments void pops(int c) { foreach(_; 0 .. c) range.popFront(); } pops(3); Verse[] vers; foreach(_; 0 .. 2) { Verse ver; ver.id = range.front.text; pops(3); ver.b = range.front.text.to!int; pops(3); ver.c = range.front.text.to!int; pops(3); ver.v = range.front.text.to!int; pops(3); ver.t = range.front.text; with(ver) vers ~= Verse(id,b,c,v,t); pops(2); } foreach(verse; vers) with(verse) writeln(id, " Book: ", b, " ", c, ":", v, " -> ", t); } ```