Re: Real implicitly converts to float?
On Wednesday, 22 June 2016 at 14:17:42 UTC, Jonathan M Davis wrote: Well, that particular value should probably work thanks to VRP (value range propagation), since 10 can fit into float with no loss of precision. However, what's far more disconcerting is that real x = real.max; float y = x; compiles. real to float is a narrowing conversion, which should be an error barring the compiler detecting that the value will fit in the target type even if it's a narrowing conversion (which only happens with VRP). That's not the sort of thing that I would have expected to be broken such that it begs the question as to whether it's intentional, but given that narrowing conversions without a cast are illegal everywhere else, this definitely seems broken. - Jonathan M Davis Should I make a bug report? I am not sure it's a bug, seems intentional. Maybe a dip for a compiler flag to warn on implicit down conversions, but it would be a pretty small dip.
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 19:20:30 UTC, jmh530 wrote: I will touch dub, but I still felt like shouting "well then why doesn't the next edition of Learning D just tell people to look at some D source code and figure it out" when I saw that... What are you referring to? I think dub is a great project; it just needs a some work on docs/examples/tutorials if it is going to get included with DMD. Then pitch in! There are already several examples in the DUB repository. If you think there should be more, create an issue. If you find documentation missing, report it. I wouldn't imagine the Sönke by himself can think of every conceivable scenario someone might need info on, or where the documentation isn't clear enough. Things can't improve unless people let the maintainer know what is missing and, if possible, contribute it themselves.
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 19:00:56 UTC, bachmeier wrote: On Wednesday, 22 June 2016 at 15:48:03 UTC, Mike Parker wrote: Suppose you need to link against a .so file that is in another directory. How do you find out how to do that on this page: http://code.dlang.org/package-format?lang=json But that's just one case. There are basically no examples at all (and the ones that are there probably don't help). There's not even a good explanation of what Dub is. Rust, on the other hand, offers this: http://doc.crates.io/guide.html If there's no dub option for it, then wouldn't you just pass it to the compiler in a dflags directive? That's basic compiler usage, is it not? This is not to criticize anyone's work. But it is to say that there is no way Dub, with its current documentation, should be distributed with DMD. Then why not pitch in to help improving the documentation? If you think there should be something explaining how to find shared libraries in another directory and can't find it anywhere, you can go to the DUB issues page and report it, or ask in the DUB forums how to contribute. That's how things get better around here.
[Issue 16094] error: overlapping slice assignment (CTFE)
https://issues.dlang.org/show_bug.cgi?id=16094 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/560f606ae94af80881606a5a8151a3cacb1b5d30 fix Issue 16094 - error: overlapping slice assignment (CTFE) https://github.com/dlang/dmd/commit/20e1c81ec0642b80413c1093702e5ae8d5fde313 Merge pull request #5827 from 9rnsr/fix16094 Issue 16094 - error: overlapping slice assignment (CTFE) --
Re: Get specific item by index from DList
On Wed, Jun 22, 2016 at 10:49:54PM +, TheDGuy via Digitalmars-d-learn wrote: > On Wednesday, 22 June 2016 at 22:25:21 UTC, lmpo wrote: > > On Wednesday, 22 June 2016 at 22:10:09 UTC, TheDGuy wrote: > > > Hi, > > > > > > i am currently programming a small game with GTKD and i have to > > > use a Dlist because an array is static > > > > Static ? An array is not static. a DList is only interesting when > > you have to insert or remove inside the list i.e not at the back. If > > the container grows always from the back than you should rather use > > an array. > > Thanks a lot for your answer. The main reason why i switched the DList > is, that i have to initialize an array with a fixed length but it is > important for me that the length-value of the property of the array is > not the maximum length but the amount of indexes which actually > contain values. I don't know how i could do this without creating an > extra variable? Take a look at: https://dlang.org/spec/arrays.html In particular, at the .reserve() method and .capacity property of arrays. It sounds like what you want is to call .reserve on the array but keep its length at 0 when you first initialize it. This way you don't need to keep an "extra variable" around. T -- When solving a problem, take care that you do not become part of the problem.
Re: How to use a char[] buffer in D
On Wed, Jun 22, 2016 at 09:57:04PM +, Andrew Chapman via Digitalmars-d-learn wrote: > Hi everyone, just wanting some help with optimisation if anyone is > kind enough :-) > > I have a loop that iterates potentially millions of times, and inside > that loop I have code that appends some strings together, e.g.: > > string key = s1 ~ "_" ~ s2; > > I discovered that due to the memory allocation required, this slows > the execution significantly. > > s1 is always a two character string, e.g "AA", and s2 is always a > single character. Yes, frequent allocation of small strings is a performance killer. Using a static array (as you've done below) is much better. > What I want to do is something like this: > > Outside the loop: > > char[4] buffer; > buffer[2] = '_'; > > Then inside the loop > > buffer[0] = s1[0]; > buffer[1] = s1[1]; > buffer[3] = s2[0]; > > This works OK, however, I then need to use the buffer value to check > for an existing value in a hashmap / associative array. > > Code such as: > > if(buffer in myHash) { > > } > > throws an access violation. A string value works without error. Is > there a way for me to use a buffer AND use it in functions expecting > strings? Maybe try: if (buffer[] in myHash) { ... } ? Does that make a difference? T -- This sentence is false.
Re: Get specific item by index from DList
On Wednesday, 22 June 2016 at 22:10:09 UTC, TheDGuy wrote: Hi, i am currently programming a small game with GTKD and i have to use a Dlist because an array is static Static ? An array is not static. a DList is only interesting when you have to insert or remove inside the list i.e not at the back. If the container grows always from the back than you should rather use an array.
[Issue 11167] Slicing a pointer can't be @safe.
https://issues.dlang.org/show_bug.cgi?id=11167 David Nadlingerchanged: What|Removed |Added Keywords||safe --
Re: How to use a char[] buffer in D
On 06/22/2016 02:57 PM, Andrew Chapman wrote: > Code such as: > > if(buffer in myHash) { > > } > > throws an access violation. A string value works without error. Does it throw an exception? Can you reproduce the issue with a short program? Ali
Get specific item by index from DList
Hi, i am currently programming a small game with GTKD and i have to use a Dlist because an array is static but i want to add user inputs dynamically to a list. Now i am wondering how i can get a specific item from that list? I read that this isn't possible but is it possible to convert that DList temporarily to an array to get a specific element? My DList just contains integer values, anyone who could offer a short code example? This doesn't work: to!Array(level,int,userInput)[i]) Level is the length of the list, int is the type and userInput is the DList.
Re: Is dmd fast?
On 6/22/2016 7:28 AM, Adam D. Ruppe wrote: On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: RDMD 0:00:00.275884 DMD 0:00:00.311102 Since rdmd is just a script wrapper around dmd, it shouldn't actually be faster. rdmd caches "script" programs, so could be faster. BTW this more measures linker speed than compiler. dmd -c -o- just runs the compiler and skips filesystem output... it'd be pretty fast and if there's similar options for other compilers (gcc has -c too at least) it might be better for small programs. Larger programs I think is fair to include the link step, since it should be less a percentage there and you do need to run it anyway. Also, "hello world" is just a handful of lines of code. Measuring compile speed with this is measuring the time it takes to load dmd off of the disk, initialize, etc., rather than time spent compiling. It's a constant added to overall time. "hello world" also imports object.d and std.stdio, both of which have a tendency to accrete barnacles which slows down compilation by another constant.
How to use a char[] buffer in D
Hi everyone, just wanting some help with optimisation if anyone is kind enough :-) I have a loop that iterates potentially millions of times, and inside that loop I have code that appends some strings together, e.g.: string key = s1 ~ "_" ~ s2; I discovered that due to the memory allocation required, this slows the execution significantly. s1 is always a two character string, e.g "AA", and s2 is always a single character. What I want to do is something like this: Outside the loop: char[4] buffer; buffer[2] = '_'; Then inside the loop buffer[0] = s1[0]; buffer[1] = s1[1]; buffer[3] = s2[0]; This works OK, however, I then need to use the buffer value to check for an existing value in a hashmap / associative array. Code such as: if(buffer in myHash) { } throws an access violation. A string value works without error. Is there a way for me to use a buffer AND use it in functions expecting strings? I can use idup() on the char[] to make a string, but again we're allocating memory which I'd rather avoid. Thanks sincerely in advance, Cheers, Andrew.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 19:56:26 UTC, Adam D. Ruppe wrote: D compile speed typically *scales* better than the competition. Instead of chasing the 100ms in hello world, it tackles the 1ms of a real project. Ok, but this is hard to test. It is not feasible to build the same real project in many languages. Generating programs might work. They would not be very realistic, but it gives a sense of scaling.
[Issue 16192] std.conv.toChars() opSlice wrong for radix other than 10
https://issues.dlang.org/show_bug.cgi?id=16192 ag0ae...@gmail.com changed: What|Removed |Added Keywords||pull CC||ag0ae...@gmail.com Assignee|nob...@puremagic.com|ag0ae...@gmail.com --- Comment #1 from ag0ae...@gmail.com --- https://github.com/dlang/phobos/pull/4457 --
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 19:25:13 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 19:20:42 UTC, deadalnix wrote: You methodology is flawed. You are essentially measuring link time against the standard lib. As someone else in the thread alluded to, people don't care about the nuance, and it's not particularly important. Linking is part of the compilation process that people have to wait for before their program can run. So if linking is slow, then compilation is slow. If you are to include link time in the measurement, you need to make sure that link time are representative of typical link time in real life applications. This require an application sufficiently large (and then you run into problem as to assert how similar applications are). In this case, one is essentially measuring the size of the standardlib rather than the speed of the compiler. There are much better way to measure the size of the standard lib than measuring how long the linker take to go through it.
[Issue 14662] __FILE__ template parameter becomes relative just by changing compilation directory
https://issues.dlang.org/show_bug.cgi?id=14662 Johan Engelenchanged: What|Removed |Added CC||jbc.enge...@gmail.com --- Comment #1 from Johan Engelen --- Using __FILE__ as template parameter is definitely bug-prone. Related forum discussion: https://forum.dlang.org/thread/induraqegvpyomvzx...@forum.dlang.org --
[Issue 16194] auto return type inference depends on return statement order
https://issues.dlang.org/show_bug.cgi?id=16194 --- Comment #2 from ZombineDev--- No, I think this is specific only to class sub-typing. For example the following compiles successfully and prints "4", "3.4" and "99". In other words, it actually finds the common type of all return statements (in this case - double) void main() { import std.stdio; fun(2).writeln(); fun(4).writeln(); fun(6).writeln(); } auto fun(int a) { if (a < 3) return 4; else if (a < 5) return 3.4; else return 'c'; } I'm not particularly bothered by this deficiency of the compiler, just wanted to report it. Also note that this deficiency is does not affect type inference of array literals: void main() { import std.stdio; [1, 'c', 3.4].writeln(); [2.3, 'c', true].writeln(); ['c', 2, 3.5].writeln(); [new A(), new B(), new C()].writeln(); [new B(), new A(), new C()].writeln(); [new C(), new B(), new A()].writeln(); } class A {} class B : A {} class C : A {} Prints: 1, 99, 3.4] [2.3, 99, 1] [99, 2, 3.5] [test.A, test.B, test.C] [test.B, test.A, test.C] [test.C, test.B, test.A] --
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 19:25:13 UTC, Jack Stouffer wrote: So if linking is slow, then compilation is slow. But, 1/3 second isn't slow... I don't feel compilation is slow until it takes more like 5 seconds. Certainly, 1/3s is noticable (if you do a hello world with printf instead of writeln you can feel the difference btw), but it isn't important. D compile speed typically *scales* better than the competition. Instead of chasing the 100ms in hello world, it tackles the 1ms of a real project.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 19:25:13 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 19:20:42 UTC, deadalnix wrote: You methodology is flawed. You are essentially measuring link time against the standard lib. As someone else in the thread alluded to, people don't care about the nuance, and it's not particularly important. Linking is part of the compilation process that people have to wait for before their program can run. So if linking is slow, then compilation is slow. you can dramatically decrease linking times by switching from libphobos2.a to libphobos2.so.
Re: Initialise dynamic array in array of structures
On Wednesday, 22 June 2016 at 09:27:01 UTC, cym13 wrote: what i meant is that "{}" should be fully equivalent to "Struct()" ctor in terms of calling postblits, and it isn't.
Re: Initialise dynamic array in array of structures
On Wednesday, 22 June 2016 at 09:27:01 UTC, cym13 wrote: On the other hand I don't see why you'd expect {} to call postblit at all. 'cause it essentially makes a copy. i gave the sample in bugreport. it worth me a hour of debugging to find why my refcounted struct keep crashing with invalid counter.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 19:20:42 UTC, deadalnix wrote: You methodology is flawed. You are essentially measuring link time against the standard lib. As someone else in the thread alluded to, people don't care about the nuance, and it's not particularly important. Linking is part of the compilation process that people have to wait for before their program can run. So if linking is slow, then compilation is slow.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: Walter and we as a community often claim that dmd is fast as in "compiles quickly". Go also claims this. Rust does not. They even state that compilation speed is one of the big tasks they are working on. From the general sentiment, I would expect that dmd performs on the level of Go and Rust being slower. Now, D as a language supports arbitrary compile-time computation so dmd can be arbitrarily slow. We need to look at the benchmark carefully. I started with the canonical Hello World. Here are some numbers: Dash 0:00:00.002366 Bash 0:00:00.002474 TCC 0:00:00.007044 Python2 0:00:00.009881 Python3 0:00:00.015547 GCC 0:00:00.028578 Go 0:00:00.149691 Rust 0:00:00.212053 RDMD 0:00:00.275884 Haskell 0:00:00.310539 DMD 0:00:00.311102 Java 0:00:00.596517 Scala0:00:01.917606 X10 Java 0:00:02.484673 X10 C++ 0:00:03.887826 Hm, Rust is faster than dmd? Go is roughly twice as fast as dmd? Destroy! But run your own numbers first: https://github.com/qznc/hello-benchmark ;) You methodology is flawed. You are essentially measuring link time against the standard lib.
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 19:00:56 UTC, bachmeier wrote: I will not touch Dub because I can't tell others that they should figure out how to use it by looking at the insides of existing packages and then fiddling around with various configurations to see if they can get it to work. I will touch dub, but I still felt like shouting "well then why doesn't the next edition of Learning D just tell people to look at some D source code and figure it out" when I saw that... I think dub is a great project; it just needs a some work on docs/examples/tutorials if it is going to get included with DMD.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 14:11:12 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: ... Including scripting languages in that example is unfair as they only lex the file. Right away you can tell that "Hello World" is a poor example of fast compile times because GCC is near the top; (as you probably know) large Cpp projects can have half hour to an hour long build times. Large projects are way faster to compile using dmd. From a marketing standpoint, you want simple things to compile fast. Ain't nobody gonna create big applications in multiple languages to see which one compiles faster. They will most likely go a little bit further than hello world, if they know what they are doing. Testing things that shows lexing speed, linking speed, etc, but they aren't gonna do complicated stuff.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 14:28:28 UTC, qznc wrote: Rust faster than Go? That still seems weird. I like your overall benchmark. Measuring build times there seems like a good idea. I'm more surprised that Go is faster than D.
Re: Phobo's migration
On Wednesday, 22 June 2016 at 16:44:25 UTC, Joerg Joergonson wrote: How bout Freezing Phobos, except for bugs and start migrating it to Phobos 2.0?. phobos is already 2.0. It has the same version as the compiler it's distributed with. For someone who has "so ambitious plans" for phobos you should at least know that ;) [...]
Re: Phobo's migration
On Wednesday, 22 June 2016 at 17:55:11 UTC, Joerg Joergonson wrote: How is that? That makes no sense. If Phobo's is production ready as claimed then freezing it can't make it automagically non-production ready, can it? D cannot afford to be stagnant in a time of fierce language competition. C++ almost died off completely outside of a couple of niches because it stood still for so long. D does not have the momentum to carry it for even a half year of no improvements. I didn't say they wernt, but they are being done on phobos Honest question: have you ever looked into Kaizen and lean management https://en.wikipedia.org/wiki/Kaizen? Because stopping everything in Phobos and waiting for "breakthroughs" is a dead on arrival plan. A continuous improvement process is much more viable, realistic, and likely to produce good results. That's what the D development process does without even being explicit about it. Each release is better than the last one. Perfect? Never. Better? Always. which is suppose to be done. The fact that Stopwatch, Monotime, TickDuration are all screwed up, etc... proves that there are problems. That specifically proves there are problems in std.datetime sure, and they're being fixed as TickDuration is marked for deprecation. The fact that Phobo's is trying to become nogc but isn't yet also shows it has a ways to go. Right, so let's keep working on it, not freeze it and not duplicate thousands of man hours of work for no reason. That gives us plenty of time, right? Plenty of time to keep fix bugs like we currently are, sure. Phobos is obviously poorly designed, hacked together manipulated This isn't obvious at all, I think D's take on iterators (ranges) is the best iterator design out there right now. D code is also faster than most of it's competitors (excluding C++ in some cases) and more readable to boot. and in a constant flux of regressions, bugs Bugs and regressions are bad; I'm not going to disagree. But, have you looked at the bug list for most OSS projects? D is not atypical, compare: D, 4073 open issues: https://issues.dlang.org/buglist.cgi?bug_status=UNCONFIRMED_status=NEW_status=ASSIGNED_status=REOPENED=0_id=209089=changeddate%20DESC=D_format=advanced=---=D2 LLVM, 8536 open issues: https://llvm.org/bugs/buglist.cgi?bug_status=__open__==_format=specific=bug_status%2Cpriority%2Cassigned_to%2Cbug_id=0 Firefox, roughly 22,000, bugzilla is unable to return the full list so it's hard to get real numbers: https://bugzilla.mozilla.org/reports.cgi?product=Firefox=UNCONFIRMED=NEW=ASSIGNED=REOPENED You also failed to mention how stopping development on Phobos would help in this regard. Bugs will still happen and need to be fixed. additions Great! New, well designed features come to users quickly in D. and removals IMO it's better to remove things than to maintain broken things and sacrificing readability and usability on the altar of backwards compatibility. D gives 12 - 18 month deprecation periods, and considering that a new release typically lands every two months, that's extremely generous. Have you every used .NET considerably? Nope; mac user.
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 15:48:03 UTC, Mike Parker wrote: I just see things from the perspective that I learned everything I needed from dub --help and the documentation that *is* online. The forums are linked in the menu item 'About' next to 'Documentation' at the top of code.dlang.org. All the information is there. Sure, it could probably clearer in some places, but it does exist and it is usable today. What needs to be improved? Suppose you need to link against a .so file that is in another directory. How do you find out how to do that on this page: http://code.dlang.org/package-format?lang=json But that's just one case. There are basically no examples at all (and the ones that are there probably don't help). There's not even a good explanation of what Dub is. Rust, on the other hand, offers this: http://doc.crates.io/guide.html Rust offers something professional that helps you get going quickly (hasn't there been talk about the first five minutes?), D pushes people away from the language. I will not touch Dub because I can't tell others that they should figure out how to use it by looking at the insides of existing packages and then fiddling around with various configurations to see if they can get it to work. This is not to criticize anyone's work. But it is to say that there is no way Dub, with its current documentation, should be distributed with DMD.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: Destroy! microbenchmarks sux. destruction sequence complete.
[Issue 16194] auto return type inference depends on return statement order
https://issues.dlang.org/show_bug.cgi?id=16194 hba...@hotmail.com changed: What|Removed |Added CC||hba...@hotmail.com --- Comment #1 from hba...@hotmail.com --- In other words, the compiler apparently extracts info about the return type from the first return statement it comes across, rather than trying to find a common type that matches all of the return statements. As an obvious workaround, I suggest you avoid using the auto keyword here. The compiler might have some trouble looking for common types, and I doubt this is something that need urgent attention. --
[Issue 13572] etc.c.zlib must be nothrow
https://issues.dlang.org/show_bug.cgi?id=13572 --- Comment #7 from Ketmar Dark--- i.e. i always thought that @trusted code should survive external errors (like courrupted data), and does check for null pointers, etc. but no code can validate all invalid arguments passed by caller. there is no way to know if passed pointer and length, for example, is absolutely valid. and if i'll change `.ptr` field of delegate with closure, for example (it is publicly available, and i can mess with it), and then pass that delegate to @safe... KABOOM. so i'm pretty sure that my understanding is correct. actually, i'm so sure that there is absolutely no reason in trying to change my mind on that. ;-) --
[Issue 13572] etc.c.zlib must be nothrow
https://issues.dlang.org/show_bug.cgi?id=13572 --- Comment #6 from Ketmar Dark--- my understanding of @trusted (and @safe, for that matter) is that safety promise is nullified if someone passing invalid pointer to such functions. like, pass a slice created from arbitrary memory region to @safe function, and it *will* segfault. zlib stream functions holds the very same promise: until the passed pointers and sizes are valid, zlib will neither crash nor corrupt memory outsize the specified range. that's why i thought that it can be marked @trusted (and actulally does so in my own code). --
Re: Phobo's migration
On Wednesday, 22 June 2016 at 17:55:11 UTC, Joerg Joergonson wrote: Have you every used .NET considerably? You're comparing D to something created and maintained by one of the largest software companies in the world...
Re: GTKD - get CSS class for button
On Wednesday, 22 June 2016 at 17:50:53 UTC, Mike Wey wrote: "Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or 'T' is, i am afraid. toArray currently only works for GtkD classes, so it doesn't work for lists of stings. ListG is a linked list, the data is stored in the data property. to iterate over the list do something like this: ``` ListG list = widget.getStyleContext().listClasses(); while(list !is null) { string str = to!string(cast(char*)list.data); //do something with str. list = list.next; } ``` Thanks alot! Works perfectly!
[Issue 16194] New: auto return type inference depends on return statement order
https://issues.dlang.org/show_bug.cgi?id=16194 Issue ID: 16194 Summary: auto return type inference depends on return statement order Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: petar.p.ki...@gmail.com void main() { fun1(2); // Error: mismatched function return type inference fun2(2); // OK } class A {} class B : A {} class C : A {} auto fun1(int a) { if (a < 3) return new B(); else if (a < 5) return new C(); else return new A(); } auto fun2(int a) { if (a < 3) return new A(); else if (a < 5) return new B(); else return new C(); } --
Re: Behavior of __FILE__ in mixin template
On Wednesday, 22 June 2016 at 17:52:26 UTC, Ali Çehreli wrote: On 06/22/2016 10:07 AM, Andre Pany wrote: > Hi, > > I thought a mixin template is copied into the place where the mixin > statement > exists and then the coding is evaluated. > This seems not to be true for __FILE__ Apparently its the whole template that supports that. Is moving the 'file' parameter to the entire template acceptable? mixin template formTemplate(string file = __FILE__) { // ... } Ali Perfekt, thanks a lot. Kind regards André
Re: Using .lib and .dll in D applications
On Wednesday, 22 June 2016 at 05:34:33 UTC, Mike Parker wrote: On Wednesday, 22 June 2016 at 03:06:29 UTC, moe wrote: I meant like this: - PluginContract // not a dub project, just some folder -- iplugin.d - TestApp // all files for the app (separate project) -- packages DerelictUtil-master // contains the project for derelict -- source app.d // the app -- dub.json // the project file for the app The only dub project would be TestApp. PluginContract would just be some folder completely outside the TestApp dub project. I could not get a relative path to work like this. Just to be clear, are you compiling iplugin.d as well? I assumed you were referring to a compiler error (i.e. missing import), but based on this post I would guess you're getting a linker error. You should probably add this to your dub.json in addition to the importPaths: "sourceFiles": ["../PluginContract/iplugin.d"] I have added all of these to the dub.json: "sourcePaths": ["../PluginContract"], "importPaths": ["../PluginContract"], "sourceFiles": ["../PluginContract/iplugin.d"], In my app I use: import iplugin; I would expect that both the compiler and the linker finds the needed files. I would also prefer a path to link a folder rather than adding files individually. It seams more error prone when I have to remember to add every file in a bigger project. However, every combination of the above seams to fail. With a linker error. Linking... OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 23: No Stack .dub\build\debug-debug-windows-x86-dmd_2071-0BEC1C92408DC77EE5C50BCF4B1225A9\tes tapp.obj(testapp) Error 42: Symbol Undefined _D18TypeInfo_Interface6__vtblZ .dub\build\debug-debug-windows-x86-dmd_2071-0BEC1C92408DC77EE5C50BCF4B1225A9\tes tapp.obj(testapp) Error 42: Symbol Undefined _D14TypeInfo_Class6__vtblZ OPTLINK : Warning 134: No Start Address --- errorlevel 2 dmd failed with exit code 2. Without the adjustments in the dub.json I get the following error (But that is expected if dub only searches in the source folder by default): testplugin ~master: building configuration "debug"... source\SomePlugin.d(3,8): Error: module iplugin is in file 'iplugin.d' which can not be read import path[0] = source import path[1] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[2] = C:\D\dmd2\windows\bin\..\..\src\druntime\import dmd failed with exit code 1.
Re: D-Man culture
On Monday, 20 June 2016 at 14:14:06 UTC, Martin Tschierschke wrote: On Sunday, 19 June 2016 at 15:01:33 UTC, Seb wrote: Hi, I am not sure how much you have heard about the D-Man, but in Japan there is an entire culture based on the D-Man! As I learned about this by accident (and even Walter didn't know about it), I thought I share this great movement with the DLang community! [...] Funny stuff! I found this link useful: http://dlangcomicstrips.tumblr.com/ These are awesome, recommend the read.
Re: Phobo's migration
On Wednesday, 22 June 2016 at 16:51:32 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 16:44:25 UTC, Joerg Joergonson wrote: How bout Freezing Phobos, except for bugs and start migrating it to Phobos 2.0?. This would kill the language. How is that? That makes no sense. If Phobo's is production ready as claimed then freezing it can't make it automagically non-production ready, can it? This will be migrating Phobos over to use the new constructs(nogc, safe, etc), How, in your opinion, are these not being used already? I didn't say they wernt, but they are being done on phobos, which is suppose to be done. The fact that Stopwatch, Monotime, TickDuration are all screwed up, etc... proves that there are problems. The fact that Phobo's is trying to become nogc but isn't yet also shows it has a ways to go. By the time it's finished D3 will be around and it could be used for it. D3 will probably never happen; at least not in the foreseeable future. That gives us plenty of time, right? This allows a clean break but and to learn, but not be shackled by the past. It could go rather fast(months rather than years) since most of the code is already written, it just needs to be migrated properly(might might not require anything but copy and paste for large amounts of code). What exactly, in your opinion, needs to be changed? What's so broken that it needs a "clean break"? Phobos is obviously poorly designed, hacked together, manipulated, and in a constant flux of regressions, bugs, additions, and removals. Have you every used .NET considerably?
Re: Behavior of __FILE__ in mixin template
On 06/22/2016 10:07 AM, Andre Pany wrote: > Hi, > > I thought a mixin template is copied into the place where the mixin > statement > exists and then the coding is evaluated. > This seems not to be true for __FILE__ Apparently its the whole template that supports that. Is moving the 'file' parameter to the entire template acceptable? mixin template formTemplate(string file = __FILE__) { // ... } Ali
Re: GTKD - get CSS class for button
On 06/22/2016 05:16 PM, TheDGuy wrote: On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote: On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized. ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html "Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or 'T' is, i am afraid. toArray currently only works for GtkD classes, so it doesn't work for lists of stings. ListG is a linked list, the data is stored in the data property. to iterate over the list do something like this: ``` ListG list = widget.getStyleContext().listClasses(); while(list !is null) { string str = to!string(cast(char*)list.data); //do something with str. list = list.next; } ``` -- Mike Wey
Re: Is there anyway to make opApply @nogc?
On Wednesday, 22 June 2016 at 13:36:54 UTC, Marc Schütz wrote: On Tuesday, 21 June 2016 at 19:21:01 UTC, Gary Willoughby wrote: Right ok, thanks! It doesn't seem to help though as the compiler complains about it being not @nogc. You probably need to declare the delegate and opApply() itself as @nogc, too: int opApply(scope int delegate(int) @nogc dg) @nogc { } That fixed it, thanks all for your help. :)
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 15:48:03 UTC, Mike Parker wrote: What needs to be improved? I will say that it looks a lot better now than it used to, even though I'm not sure if the content has changed as much. It's not entirely clear why to use SDLang over JSON. It should be more clearly labeled which is preferred. In the JSON description, I'm not a fan of the Build Options text. I would change it to this: Build settings influence the command line options passed to the compiler and linker. All settings are optional. Examples: { "versions": ["PrintfDebugging", "UseAmd64Impl"], "dflags": ["-vtls"], "sourceFiles": ["lib/mylib.lib"], } In addition, it is possible to implement platform specific settings using field name suffixes. Field name suffixes are dash separated platform identifiers, as defined in the D language reference, but converted to lower case. The order of these suffixes is os-architecture-compiler, where any of these parts can be left off. For instance, "sourceFiles-windows-x86_64-dmd" would pass "sourceFiles" only to the DMD compiler on Windows with an x86_64 bit architecture. This can be helpful when a project requires libraries specific to a particular OS and hardware architecture. Other examples: { "versions": ["PrintfDebugging"], "dflags-dmd": ["-vtls"], "versions-x86_64": ["UseAmd64Impl"] "libs-posix": ["ssl", "crypto"], "sourceFiles-windows-x86_64-dmd": ["lib/win32/mylib.lib"], } In the Configuration section: It says "A list of platform suffixes (as used for the build settings) to limit on which platforms the configuration applies." Platform suffixes is not clear enough. Above they are referred to as field name suffixes. I would re-write this as "A list of field name suffixes (as described above and used for the build settings) to limit on which platforms the configuration applies. For instance, setting "platforms": ["windows-x86_64-dmd"] would mean the configuration would only apply when compiling only with the DMD compiler on Windows with an x86_64 bit architecture." Also, it says "When defining a configuration's platform, any of the suffixes described in build settings may be combined to make the configuration as specific as necessary." to which I would append: For instance, in the following configuration { "name": "desktop-app", "targetType": "executable", "platforms": ["windows"], "versions": ["DesktopApp"], "libs-x86_64-dmd": ["d3d9"] }, "libs" is customized for compiling with DMD on the x86_64 architecture. Further, since "platforms" is set to Windows, it applies "libs" (and "versions" and "windows" does not need to be specified.
Re: Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
On Wednesday, 22 June 2016 at 17:04:54 UTC, Meta wrote: Intentional or not, I don't see any downside to disallowing calling text with 0 args (aside from backwards-compatibility concerns). It doesn't even return anything useful, just null. Well, the idea is that the function is a string constructor so it returns d/w/string.init with nothing passed in.
Behavior of __FILE__ in mixin template
Hi, I thought a mixin template is copied into the place where the mixin statement exists and then the coding is evaluated. This seems not to be true for __FILE__ I have a module form, which has a class Form. This module also contains following mixin template mixin template formTemplate() { void generateForm() { string getFormName(string file = __FILE__)() { import std.string: indexOf; return file[0..file.indexOf(".")]~".frm"; } enum fileContent = import(getFormName()); } } In another module myform I have a class MyForm in which I call the mixin statement: mixin formTemplate. The purpose of the template coding is: The enum fileContent should contain the text of a file, which has the same name as the module but the file ending .frm. I tried different things, but either it doesn't compile or __FILE__ returns "form" instead of "myform". Is this behavior correct? Do you have any tip? Kind regards André
Re: Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
On Wednesday, 22 June 2016 at 15:39:11 UTC, Meta wrote: If it is called with 0 arguments it will return null. This behaviour has caused several bugs in my code because combined with optional parens and UFCS, it is easy to accidentally call text with 0 args but have it look like passing a variable to a function. It's really annoying: https://issues.dlang.org/show_bug.cgi?id=12357
Re: Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
On Wednesday, 22 June 2016 at 16:47:53 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 15:48:06 UTC, Seb wrote: I don't see any problem in deprecating it as std.conv.text with 0 arguments is clearly unintended behavior I don't see how you can make that claim, take a look at the code again: private S textImpl(S, U...)(U args) { static if (U.length == 0) { return null; } else { auto result = to!S(args[0]); foreach (arg; args[1 .. $]) result ~= to!S(arg); return result; } } The zero argument result was clearly an intentional special case Intentional or not, I don't see any downside to disallowing calling text with 0 args (aside from backwards-compatibility concerns). It doesn't even return anything useful, just null.
Re: Phobo's migration
On Wednesday, 22 June 2016 at 16:44:25 UTC, Joerg Joergonson wrote: How bout Freezing Phobos, except for bugs and start migrating it to Phobos 2.0?. This would kill the language. This will be migrating Phobos over to use the new constructs(nogc, safe, etc), How, in your opinion, are these not being used already? By the time it's finished D3 will be around and it could be used for it. D3 will probably never happen; at least not in the foreseeable future. This allows a clean break but and to learn, but not be shackled by the past. It could go rather fast(months rather than years) since most of the code is already written, it just needs to be migrated properly(might might not require anything but copy and paste for large amounts of code). What exactly, in your opinion, needs to be changed? What's so broken that it needs a "clean break"?
Re: Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
On Wednesday, 22 June 2016 at 15:48:06 UTC, Seb wrote: I don't see any problem in deprecating it as std.conv.text with 0 arguments is clearly unintended behavior I don't see how you can make that claim, take a look at the code again: private S textImpl(S, U...)(U args) { static if (U.length == 0) { return null; } else { auto result = to!S(args[0]); foreach (arg; args[1 .. $]) result ~= to!S(arg); return result; } } The zero argument result was clearly an intentional special case
Phobo's migration
How bout Freezing Phobos, except for bugs and start migrating it to Phobos 2.0?. This way a proper library can be built that doesn't feel like a lot of stuff thrown together haphazardly(think .NET). This will be migrating Phobos over to use the new constructs(nogc, safe, etc), remove the crust and just polish things up. It could be added to the release and used "import p = Phobos2;" By the time it's finished D3 will be around and it could be used for it. A committee can formed to decide what to include and to design the structure of the library. Anyone can submit code. This allows a clean break but and to learn, but not be shackled by the past. It could go rather fast(months rather than years) since most of the code is already written, it just needs to be migrated properly(might might not require anything but copy and paste for large amounts of code). I know some people like to keep their old rusty cars on their front lawns but it only tells everybody that they are stuck in the past.
Re: TypeInfo_Interface from runtime string?
On Wednesday, 22 June 2016 at 15:46:15 UTC, Thalamus wrote: On Wednesday, 22 June 2016 at 15:43:08 UTC, Basile B. wrote: On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: [...] No need for a constructor. typeid() returns a static instance that's pre-allocated. [...] Thanks Basile. Hit Send too soon... Thanks Basile. As it turned out I was already doing something very similar for mapping types to interfaces and to other types, using shared static constructors to perform registration into associative arrays, e.g. TypeInfo_Class[TypeInfo_Class] and TypeInfo_Interface[TypeInfo_Class] So I can easily add TypeInfo_Interface[string] and TypeInfo_Class[string] as part of the existing registration process and then expose a simple lookup method. Thanks for the good idea! :)
Re: TypeInfo_Interface from runtime string?
On Wednesday, 22 June 2016 at 15:43:08 UTC, Basile B. wrote: On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: [...] No need for a constructor. typeid() returns a static instance that's pre-allocated. [...] Thanks Basile.
Re: Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
On Wednesday, 22 June 2016 at 15:39:11 UTC, Meta wrote: This is a small but annoying problem: std.conv.text is defined like this: [...] Imho that's a great idea! I don't see any problem in deprecating it as std.conv.text with 0 arguments is clearly unintended behavior. Hence I would call this a bug fix ;-)
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 13:51:55 UTC, jmh530 wrote: Given that this project is going to bundled with DMD some time in the future, I think that this response sees the forest for the trees. While those things would make the OPs life a little easier, hopefully, the number of people using dub would increase with its inclusion in DMD. I care more about ease of use for all the people who might start using dub in the future. Not all of these people would want to learn from dub --help. I don't think I'm alone in believing that the dub documentation could be improved, especially with tutorials or examples. I just see things from the perspective that I learned everything I needed from dub --help and the documentation that *is* online. The forums are linked in the menu item 'About' next to 'Documentation' at the top of code.dlang.org. All the information is there. Sure, it could probably clearer in some places, but it does exist and it is usable today. What needs to be improved?
Re: TypeInfo_Interface from runtime string?
On Wednesday, 22 June 2016 at 15:15:51 UTC, Thalamus wrote: Hi everyone, My project includes lots of .Net interop via C linkage. One of the things I need to do is refer in C# to an interface declared in the D code, and then to actually work with the interface concretely in the D layer. So, I need to get a TypeInfo_Interface object from a string passed in from C#. The problem isn't in marshaling the string between C# and D, but rather what to do with the string once I have it in D. So in the D code, where interfaceName is the fully qualified name of an interface, e.g. "MyPackage.MyModule.MyInterface", what I would like is something like: TypeInfo_Interface theInterface = new TypeInfo_Interface(interfaceName); But there's no such constructor. No need for a constructor. typeid() returns a static instance that's pre-allocated. Apologies if this seems like it should be obvious, but I couldn't find anything in the forums or the wider web. :) No problem. What you need to do is to create a registry with all the possible TypeInfo_Interfaces. This registry will have the form of an associative array. Each TypeInfo_Interface will be selectable with the fully qualified string, for example: __gshared TypeInfo_Interface[string] registry; interface Foo{} interface Bar{} static this() { registry[typeid(Foo).toString] = typeid(Foo); registry[typeid(Bar).toString] = typeid(Bar); } That's the basic idea but with introspection (foreach(member; traits) you should be able to automate the creation of the registry, in a smarter way.
Proposed Enhancement: Deprecate std.conv.text With 0 Arguments
This is a small but annoying problem: std.conv.text is defined like this: string text(T...)(T args) { return textImpl!string(args); } private S textImpl(S, U...)(U args) { static if (U.length == 0) { return null; } else { auto result = to!S(args[0]); foreach (arg; args[1 .. $]) result ~= to!S(arg); return result; } } If it is called with 0 arguments it will return null. This behaviour has caused several bugs in my code because combined with optional parens and UFCS, it is easy to accidentally call text with 0 args but have it look like passing a variable to a function. An example bug that I recently found in my code: Token getNextToken(ref string input) { assert(!input.empty); while (input.front.isSpace) { input.advance(1); } if (input.front == '$' || input.front.isAlpha) { if (input.front == '$') { //BUG text.advance(1); } auto identStr = input.getNextWord(); if (keywords.canFind(identStr)) { return new Keyword(input.front == '$' ? '$' ~ identStr : identStr); } else { return new Identifier(identStr); } } else if (input.front.isDigit || input.front == '-' || input.front == '+') { //etc. } else if (input.front == '"') { //etc. } //etc... } void advance(ref string input, size_t n) { foreach (_; 0..n) { if (input.empty) { break; } input.popFront(); } } The problem is that `advance` was not advancing the input, causing bugs in the lexing stage. Usually the compiler would warn me that no such variable `text` exists, but as I imported std.conv, `text` was in scope. Since `text` can take 0 or more arguments, and due to optional parens, `text.advance(1)` is a valid expression that does nothing. If std.conv.text took only 1 or more arguments and refused to compile with 0 arguments, then the compiler would signal an error as normal and I would not have to spend an hour hunting down this bug. I would like to make a pull request to fix this, deprecating the 0-argument case and then eventually making it an error, but would this PR be accepted considering it technically breaks backwards-compatibility?
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 14:28:19 UTC, Adam D. Ruppe wrote: BTW this more measures linker speed than compiler. dmd -c -o- just runs the compiler and skips filesystem output... it'd be pretty fast and if there's similar options for other compilers (gcc has -c too at least) it might be better for small programs. Larger programs I think is fair to include the link step, since it should be less a percentage there and you do need to run it anyway. Yeah, you do need to run it anyway, even if you build incrementally. It'd be a lie to omit the link time when the compiler actively works to make linker's job harder by inflating the symbol table to tens or hundreds of megabytes.
Re: GTKD - get CSS class for button
On Wednesday, 22 June 2016 at 13:47:01 UTC, Gerald wrote: On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized. ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html "Type T wraps should match the type of the data" Does string match the type of the data? What is the type of the data? How do i tell the function that i want the Array as a string array? I am not familiar with Types and what 'TC' or 'T' is, i am afraid.
TypeInfo_Interface from runtime string?
Hi everyone, My project includes lots of .Net interop via C linkage. One of the things I need to do is refer in C# to an interface declared in the D code, and then to actually work with the interface concretely in the D layer. So, I need to get a TypeInfo_Interface object from a string passed in from C#. The problem isn't in marshaling the string between C# and D, but rather what to do with the string once I have it in D. So in the D code, where interfaceName is the fully qualified name of an interface, e.g. "MyPackage.MyModule.MyInterface", what I would like is something like: TypeInfo_Interface theInterface = new TypeInfo_Interface(interfaceName); But there's no such constructor. Apologies if this seems like it should be obvious, but I couldn't find anything in the forums or the wider web. :) thanks, Thalamus
Re: Phobos Action Items
https://lexi-lambda.github.io/blog/2016/06/12/four-months-with-haskell/#documentation-is-nearly-worthless - found this on reddit, criticizes haskell docs and praises racket docs: they are so effective because of how the prose explains what each function does, when to use it, why you’d use it, and why you wouldn’t use it.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: RDMD 0:00:00.275884 DMD 0:00:00.311102 Since rdmd is just a script wrapper around dmd, it shouldn't actually be faster. BTW this more measures linker speed than compiler. dmd -c -o- just runs the compiler and skips filesystem output... it'd be pretty fast and if there's similar options for other compilers (gcc has -c too at least) it might be better for small programs. Larger programs I think is fair to include the link step, since it should be less a percentage there and you do need to run it anyway.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 14:28:19 UTC, Adam D. Ruppe wrote: On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: RDMD 0:00:00.275884 DMD 0:00:00.311102 Since rdmd is just a script wrapper around dmd, it shouldn't actually be faster. BTW this more measures linker speed than compiler. dmd -c -o- just runs the compiler and skips filesystem output... it'd be pretty fast and if there's similar options for other compilers (gcc has -c too at least) it might be better for small programs. Larger programs I think is fair to include the link step, since it should be less a percentage there and you do need to run it anyway. I agree that this is strange. It is tricky compare compilation time with Python or Java. Python works as in interpreter (with bytecode compilation behind the scene). Java does most of the compiling in the JVM and javac is pretty stupid. What I want to get at is actually the "iteration speed", not just the "compilation speed". How fast can edit-compile-test your program? It might actually be more truthful to use dub (and cargo and maven ...), since it is the idiomatic way.
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 14:11:12 UTC, Jack Stouffer wrote: On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: ... Including scripting languages in that example is unfair as they only lex the file. Sure. Especially bash, which is always in RAM anyways. It shows the possible span, though. Right away you can tell that "Hello World" is a poor example of fast compile times because GCC is near the top; (as you probably know) large Cpp projects can have half hour to an hour long build times. Large projects are way faster to compile using dmd. This is the C hello world. I added a C++ one and it is slightly faster than Go. I completely agree that Hello World is poor. Brainfuck is a little better. Using the code from even a small piece of code that does something real, all of a sudden the numbers get a lot closer. Here is the code I'm using: https://github.com/kostya/benchmarks/tree/master/brainfuck2 $ time rustc bf.rs rustc bf.rs 0.29s user 0.05s system 99% cpu 0.350 total $ time go build bf.go go build bf.go 0.46s user 0.07s system 128% cpu 0.416 total $ time dmd bf.d dmd bf.d 0.32s user 0.09s system 73% cpu 0.556 total $ time g++ bf.cpp g++ bf.cpp 0.36s user 0.36s system 65% cpu 1.093 total Rust faster than Go? That still seems weird. I like your overall benchmark. Measuring build times there seems like a good idea.
Re: TickDuration depreciated, yet stopwatch not?
On Tuesday, June 21, 2016 19:17:00 Joerg Joergonson via Digitalmars-d-learn wrote: > Stopwatch depends on TickDuration and TickDuration is depreciated > yet Stopwatch isn't and hasn't been converted to MonoTime... > makes sense? TickDuration does have a note in its documentation about how it's _going_ to be deprecated, but it isn't deprecated yet - precisely because StopWatch has not been deprecated yet. A replacement which uses MonoTime is in the works, but there are issues with where to put it in Phobos, because putting it in std.datetime as things stand won't work, because it would conflict with the existing StopWatch. Plans are in place to sort that out, but until then, StopWatch won't be deprecated and neither will TickDuration. - Jonathan M Davis
Re: Real implicitly converts to float?
On Wednesday, June 22, 2016 05:04:42 Tofu Ninja via Digitalmars-d-learn wrote: > Is this intended behavior? I can't seem to find it documented > anywhere, I would think the loss in precision would atleast be a > warning. > > real x = 10; > float y = x; // No error or warning > > real to double and double to float also work. Well, that particular value should probably work thanks to VRP (value range propagation), since 10 can fit into float with no loss of precision. However, what's far more disconcerting is that real x = real.max; float y = x; compiles. real to float is a narrowing conversion, which should be an error barring the compiler detecting that the value will fit in the target type even if it's a narrowing conversion (which only happens with VRP). That's not the sort of thing that I would have expected to be broken such that it begs the question as to whether it's intentional, but given that narrowing conversions without a cast are illegal everywhere else, this definitely seems broken. - Jonathan M Davis
Re: Is dmd fast?
On Wednesday, 22 June 2016 at 13:46:50 UTC, qznc wrote: ... Including scripting languages in that example is unfair as they only lex the file. Right away you can tell that "Hello World" is a poor example of fast compile times because GCC is near the top; (as you probably know) large Cpp projects can have half hour to an hour long build times. Large projects are way faster to compile using dmd. Using the code from even a small piece of code that does something real, all of a sudden the numbers get a lot closer. Here is the code I'm using: https://github.com/kostya/benchmarks/tree/master/brainfuck2 $ time rustc bf.rs rustc bf.rs 0.29s user 0.05s system 99% cpu 0.350 total $ time go build bf.go go build bf.go 0.46s user 0.07s system 128% cpu 0.416 total $ time dmd bf.d dmd bf.d 0.32s user 0.09s system 73% cpu 0.556 total $ time g++ bf.cpp g++ bf.cpp 0.36s user 0.36s system 65% cpu 1.093 total
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 01:56:34 UTC, Mike Parker wrote: And there's always the DUB forums [5. I didn't even know there were DUB forums.
Re: Examples of dub use needed
On Wednesday, 22 June 2016 at 01:56:34 UTC, Mike Parker wrote: There aren't that many commands for DUB on the command line. Most of what you need can be gleaned from dub --help, but there is also documentation online [1]. For package configurations, the documentation at code.dlang.org covers everything [2] & [3], just not always clearly. It's easy enough to get examples for that from all of the projects listed in the registry [4]. Just click through them to their github or bitbucket repositories and study their dub.json/sdl files. And there's always the DUB forums [5. Given that this project is going to bundled with DMD some time in the future, I think that this response sees the forest for the trees. While those things would make the OPs life a little easier, hopefully, the number of people using dub would increase with its inclusion in DMD. I care more about ease of use for all the people who might start using dub in the future. Not all of these people would want to learn from dub --help. I don't think I'm alone in believing that the dub documentation could be improved, especially with tutorials or examples.
[Issue 16193] opApply() doesn't heap allocate closure
https://issues.dlang.org/show_bug.cgi?id=16193 Mathias Langchanged: What|Removed |Added CC||mathias.l...@sociomantic.co ||m --- Comment #1 from Mathias Lang --- Why do you want it to allocate ? That can either be changed (with a BIG RED warning), or the specs can be updated to mention the delegate is always `scope`. Either way, I'm just puzzled what's the use case here. --
Re: GTKD - get CSS class for button
On Wednesday, 22 June 2016 at 12:57:51 UTC, TheDGuy wrote: widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized. ListG has a D specific method called toArray that allows you to convert it to a typed array, so you could use it in this case to get a string[] out of it. http://api.gtkd.org/src/glib/ListG.html
Is dmd fast?
Walter and we as a community often claim that dmd is fast as in "compiles quickly". Go also claims this. Rust does not. They even state that compilation speed is one of the big tasks they are working on. From the general sentiment, I would expect that dmd performs on the level of Go and Rust being slower. Now, D as a language supports arbitrary compile-time computation so dmd can be arbitrarily slow. We need to look at the benchmark carefully. I started with the canonical Hello World. Here are some numbers: Dash 0:00:00.002366 Bash 0:00:00.002474 TCC 0:00:00.007044 Python2 0:00:00.009881 Python3 0:00:00.015547 GCC 0:00:00.028578 Go 0:00:00.149691 Rust 0:00:00.212053 RDMD 0:00:00.275884 Haskell 0:00:00.310539 DMD 0:00:00.311102 Java 0:00:00.596517 Scala0:00:01.917606 X10 Java 0:00:02.484673 X10 C++ 0:00:03.887826 Hm, Rust is faster than dmd? Go is roughly twice as fast as dmd? Destroy! But run your own numbers first: https://github.com/qznc/hello-benchmark ;)
Re: Is there anyway to make opApply @nogc?
On Tuesday, 21 June 2016 at 19:21:01 UTC, Gary Willoughby wrote: Right ok, thanks! It doesn't seem to help though as the compiler complains about it being not @nogc. You probably need to declare the delegate and opApply() itself as @nogc, too: int opApply(scope int delegate(int) @nogc dg) @nogc { }
[Issue 16193] New: opApply() doesn't heap allocate closure
https://issues.dlang.org/show_bug.cgi?id=16193 Issue ID: 16193 Summary: opApply() doesn't heap allocate closure Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: schue...@gmx.net // yy.d module yy; struct S { int opApply(int delegate(int) dg) { foreach(i; 1 .. 10) { int result = dg(i); if(result) return result; } return 0; } } // xx.d import yy; int* px, py; int foo() { int x = 0, y = 0; foreach(i; S.init) { px = py = y++; } return y; } void main() { import std.stdio; writeln(foo()); int z = 0; writeln(" = ", px, " = ", py, " = ", ); } # dmd -c xx.d # dmd -c yy.d # dmd -ofxx xx.o yy.o # ./xx prints: 9 = 7FFEAD3C47C0 = 7FFEAD3C47C4 = 7FFEAD3C47E8 (or similar) As can be seen, all local variables are allocated next to each other, evidently on the stack. This happens even though S.opApply() doesn't take its delegate as scope. I'm deliberately using separate compilation here to make sure that the compiler has no way to infer that the closure doesn't escape. --
Re: Access vialotion
On Wednesday, 22 June 2016 at 13:24:47 UTC, vladdeSV wrote: On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; } private void letButtonsFlash(){ for(int i = 0; i < 4; i++){ writeln(this.bArr[i].getName()); } } } i don't understand why i get an 'Access Violation' - Error in the 'for'-loop? Okay, i solved it, instead of: Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; this: bArr = [btn_1,btn_2,btn_3,btn_4]; I would also suggest you use a foreach loop to iterate over the buttons: private void letButtonsFlash() { foreach(button; bArr) { writeln(button.getName()); } } //Also, question to anyone: should a ref be used here? No, ref for classes is pointless. The ptr destination is always the same heap chunk, whatever you use the original pointer or not.
Re: Access vialotion
On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; } private void letButtonsFlash(){ for(int i = 0; i < 4; i++){ writeln(this.bArr[i].getName()); } } } i don't understand why i get an 'Access Violation' - Error in the 'for'-loop? Okay, i solved it, instead of: Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; this: bArr = [btn_1,btn_2,btn_3,btn_4]; I would also suggest you use a foreach loop to iterate over the buttons: private void letButtonsFlash() { foreach(button; bArr) { writeln(button.getName()); } } //Also, question to anyone: should a ref be used here?
Re: Real implicitly converts to float?
On Wednesday, 22 June 2016 at 08:57:38 UTC, Guillaume Piolat wrote: On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote: Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x; // No error or warning real to double and double to float also work. Intended behaviour (in TDPL and all), and same behaviour than C. I'm not sure of the reason. That's a little disconcerting, would be nice if there was a compiler flag to give a warning on the precision loss.
Re: Access vialotion
On Wednesday, 22 June 2016 at 12:47:31 UTC, TheDGuy wrote: On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; } private void letButtonsFlash(){ for(int i = 0; i < 4; i++){ writeln(this.bArr[i].getName()); } } } i don't understand why i get an 'Access Violation' - Error in the 'for'-loop? Okay, i solved it, instead of: Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; this: bArr = [btn_1,btn_2,btn_3,btn_4]; I would expect DMD to output a warning here, because of the shadowing...but after 3 verifications, nothing. Dscanner does.
Re: GTKD - get CSS class for button
widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass() Thanks a lot for your answer. Do you know how i can get the first classname as string from the widget? I don't understand how the return type 'GList' is organized.
Re: Access vialotion
On Wednesday, 22 June 2016 at 12:45:29 UTC, TheDGuy wrote: I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; } private void letButtonsFlash(){ for(int i = 0; i < 4; i++){ writeln(this.bArr[i].getName()); } } } i don't understand why i get an 'Access Violation' - Error in the 'for'-loop? Okay, i solved it, instead of: Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; this: bArr = [btn_1,btn_2,btn_3,btn_4];
Access vialotion
I have an array of buttons: class Window : MainWindow{ private Button[4] bArr; this(){ Button btn_1 = new Button(); Button btn_2 = new Button(); Button btn_3 = new Button(); Button btn_4 = new Button(); Button[4] bArr = [btn_1,btn_2,btn_3,btn_4]; } private void letButtonsFlash(){ for(int i = 0; i < 4; i++){ writeln(this.bArr[i].getName()); } } } i don't understand why i get an 'Access Violation' - Error in the 'for'-loop?
Re: QtE5 - is a wrapping of Qt-5 for D
This is very nice! I would love to know how you managed to get it working. I had trouble with signals and slots, the class hierarchy, and numerous other things when I was trying to get Qt4 to work in D. How did you handle the Qt class constructors and destructors, etc.? Well, there are too many questions.The majority of answers you can find in qte5widgets(h,cpp)files.The main thing is the set of readymade slots that are based in prepared class "eAction"(C++). This class has the address of the D function by way of property and when the slot is called it will just call the D function. I suggest to continue the discussion at Github.
Re: GTKD - get CSS class for button
On Wednesday, 22 June 2016 at 08:08:20 UTC, TheDGuy wrote: Hello, i would like to know if it possible to get the CSS-class which is asigned to a button (for example)? I didn't find any documentation about this, just the function "getStyleContext().getProperty()", my current attempt: Value value; bArr[0].getStyleContext().getProperty("Class",StateFlags.NORMAL,value); (bArr is an array of buttons). I get the error, that 'Value' is not defined, if i use 'GValue' (as it is described here: https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-get-property) i get 'function is not callable with GValue' Any ideas? Thanks alot! widget.getStyleContext().listClasses() to get a list of all classes assigned to the widget. If you just want to see if a specific class is assigned to the widget you can use widget.getStyleContext().hasClass()
Re: inout and opApply
On Monday, 20 June 2016 at 15:09:22 UTC, Steven Schveighoffer wrote: int opApply(scope int delegate(ref inout T value) dg) inout The inout inside the delegate is wrapped just like the inout of the 'this' parameter. effectively, this becomes equivalent to several function signatures: int opApply(scope int delegate(ref T value) dg) int opApply(scope int delegate(ref const T value) dg) const int opApply(scope int delegate(ref immutable T value) dg) immutable int opApply(scope int delegate(ref inout T value) dg) inout AFAIK, there was a bugzilla issue for it. Wasn't it implemented?
Re: Release DUB 1.0.0
Am 21.06.2016 um 00:37 schrieb Basile B.: You should add a system to support example files, without dependency. For example in a static library, something that would indicate that the package in which the file resides is itself a dependency but don't have to be downloaded: package examples ex1.d ex2.d source package src1.d ex1.d /+ dub.sdl: name "package" dependency "this" (or dependency "../..") +/ from ex1 you should be able to locate the package by using .dirName until a dub.json is found. Maybe that if the dep value is a relative path that leads to a description this works too. This currently works using dependency "package" path="../../" I'd like to avoid making this smarter, because currently (sub) packages are all logically distinct, which helps a lot to keep the internal logic simple in various places. An exception to this rule is that versions of sub packages are locked to the version of the parent package, which causes quite some complications in the dependency resolution algorithm, which in turn has often been a source of bugs.
Re: Release DUB 1.0.0
Am 22.06.2016 um 11:51 schrieb gleb: Sönke Ludwig wrote: I'm pleased to announce the release of the first stable version of the DUB package manager. Stable in this case means that Hello! That's great! But... Is "DFLAGS="-defaultlib=libphobos2.so" dub build" still the only way to build dynamically linked binaries? What about standard options to build/link against ".so's"? Thank You! Do you mean building a shared library, or linking against the shared version of Phobos? The former case should automatically add -defaultlib, if targetType is set to "dynamicLibrary" in the package recipe. In the latter case, it has to be specified dynamically. Using DFLAGS is a possibility, or putting it in the "dflags" field of the recipe.
[Issue 13572] etc.c.zlib must be nothrow
https://issues.dlang.org/show_bug.cgi?id=13572 --- Comment #5 from Sobirari Muhomori--- Are you sure it can survive if someone messes with z_stream fields? They are all public. --
Re: Phobos: __FILE__ as template default parameter
On Tuesday, 21 June 2016 at 10:39:52 UTC, David Nadlinger wrote: On Monday, 20 June 2016 at 08:10:19 UTC, Dicebot wrote: How about defining semantics like "try inlining if possible, fallback to always emitting symbol to object file otherwise"? That would also allow compatible implementation in dmd. This would get rid of the undefined symbols, but there is a much more subtle problem here that nobody has brought up yet: If the template ends up being emitted twice with different mangled names, then, well, it ends up existing twice in the final executable. This is not really an issue for functions, but very much so for data symbols (e.g. a static variable inside a function), where you could end up with the same alias referring to two different pieces of data depending on where it is used from. The root of this issue is that __FILE__ introduces incidental environmental state into the otherwise pure module system. +1
Re: Release DUB 1.0.0
Sönke Ludwig wrote: > I'm pleased to announce the release of the first stable version of the > DUB package manager. Stable in this case means that Hello! That's great! But... Is "DFLAGS="-defaultlib=libphobos2.so" dub build" still the only way to build dynamically linked binaries? What about standard options to build/link against ".so's"? Thank You!
Re: Initialise dynamic array in array of structures
On Wednesday, 22 June 2016 at 08:06:26 UTC, ketmar wrote: On Wednesday, 22 June 2016 at 06:43:12 UTC, Paul wrote: Why is initialisation via {} bad (in simple terms please :D)? first, it is buggy. i.e. it doesn't always call postblit[1]. second, it's syntax is the same as the syntax of argument-less lambda, which makes it context-dependent -- so reader has to make some mental efforts to find out if it is really lambda or struct initialization. for me, it is enough to see it as bad. and for some other people too. ;-) [1] https://issues.dlang.org/show_bug.cgi?id=16146 On the other hand I don't see why you'd expect {} to call postblit at all. Postblit is meant for copy construction while here (with {}) there is no copy, just an initialization. And actually the "verbose" way doesn't call postblit either: import std.stdio; struct Coord { int x, y; this(this) { writeln("Postblit (", x, ",", y, ")"); } } void main(string[] args) { writeln("Building a"); Coord a = {1, 3}; writeln("Building b"); Coord b = Coord(4, 2); } /* (fcn) sym._Dmain 78 ; var int local_14h @ ebp-0x14 ; var int local_10h @ ebp-0x10 ; var int local_ch @ ebp-0xc ; var int local_8h @ ebp-0x8 ; var int local_4h @ ebp-0x4 ; DATA XREF from 0x08078f13 (sym.main) 0x080786e0 push ebp 0x080786e1 mov ebp, esp 0x080786e3 sub esp, 0x14 0x080786e6 mov dword [ebp - local_14h], ebx 0x080786e9 mov ecx, str.Building_a 0x080786ee mov eax, 0xa 0x080786f3 push ecx 0x080786f4 push eax 0x080786f5 call sym._D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv ; Construction of 'a' 0x080786fa mov dword [ebp - local_10h], 1 0x08078701 mov dword [ebp - local_ch], 3 0x08078708 mov edx, str.Building_b 0x0807870d mov ebx, 0xa 0x08078712 push edx 0x08078713 push ebx 0x08078714 call sym._D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv ; Construction of 'b' 0x08078719 mov dword [ebp - local_8h], 4 0x08078720 mov dword [ebp - local_4h], 2 0x08078727 xor eax, eax 0x08078729 mov ebx, dword [ebp - local_14h] 0x0807872c leave 0x0807872d ret */ No postblit.
Re: dlang-requests 0.1.7 released
On Wednesday, 22 June 2016 at 02:04:25 UTC, Zekereth wrote: On Saturday, 11 June 2016 at 23:03:52 UTC, ikod wrote: Hello, Dlang-requests is library created under influence of Python-requests, with primary goal of easy to use and performance. I have a couple of questions. If a url can't be found and I catch the ConnectError exception and handle it[2] I still get an additional error[1] printed. For example: try { getContent(url); } catch(ConnectError ex) { debug writeln("Error getting page: ", ex.msg); } Will error with this: [1]2016-06-21T20:59:15.073:streams.d:connect:750 Failed to connect: can't resolve www.systemcontrolpanel.com - getaddrinfo error: Name or service not known [2]Error getting page: Can't connect to www.systemcontrolpanel.com:80: getaddrinfo error: Name or service not known The additional error[1] will still print in release build. The only workaround I could find was to check getAddress myself and ensure that the page exists before calling getContent. Thanks! Hello, It makes no sense to log error message and throw exception in next line, so I'll remove this error messages from the code. Thanks for report(but better place it on the github project page so that I can link code changes with bug reports)!
Re: QtE5 - is a wrapping of Qt-5 for D
On Monday, 20 June 2016 at 16:52:04 UTC, MGW wrote: This my library has about 400 functions from Qt and is quite efficient for small applications. https://github.com/MGWL/QtE5 Small video about QtE5 and id5 written on its basis - an example of use. QtE5 on Mac OSX https://www.youtube.com/watch?v=JBA4vkT5uKE This is very nice! I would love to know how you managed to get it working. I had trouble with signals and slots, the class hierarchy, and numerous other things when I was trying to get Qt4 to work in D. How did you handle the Qt class constructors and destructors, etc.?
Re: Real implicitly converts to float?
On Wednesday, 22 June 2016 at 05:04:42 UTC, Tofu Ninja wrote: Is this intended behavior? I can't seem to find it documented anywhere, I would think the loss in precision would atleast be a warning. real x = 10; float y = x; // No error or warning real to double and double to float also work. Intended behaviour (in TDPL and all), and same behaviour than C. I'm not sure of the reason.
Re: problem using ldc 1.0.0 as D compiler
On Tuesday, 21 June 2016 at 21:44:59 UTC, Dicebot wrote: Would you mind making a point release with it if fix is confirmed? That's Kai's territory, but I'm sure he'll agree that this a sensible thing to do. — David
Re: Searching for a T in a T[]
On Wednesday, 22 June 2016 at 08:07:51 UTC, David Nadlinger wrote: What about http://dlang.org/phobos/std_algorithm_searching.html#.canFind.canFind.2? My mistake. The reason for the template error message was another than I though of. Thanks.
Re: Searching for a T in a T[]
On Wednesday, 22 June 2016 at 08:04:34 UTC, Nordlöw wrote: Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. I'm aware of `std.string.indexOf` but that's only for strings. I don't see why canFind isn't good enough for you, maybe I don't get what you want: void main(string[] args) { import std.algorithm: canFind; struct Coord { int x, y; } Coord[] list = [Coord(0, 0), Coord(3, 14), Coord(1, 2), Coord(4, 2)]; assert( list.canFind(Coord(3, 14))); assert( list.canFind(Coord(4, 2))); assert(!list.canFind(Coord(4, 3))); assert(!list.canFind(Coord(-1, 3))); }
GTKD - get CSS class for button
Hello, i would like to know if it possible to get the CSS-class which is asigned to a button (for example)? I didn't find any documentation about this, just the function "getStyleContext().getProperty()", my current attempt: Value value; bArr[0].getStyleContext().getProperty("Class",StateFlags.NORMAL,value); (bArr is an array of buttons). I get the error, that 'Value' is not defined, if i use 'GValue' (as it is described here: https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-get-property) i get 'function is not callable with GValue' Any ideas? Thanks alot!
Re: Initialise dynamic array in array of structures
On Wednesday, 22 June 2016 at 06:43:12 UTC, Paul wrote: Why is initialisation via {} bad (in simple terms please :D)? first, it is buggy. i.e. it doesn't always call postblit[1]. second, it's syntax is the same as the syntax of argument-less lambda, which makes it context-dependent -- so reader has to make some mental efforts to find out if it is really lambda or struct initialization. for me, it is enough to see it as bad. and for some other people too. ;-) [1] https://issues.dlang.org/show_bug.cgi?id=16146
Re: Searching for a T in a T[]
On Wednesday, 22 June 2016 at 08:04:34 UTC, Nordlöw wrote: Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. What about http://dlang.org/phobos/std_algorithm_searching.html#.canFind.canFind.2? — David
Searching for a T in a T[]
Is there now algorithm (similar to `canFind`) that can search for a `T` in a `T[]`? Existing `canFind` only supports sub-sequence needles. I'm aware of `std.string.indexOf` but that's only for strings.