Re: D for scripting?
On 2017-01-20 08:10, Andrei Alexandrescu wrote: It would be worth it. I think a fix takes some thinking because if I remember correctly the compiler does not accept files without an extension as input. It does. It's been fixed, for exactly this reason. -- /Jacob Carlborg
Re: Catching Errors
On 2017-01-20 03:11, Adam D. Ruppe wrote: It is just that Errors are not necessarily *thrown*. The implementation is allowed to immediately abort on them too - your catch has no guarantee to actually run, whereas with Exceptions, they are. That doesn't work well with a unit test framework that want to catch assertions to be able to continue with other tests. -- /Jacob Carlborg
Re: DConf 2017 now open for registration
On 2017-01-19 21:53, Walter Bright wrote: $250 for Early Bird tickets! http://dconf.org/2017/registration.html Awesome :). BTW, there's a page missing [1]. [1] http://dconf.org/2017/thankyou.html -- /Jacob Carlborg
Re: Catching Errors
On 2017-01-19 17:22, Atila Neves wrote: Just slap @trusted on the part of the framework that catches them. Sure, but that doesn't help with the plan [1] making Errors unable to be caught even in system code. [1] Note sure if it's really the plan but it's been talked about -- /Jacob Carlborg
Re: Catching Errors
On 2017-01-19 16:46, Jack Stouffer wrote: Or, you can mark that unit test block as @system and have @safe tests in another block. No, this is for when the framework is catching the exception. It needs to wrap _all_ unit test blocks in a try-catch. If an assert fails I want the rest of the unit tests to be able to run. -- /Jacob Carlborg
Re: Release Candidate 2.073.0-rc1
On 2017-01-19 14:57, Jacob Carlborg wrote: The changelog is missing an entry to the new default Ddoc theme. I'll see if I can add that. Do we want an image, HTML page or something to show? https://github.com/dlang/dlang.org/pull/1558 -- /Jacob Carlborg
Re: What do you use to generate documentation?
On 2017-01-19 19:45, Suliman wrote: It's seems that there is no any big changes in this deal. The upcoming 2.073.0 (now in release candidate) has a completely new default Ddoc theme. -- /Jacob Carlborg
Re: What do you use to generate documentation?
On 2013-03-13 10:35, Andrea Fontana wrote: I've tried to build documentation using ddoc format and dmd. dmd -c -D -o- ... Generated documentation looks ugly and without stylesheet. Am I wrong? Yes :). The upcoming 2.073.0 (now in release candidate) has a completely new default Ddoc theme. -- /Jacob Carlborg
Re: D for scripting?
On 1/20/17 3:59 AM, 岩倉 澪 wrote: I feel like the shebang is totally worth it if I could name my file without .d and symlink to it. Would it be reasonable to change rdmd to allow these features? I'd be happy to look into writing a patch for it if it wouldn't be a waste of time. It would be worth it. I think a fix takes some thinking because if I remember correctly the compiler does not accept files without an extension as input. So rdmd would need to use a workaround - e.g. create a temporary symlink, compile, and remove the symlink. -- Andrei
D for scripting?
Last weekend I tried porting some old shell scripts to D, as I think D is actually extremely well suited as a shell script replacement. My scripts are so much more robust now and do things like rolling back on errors and having debug mode, all with roughly the same amount of lines as the flimsy old shell scripts. I have two points of feedback regarding rdmd: * If you name your script without a .d extension, rdmd fails saying the module is in script.d which cannot be read * rdmd doesn't seem to play nice with symlinks I keep my scripts in ~/scripts so that I can just pull them from github and go on my merry way, with symlinks in /usr/local/bin, but rdmd doesn't -I the real directory, it does -I/usr/local/bin, and if I symlink a script.d as /usr/local/bin/script, it can't find the module. I can pass -I/home/mio/scripts on the shebang line at least... Furthermore, if I -J a folder with string imports I would have to type out the fully qualified path just like with -I. It would be so much more convenient if rdmd would follow the symlink to the scripts directory, change the working directory, and then compile, or something like that. Is anyone else using D for scripting? I feel like the shebang is totally worth it if I could name my file without .d and symlink to it. Would it be reasonable to change rdmd to allow these features? I'd be happy to look into writing a patch for it if it wouldn't be a waste of time.
Re: Phobos: Determining number of hours or minutes or seconds till now
On 20/01/2017 9:29 AM, Rene Zwanenburg wrote: On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote: Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual calculations but from Phobos functions. You can get a duration by subtracting two timestamps. For example: auto delta = (Clock.currTime - timeStamp).total!"seconds"; As per the documentation this is wrong for anything beyond a few weeks. Although I have no idea if that's the case implementation wise.
Re: Catching Errors
On Friday, 20 January 2017 at 02:11:41 UTC, Adam D. Ruppe wrote: On Friday, 20 January 2017 at 01:24:18 UTC, Jon Degenhardt wrote: Is there a place in the docs that describe the difference between errors and exceptions? As to the particular example, why is it unsafe to recover from attempting to access memory past the end of the array, as long as the access was prevented? It is just that Errors are not necessarily *thrown*. The implementation is allowed to immediately abort on them too - your catch has no guarantee to actually run, whereas with Exceptions, they are. Thanks, that's helpful. I hadn't seen it before, but the documentation for Object.Error and Object.Exception is clear on the distinction (https://dlang.org/phobos/object.html#.Error). There the intent is clear that Object.Error is for "unrecoverable runtime errors", and "not safe to catch and handle". An aside - The documentation I had read, in the Error Handling chapter of the Language Reference, https://dlang.org/spec/errors.html, is less crisp about this distinction than the documentation for Object.Error. Perhaps an opportunity to improve this part of the documentation. --Jon
[Issue 16697] Extend IsExpression to accept __vector as a TypeSpecialization
https://issues.dlang.org/show_bug.cgi?id=16697 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 16697] Extend IsExpression to accept __vector as a TypeSpecialization
https://issues.dlang.org/show_bug.cgi?id=16697 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/f298a8ca60fab15ac5a552f2818daf9724f2e0df Fix issue 16697 - Accept __vector as type specialization in is() https://github.com/dlang/dmd/commit/2853931c19f4f94b134da8bfa2867aba48d8a1c2 Merge pull request #6458 from LemonBoy/b16697 Fix issue 16697 - Accept __vector as type specialization in is() --
Re: Making .exe
On Thursday, 19 January 2017 at 21:47:53 UTC, Dlearner wrote: Yo! Okay I did this and I run the .exe and it works, but if I try to copy/paste it on my desktop and run it, it (obviously) doesn't work. Is there a way to somehow compile the source, .dll's and image file that I'm using together into one executable? If your app has dependencies, you should bundle them all up and distribute it all as a zip file or installer. That's not specific to D.
Re: Catching Errors
On Friday, 20 January 2017 at 01:24:18 UTC, Jon Degenhardt wrote: Is there a place in the docs that describe the difference between errors and exceptions? As to the particular example, why is it unsafe to recover from attempting to access memory past the end of the array, as long as the access was prevented? It is just that Errors are not necessarily *thrown*. The implementation is allowed to immediately abort on them too - your catch has no guarantee to actually run, whereas with Exceptions, they are.
Re: Catching Errors
On Fri, 20 Jan 2017 01:24:18 +, Jon Degenhardt wrote: > As > to the particular example, why is it unsafe to recover from attempting > to access memory past the end of the array, as long as the access was > prevented? Because array bounds checking seems to be intended as an aid to find bugs, a tool that you use during testing and development and turn off for production. Disabling array bounds checks is too dangerous for me.
Re: Catching Errors
On Thu, 19 Jan 2017 14:29:46 +, Jack Stouffer wrote: > From what I understand, the difference between an Exception and and > Error is that Errors signal your program has entered into an invalid > state. That's the intent, but I don't think that matches reality. > For example, going past the end of an array and attempting to > access that memory. The program is in a well-defined state. In production, I want to catch and log that problem, move that work item into the dead letter queue, and move on. There are other problems that lead to the program being in an unpredictable, possibly unusable state. This is primarily when the runtime produces an Error regarding its internal state (as opposed to parameter validation).
with not working wtih BitFlags
struct EnumToFlags(alias E) { template opDispatch(string Name) { enum opDispatch = 1 << __traits(getMember, E, Name); }; }; enum X { a,b,c } auto q = EnumtoFlags!X; auto m = q.a; with(q) { auto m = a; } a undefined. Any way to get it to work? Maybe a full blowing string mixin is needed to generate the flag enum?
Re: cannot alias array ;/
On Thursday, 19 January 2017 at 12:50:06 UTC, John Colvin wrote: On Thursday, 19 January 2017 at 07:48:03 UTC, Jot wrote: alias a = myarray[k]; fails myarray is a multidimensial array that I want to reduce writing it every time but D complains that it can't alias it. I simply want it to do a direct substitution, nothing fancy, just to reducing typing. Simplest solution, has brackets that you may not like: void main() { int[][] a = [[1]]; size_t k = 0; ref foo() { return a[k]; }; foo() = [3]; assert(a == [[3]]); } I just use a pointer and dereference ;/
Re: Catching Errors
On Friday, 20 January 2017 at 01:24:18 UTC, Jon Degenhardt wrote: On Thursday, 19 January 2017 at 14:29:46 UTC, Jack Stouffer wrote: [...] I think this is an area of D I haven't explored yet. Is there a place in the docs that describe the difference between errors and exceptions? As to the particular example, why is it unsafe to recover from attempting to access memory past the end of the array, as long as the access was prevented? --Jon It indicates a programming error. If you attempted to read past the end, what other invalid data did you end up actually succeeding reading?
Re: Catching Errors
On Thursday, 19 January 2017 at 14:29:46 UTC, Jack Stouffer wrote: From what I understand, the difference between an Exception and and Error is that Errors signal your program has entered into an invalid state. For example, going past the end of an array and attempting to access that memory. On the flip side, Exceptions signal that something out of the ordinary happened, but with proper handling the program can go on it's merry way. An example being entering 13 as a month in a std.datetime.Date. If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? I think this is an area of D I haven't explored yet. Is there a place in the docs that describe the difference between errors and exceptions? As to the particular example, why is it unsafe to recover from attempting to access memory past the end of the array, as long as the access was prevented? --Jon
Re: iterating through members of bitfields
On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote: I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works. Interesting, could you provide a working example?
[Issue 17102] std.write.file generates a segmentation fault when the file name is a string with a default value
https://issues.dlang.org/show_bug.cgi?id=17102 Jack Stoufferchanged: What|Removed |Added CC||j...@jackstouffer.com Hardware|x86 |All OS|Mac OS X|All Severity|enhancement |normal --
[Issue 16323] std.utf.decodeBack
https://issues.dlang.org/show_bug.cgi?id=16323 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/944e7da50b80d916a2e0edd5b4f8d886de8b45b5 Fix issue #16323 - implement utf.encodeBack function https://github.com/dlang/phobos/commit/ffba5a2a4d82b2eb3fd7744fb0fb8f0cb439bec1 Merge pull request #5043 from byebye/issue_16323 Fix issue #16323 - implement utf.encodeBack function --
[Issue 16210] std.utf.byUTF can be made into a bidirectional range
https://issues.dlang.org/show_bug.cgi?id=16210 Issue 16210 depends on issue 16323, which changed state. Issue 16323 Summary: std.utf.decodeBack https://issues.dlang.org/show_bug.cgi?id=16323 What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
Re: Making .exe
On Thursday, 19 January 2017 at 20:56:41 UTC, Nemanja Boric wrote: On Thursday, 19 January 2017 at 18:58:31 UTC, Dlearner wrote: [...] Hello! The binary should be in the working directory: ``` ➜ dub init Package recipe format (sdl/json) [json]: Name [test-dub]: Description [A minimal D application.]: Author name [Nemanja]: License [proprietary]: Copyright string [Copyright © 2017, Nemanja]: Add dependency (leave empty to skip) []: Successfully created an empty project in '/home/burgos/work/test-dub'. Package sucessfully created in . ➜ echo 'import std.stdio;\nvoid main() { writeln("Hello!"); }' > source/app.d ➜ dub --build=release Performing "release" build using dmd for x86_64. test-dub ~master: building configuration "application"... Linking... Running ./test-dub Hello! ➜ ./test-dub Hello! ➜ ll total 820K -rw-rw-r-- 1 burgos burgos 168 Jan 19 21:53 dub.json drwxrwxr-x 2 burgos burgos 4,0K Jan 19 21:52 source -rwxrwxr-x 2 burgos burgos 811K Jan 19 21:53 test-dub <- the executable ``` You can ommit --build=release - this makes a "release mode" binary (without assertions and bounds check), which is a faster & smaller version of the binary, but with less sanity checks. Yo! Okay I did this and I run the .exe and it works, but if I try to copy/paste it on my desktop and run it, it (obviously) doesn't work. Is there a way to somehow compile the source, .dll's and image file that I'm using together into one executable?
Re: Release Candidate 2.073.0-rc1
On Thursday, 19 January 2017 at 19:22:07 UTC, Rainer Schuetze wrote: On 19.01.2017 08:32, Suliman wrote: http://dlang.org/changelog/2.073.0.html#mscrtlib-option How can I set this flag in dub.json? I tried: "dflags": [ "-mscrt=msvcrt" ] but got error: Error: unrecognized switch '-mscrt=msvcrt' Ouch, the switch is actually called -mscrtlib. We need to fix the documentation... Thanks! Now it's compile. What version of cruntime (I tried: libcmtd, msvcrt msvcrtd) I should use to prevent depending my project on `msvcr120.dll`. Now when I try run vibed-based project on another PC it's give me error about absent `msvcr120.dll`.
Re: Making .exe
On Thursday, 19 January 2017 at 18:58:31 UTC, Dlearner wrote: Hey! I wrote a little program that has an image bounce around and change colours, like the old DVD player screensavers. How can I build this as a little .exe file that I can send to someone? In the dub documentation there is something like `dub --build=`, but I'm not entirely sure what this does. Thanks! Hello! The binary should be in the working directory: ``` ➜ dub init Package recipe format (sdl/json) [json]: Name [test-dub]: Description [A minimal D application.]: Author name [Nemanja]: License [proprietary]: Copyright string [Copyright © 2017, Nemanja]: Add dependency (leave empty to skip) []: Successfully created an empty project in '/home/burgos/work/test-dub'. Package sucessfully created in . ➜ echo 'import std.stdio;\nvoid main() { writeln("Hello!"); }' > source/app.d ➜ dub --build=release Performing "release" build using dmd for x86_64. test-dub ~master: building configuration "application"... Linking... Running ./test-dub Hello! ➜ ./test-dub Hello! ➜ ll total 820K -rw-rw-r-- 1 burgos burgos 168 Jan 19 21:53 dub.json drwxrwxr-x 2 burgos burgos 4,0K Jan 19 21:52 source -rwxrwxr-x 2 burgos burgos 811K Jan 19 21:53 test-dub <- the executable ``` You can ommit --build=release - this makes a "release mode" binary (without assertions and bounds check), which is a faster & smaller version of the binary, but with less sanity checks.
DConf 2017 now open for registration
$250 for Early Bird tickets! http://dconf.org/2017/registration.html
Re: Phobos: Determining number of hours or minutes or seconds till now
On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote: Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual calculations but from Phobos functions. You can get a duration by subtracting two timestamps. For example: auto delta = (Clock.currTime - timeStamp).total!"seconds";
Re: Release Candidate 2.073.0-rc1
On 19.01.2017 20:22, Rainer Schuetze wrote: On 19.01.2017 08:32, Suliman wrote: http://dlang.org/changelog/2.073.0.html#mscrtlib-option How can I set this flag in dub.json? I tried: "dflags": [ "-mscrt=msvcrt" ] but got error: Error: unrecognized switch '-mscrt=msvcrt' Ouch, the switch is actually called -mscrtlib. We need to fix the documentation... https://github.com/dlang/dmd/pull/6471 https://github.com/dlang/dlang.org/pull/1557
Re: Release Candidate 2.073.0-rc1
On 19.01.2017 08:32, Suliman wrote: http://dlang.org/changelog/2.073.0.html#mscrtlib-option How can I set this flag in dub.json? I tried: "dflags": [ "-mscrt=msvcrt" ] but got error: Error: unrecognized switch '-mscrt=msvcrt' Ouch, the switch is actually called -mscrtlib. We need to fix the documentation...
Making .exe
Hey! I wrote a little program that has an image bounce around and change colours, like the old DVD player screensavers. How can I build this as a little .exe file that I can send to someone? In the dub documentation there is something like `dub --build=`, but I'm not entirely sure what this does. Thanks!
Re: What do you use to generate documentation?
On Thursday, 19 January 2017 at 18:45:05 UTC, Suliman wrote: It's seems that there is no any big changes in this deal. I made my doc gen since then and ddox has grown since then as well. Only other major change is ddoc just got new styling in the newest dmd beta. Still the same ddoc, just nicer looking out of the box. ok. I know that there is a lot of other docs-gen, but who can give me answer about flag `-c` why its used? dmd -c means do not link the executable. You use it when just creating object files (for separate linking) or when you don't want the program generated for some other reason. Since the command is just meant to generate docs, it used -c to skip generating the exe too.
Re: What do you use to generate documentation?
On Thursday, 19 January 2017 at 18:09:20 UTC, Basile B. wrote: On Thursday, 19 January 2017 at 15:20:37 UTC, Suliman wrote: What do dflag: `-c do not link`. Should I pass it during the generation of the docs? dub is append it's automatically, but if I want to generate new docs every rebuild of app what is the reason to use this flag? Oh no 2013 !! I thought it was a hot conversation. I've been trapped. Why didn't you create your own subject ? It's seems that there is no any big changes in this deal. ok. I know that there is a lot of other docs-gen, but who can give me answer about flag `-c` why its used?
Re: What do you use to generate documentation?
On Thursday, 19 January 2017 at 15:20:37 UTC, Suliman wrote: What do dflag: `-c do not link`. Should I pass it during the generation of the docs? dub is append it's automatically, but if I want to generate new docs every rebuild of app what is the reason to use this flag? Oh no 2013 !! I thought it was a hot conversation. I've been trapped. Why didn't you create your own subject ?
[Issue 17109] std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 --- Comment #5 from Sophie--- (In reply to Jack Stouffer from comment #4) > (In reply to Sophie from comment #3) > The problem is, if I just get strings, then std.csv is useless because I can > just do this > > auto input = File("file.csv"); > auto data = input.byLine.map!(a => splitter(a, ',')); Not that I don't understand your argument, but be aware the example is not at all equivalent to parsing a CSV; it does not handle quoted columns or escaped metacharacters. Null for nullable types would work, I think. I don't think using nan is ideal but it's probably the best solution for floats, the issue is that integers would have no such capability and this would an unusual inconsistency to have between the numeric types. Perhaps when a type other than string is expected, it will be made nullable if it's not already and null will be returned when the column is blank? --
Re: What do you use to generate documentation?
On Thursday, 19 January 2017 at 17:06:39 UTC, Nemanja Boric wrote: On Thursday, 19 January 2017 at 16:47:07 UTC, Basile B. wrote: [...] I've submitted few PRs but they never got merged. We're maintaining, unofficially, fork that does compile and it's available at: https://github.com/sociomantic-tsunami/harbored-mod Good to know !
[Issue 17109] std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 --- Comment #4 from Jack Stouffer--- (In reply to Sophie from comment #3) > It's a missing value, but in the case of numeric types a missing value is > simply one example of a malformed value. I think the better approach in the > code you used as an example would be to not expect the CSV logic to handle > malformed floats. Use the CSV parser to extract strings, and then your code > should assume responsibility for validating and handling malformed inputs. The problem is, if I just get strings, then std.csv is useless because I can just do this auto input = File("file.csv"); auto data = input.byLine.map!(a => splitter(a, ',')); It would be faster too, as I'm just getting slices over byLine's buffer rather than creating a new Tuple. But, returning T.init probably is a wrong choice because int.init == 0. Perhaps the replacement logic can be confined to nullable types and types with nan? --
Re: Android LDC in a Container
On Sunday, 15 January 2017 at 17:40:01 UTC, Andre Pany wrote: Hi, on Dockerhub I published a repository which makes it really easy to develop Android applications using LDC and Joakims work. The repository contains Android 1.1.0 beta from https://github.com/joakim-noah/android/releases and also the NDK from google. By using this command, you will have a shell containing all you need to compile the source files: docker run --rm -it -v c:/D/projects:/projects andre2007/ldc-android sh This command will also mount C:\D\projects from your host OS to the container path /projects. On linux / mac you will have to adapt the mount source path. You need the Google Android SDK on your host system installed to build the APK and test the application. More information on building the demo applications you can find here: https://wiki.dlang.org/Build_LDC_for_Android A Wiki update will follow with detailed information. Kind regards André Hi, I added a WIKI page with all information you need to create your first Android application using LDC in a Docker container. Although the page describes the process on a windows system, it also work on Linux and Mac just by adapting the directory paths. https://wiki.dlang.org/Build_Android_Apps_using_LDC_in_a_Container Kind regards André
Re: std.traits vcs __traits
On Tuesday, 17 January 2017 at 18:22:06 UTC, Nordlöw wrote: https://github.com/dlang/phobos/pull/5038 This makes (at least) UnsignedTypeOf unused in Phobos, and it's undocumented but public. There are LREFs in the std.traits docs under the SomethingTypeOf section - none of these links go anywhere AFAICT. Presumably the links should be removed from the docs (independently of the above pull), but should unused undocumented public templates also be removed?
[Issue 17109] std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 --- Comment #3 from Sophie--- It's a missing value, but in the case of numeric types a missing value is simply one example of a malformed value. I think the better approach in the code you used as an example would be to not expect the CSV logic to handle malformed floats. Use the CSV parser to extract strings, and then your code should assume responsibility for validating and handling malformed inputs. --
Re: What do you use to generate documentation?
On Thursday, 19 January 2017 at 16:47:07 UTC, Basile B. wrote: On Wednesday, 13 March 2013 at 09:35:18 UTC, Andrea Fontana wrote: [...] I use harbored-mod (https://github.com/kiith-sa/hmod-dub). What I like about it: 1/ I'm not good with web things. The default styling is Okay for me so I don't have to lost time at writing some templates or others css files. 2/ I can call it in a single step from my IDE. For example after installing a static library, if i don't understand the API: - a double click to generate, using a custom tool, the doc using an IDE environment var that symbolize the sources files of the lib. - a double click to open the newly generated doc in the web-browser. It's really a no-brainer. Unfortunately It's not maintained anymore, but I'll go back to harbored the day the fork won't compile anymore. I've submitted few PRs but they never got merged. We're maintaining, unofficially, fork that does compile and it's available at: https://github.com/sociomantic-tsunami/harbored-mod
[Issue 17109] std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 --- Comment #2 from Jack Stouffer--- (In reply to Sophie from comment #1) > I think this is the correct behavior. The empty string is not valid as a > floating point value, nan or otherwise. This is going to sound dramatic, but not correctly handling missing values in a CSV makes std.csv dead on arrival. The truth of the matter is that missing values in CSVs are the rule and not the exception. Python's pandas does this correctly, and so should we. --
Re: Catching Errors
On Thursday, 19 January 2017 at 14:29:46 UTC, Jack Stouffer wrote: From what I understand, the difference between an Exception and and Error is that Errors signal your program has entered into an invalid state. For example, going past the end of an array and attempting to access that memory. On the flip side, Exceptions signal that something out of the ordinary happened, but with proper handling the program can go on it's merry way. An example being entering 13 as a month in a std.datetime.Date. If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? Ok, very visible idiotic moment here: This is already the rule.
Re: What do you use to generate documentation?
On Wednesday, 13 March 2013 at 09:35:18 UTC, Andrea Fontana wrote: I've tried to build documentation using ddoc format and dmd. dmd -c -D -o- ... Generated documentation looks ugly and without stylesheet. Am I wrong? I expected a phobos-like documentation. So, what do you use to generate your D docs? Doxygen or something else? I use harbored-mod (https://github.com/kiith-sa/hmod-dub). What I like about it: 1/ I'm not good with web things. The default styling is Okay for me so I don't have to lost time at writing some templates or others css files. 2/ I can call it in a single step from my IDE. For example after installing a static library, if i don't understand the API: - a double click to generate, using a custom tool, the doc using an IDE environment var that symbolize the sources files of the lib. - a double click to open the newly generated doc in the web-browser. It's really a no-brainer. Unfortunately It's not maintained anymore, but I'll go back to harbored the day the fork won't compile anymore.
[Issue 12679] std.typecons.Maybe
https://issues.dlang.org/show_bug.cgi?id=12679 Nick Treleavenchanged: What|Removed |Added CC||n...@geany.org --- Comment #2 from Nick Treleaven --- Jakob Ovrum's Option range (closed due to inactivity): https://github.com/dlang/phobos/pull/3915 --
Re: Catching Errors
On Thursday, 19 January 2017 at 15:43:26 UTC, Jacob Carlborg wrote: On 2017-01-19 15:29, Jack Stouffer wrote: If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? There's the issue with AssertError, which is useful for a unit test framework to catch. Perhaps it could throw an AssertException instead when the "unittest" flag is passed. Just slap @trusted on the part of the framework that catches them. Atila
[Issue 17109] std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 Jack Stoufferchanged: What|Removed |Added Hardware|x86 |All OS|Mac OS X|All Severity|enhancement |normal --
[Issue 17109] New: std.csv chokes on empty columns when parsing to struct
https://issues.dlang.org/show_bug.cgi?id=17109 Issue ID: 17109 Summary: std.csv chokes on empty columns when parsing to struct Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: j...@jackstouffer.com import std.csv; import std.typecons; import std.stdio; static immutable csv_string = "aaa,1.1,bbb\nstring,,another string"; void main() { foreach(record; csvReader!(Tuple!(string, float, string))(csv_string)) { writeln(record[0], record[1], record[2]); } } std.csv.CSVException@/opt/compilers/dmd2/include/std/csv.d(1096): Floating point conversion error for input "". It should return T.init when it encounters an empty string. --
Re: Catching Errors
On Thursday, 19 January 2017 at 15:43:26 UTC, Jacob Carlborg wrote: On 2017-01-19 15:29, Jack Stouffer wrote: If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? There's the issue with AssertError, which is useful for a unit test framework to catch. Perhaps it could throw an AssertException instead when the "unittest" flag is passed. Or, you can mark that unit test block as @system and have @safe tests in another block.
Re: Release Candidate 2.073.0-rc1
On 2017-01-19 16:21, Martin Nowak wrote: It seems sufficiently different to not worry about a Win only switch, it's used for selecting different flavours of MS libcrt (threaded, debug...). IMO we should try to depart with hard-coding linker flags into the compiler. Fair enough. -- /Jacob Carlborg
Re: Catching Errors
On 2017-01-19 15:29, Jack Stouffer wrote: If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? There's the issue with AssertError, which is useful for a unit test framework to catch. Perhaps it could throw an AssertException instead when the "unittest" flag is passed. -- /Jacob Carlborg
Re: What do you use to generate documentation?
What do dflag: `-c do not link`. Should I pass it during the generation of the docs? dub is append it's automatically, but if I want to generate new docs every rebuild of app what is the reason to use this flag?
Re: Release Candidate 2.073.0-rc1
On Thursday, 19 January 2017 at 07:43:29 UTC, Jacob Carlborg wrote: About the new -mscrt=libname flag. Could we have a more generic name of the flag that would fit for other platforms to specify the C library, i.e. Musl instead of GNU? Or is this something different? It seems sufficiently different to not worry about a Win only switch, it's used for selecting different flavours of MS libcrt (threaded, debug...). IMO we should try to depart with hard-coding linker flags into the compiler. We had some ideas to make the config file more flexible. https://issues.dlang.org/show_bug.cgi?id=7044#c16 https://issues.dlang.org/show_bug.cgi?id=7044#c30
[Issue 15256] Data races with arrays allowed in @safe code
https://issues.dlang.org/show_bug.cgi?id=15256 Jack Stoufferchanged: What|Removed |Added CC||j...@jackstouffer.com --- Comment #1 from Jack Stouffer --- This is more an issue with shared than with @safe. AFAIK @safe makes no guarantees when it comes to data races. --
Re: Catching Errors
On Thursday, 19 January 2017 at 14:29:46 UTC, Jack Stouffer wrote: From what I understand, the difference between an Exception and and Error is that Errors signal your program has entered into an invalid state. For example, going past the end of an array and attempting to access that memory. On the flip side, Exceptions signal that something out of the ordinary happened, but with proper handling the program can go on it's merry way. An example being entering 13 as a month in a std.datetime.Date. If this is the case, would it not make sense to make it illegal to catch Errors in @safe code? I would say yes. This sounds plausible.
Catching Errors
From what I understand, the difference between an Exception and and Error is that Errors signal your program has entered into an invalid state. For example, going past the end of an array and attempting to access that memory. On the flip side, Exceptions signal that something out of the ordinary happened, but with proper handling the program can go on it's merry way. An example being entering 13 as a month in a std.datetime.Date. If this is the case, would it not make sense to make it illegal to catch Errors in @safe code?
Re: Language server protocol implementation for D
On Wednesday, 18 January 2017 at 09:31:49 UTC, xtreak wrote: Rust is making good progress on the IDE aspect with the announcement : http://www.jonathanturner.org/2017/01/rls-alpha-release.html. HN discussion : https://news.ycombinator.com/item?id=1348 It will be good to see the protocol implemented so that many tools and IDEs can use the interface to provide better tooling for development. https://github.com/Microsoft/language-server-protocol https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations A rust language server has also landed in GNOME Builder IDE and now rust is a first candidate in Buider (the number one Linux/GNOME IDE).
[Issue 17108] Associative array byKeyValue is unsafe
https://issues.dlang.org/show_bug.cgi?id=17108 Jack Stoufferchanged: What|Removed |Added Keywords||safe --
[Issue 17108] New: Associative array byKeyValue is unsafe
https://issues.dlang.org/show_bug.cgi?id=17108 Issue ID: 17108 Summary: Associative array byKeyValue is unsafe Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: j...@jackstouffer.com void main () @safe { int[string] aa; foreach (val; aa.byKeyValue) ++aa[val.key]; } /d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue' /d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.empty' /d399/f220.d(4): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.popFront' /d399/f220.d(5): Error: @safe function 'D main' cannot call @system function 'object.byKeyValue!(int[string], string, int).byKeyValue.Result.front.Pair.key' --
Phobos: Determining number of hours or minutes or seconds till now
Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual calculations but from Phobos functions.
Re: Release Candidate 2.073.0-rc1
On 2017-01-18 14:48, Martin Nowak wrote: First release candidate for 2.073.0. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.073.0.html The changelog is missing an entry to the new default Ddoc theme. I'll see if I can add that. Do we want an image, HTML page or something to show? -- /Jacob Carlborg
[Issue 16564] KRRegion.empty sometimes returns Ternary.no
https://issues.dlang.org/show_bug.cgi?id=16564 --- Comment #1 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/8a69b104513d5f95e31be65b04a6502f559a95c0 fix issue 16564 https://github.com/dlang/phobos/commit/bb27aa7bd2b6863d50c3f19016ad8f4476709748 Merge pull request #5029 from somzzz/issue_16564 fix issue 16564 - KRRegion.empty sometimes returns Ternary.no --
[Issue 7016] local import does not create -deps dependency
https://issues.dlang.org/show_bug.cgi?id=7016 --- Comment #28 from Vladimir Panteleev--- (In reply to RazvanN from comment #27) > -> add another compiler flag: "-rdeps" (or maybe a more inspired name) which >will recurs through all the dependencies, excluding druntime or phobos > imports. >The rationale behind this is that both druntime and phobos have circular > imports >which will cause the recursive implementation to fail; also having just 1 > phobos >import will lead to a cascade of imports which will be hard to follow. Hard-coding blacklists for druntime and phobos into the compiler sounds wrong. (People may need to build D against other libraries with the same issues, or build against Phobos from source - i.e. without linking to libphobos2.) If this is done, there would probably need to be ways to add to or remove from that list. Either way, it sounds like this will also result is a huge slowdown... > Any better ideas? Would it be a far stretch from this to add a switch to just do code generation whenever an import is done, whether it's in semantic3 or earlier? Meaning, move rdmd into dmd itself. I think all we need is a switch to enable this behavior (e.g. -r, for recursive compilation), and switches to add or remove from the list of packages that will be excluded from compilation (default being std.*, etc.* and core.*). This will make rdmd much faster, too, since it will no longer need to ask the compiler to perform semantics just to get a list of modules to compile and do it all over again during the real compilation. --
[Issue 7016] local import does not create -deps dependency
https://issues.dlang.org/show_bug.cgi?id=7016 --- Comment #27 from RazvanN--- Running semantic3 recursively on dependencies will end up in an infinite loop when there are circular imports. So, I propose the following solution: -> the current -deps implementation should remain untouched and this will print all the direct dependencies. -> add another compiler flag: "-rdeps" (or maybe a more inspired name) which will recurs through all the dependencies, excluding druntime or phobos imports. The rationale behind this is that both druntime and phobos have circular imports which will cause the recursive implementation to fail; also having just 1 phobos import will lead to a cascade of imports which will be hard to follow. Any better ideas? RazvanN --
Re: Vision document for H1 2017
On Wednesday, 4 January 2017 at 19:22:33 UTC, Andrei Alexandrescu wrote: We release a brief Vision document summarizing the main goals we plan to pursue in the coming six months. This half we are focusing on three things: safety, lifetime management, and static introspection. https://wiki.dlang.org/Vision/2017H1 I guess the 2017H1 document is quite final now. Why not turn that into a blog post? It could be official (by the leaders) or informal (interview with Andrei).
Re: Getters/setters generator
On Wednesday, 18 January 2017 at 21:57:42 UTC, Andrei Alexandrescu wrote: On 1/18/17 5:29 PM, Mark wrote: I see. Is there a way to call invariant() of a class/struct directly? That would obviate the need for a particular predicate (copy the class state, run the setter, check if invariants are satisfied and restore previous state if they aren't). It seems painfully obvious the right way is a guarded assignment and anything else would be a more or less painful workaround. -- Andrei I agree. I'm just a bit unsettled by the slight code duplication that would ensue.
Re: Plugin for 1C:Enterprise in dmd
On Wednesday, 18 January 2017 at 23:33:15 UTC, Dmitry Olshansky wrote: On 1/18/17 1:00 PM, MGW wrote: Sourse files https://github.com/MGWL/QtE5/tree/master/examples/1C_vk
[Issue 8471] std.stdio.readf should be @trusted
https://issues.dlang.org/show_bug.cgi?id=8471 --- Comment #8 from Jakub Łabaj--- Sorry, I'm not sure what you mean by that - what are the next steps to do here? --
Re: version identifier hygiene
Moving from digitalmars.D.Learn... tl;dr It seems to be a good guideline to always name-mangle your version identifiers with the package (and module) name. Otherwise, you will risk confusions and conflicts on the build line. Ali On 01/16/2017 11:23 PM, Jacob Carlborg wrote: On 2017-01-16 21:04, Ali Çehreli wrote: It is plausible to compile and link the sources of multiple packages on the same command line at the same. (I'm not sure whether this is required for e.g. LLVM's link-time optimization (LTO) but I think it helps the compiler as well.) The trouble is, the version identifiers used by one package may look strange on the command line and even contradict with another package's: dmd -version=use-fibers a/a.d b/b.d use-fibers? Who is using fibers? Does it have any effect on the other package as well? So, I think it's a good idea to name-mangle version identifiers with prefixed package names (a-use-fibers instead of use-fibers): dmd -version=a-use-fibers a/a.d b/b.d What do you think? Is there a way of managing this from the outside? I couldn't do this for a package by introducing a new file that "translates" to what it understands: version (a-use-fibers) { version=use-fibers; } I tried putting it in a module and importing by all sources of package 'a' but version did not have affect on the modules that imported it. Yeah, I think it only applies to the module it's set in. String mixins would probably work but it already feels too intrusive to "fix" third party packages like that. I don't think it's possible to fix from the outside. I would rather see that the library is adopted for that. Or even better using some kind of config file. With Dub it's possible to generate something like a config file with preGenerateCommands. That config file could look something like: module liba.config; version (liba_use_fibers) enum useFibers = true; else enum useFibers = false; Then the library would use "static if" instead of "version" to pick the correct implementation. Or if the user of the library could supply the config file from the beginning then no version statements are needed. Not sure if that's possible though.
Re: Mixin template confusion / compiler error.
On 01/19/2017 01:06 AM, Ali Çehreli wrote: > In other words, D's string > mixins are the same as C's macros. I was testing you! :p I meant "NOT the same as". :p Ali
Re: Mixin template confusion / compiler error.
On 01/19/2017 12:41 AM, Chris Katko wrote: > 1 - Is there any way TO get the output 64,64? You can mixin the entire statement. I used the ~ operator but you can use format() or the return value of a function as well: mixin("array_t!(" ~ sizer2D!() ~ ") case2;"); // ... mixin("array3_t!(" ~ sizer2D!() ~ ") case6;"); With function call: mixin(makeDeclaration(/* ... */)); > 2 - Is this very non-standard / unrecommended practice and there's a > much better way to do this? There are other options like using literals like 64. Perhaps an AliasSeq!(64, 64) could be useful. > enum MAP_SIZE > { > PLANET = 2048, > SHIP = 256, > SHUTTLE = 64, > (etc) > } //this could also be translated to an array lookup. ala SHIP = 0, > SHUTTLE = 1, etc. with an array holding the sizes. > > and then I pass MAP_SIZE, into a map class, which then builds layers > into that map based on the MAP_SIZE. The layers are statically sized at > compile-time by translating a given MAP_SIZE down to the actual required > dimensions. > > So in plain English: Based on a MAP_SIZE, the inner structures are all > sized appropriately at compile-time. I think the best way of doing this is by producing the entire code as string but look at the implementation of std.bitmanip.bitfields to see how it's actually a mixin template than contains an enum, I think to prevent name-polluting the scope that it's mixed in. > "no commas" seem so arbitrary from an abstract, novice > perspective. I think AliasSeq is your best bet in that case. > What if I was pre-processing English statements which include > commas? Of course you can do that as strings but mixed-in code must obey the spec and it must be "a valid StatementList". In other words, D's string mixins are the same as C's macros. Ali
Re: Mixin template confusion / compiler error.
On Thursday, 19 January 2017 at 08:41:53 UTC, Chris Katko wrote: Thank you! So: 1 - Is there any way TO get the output 64,64? Would this work for you? import std.meta; alias sizer1D = AliasSeq!(64); alias sizer2D = AliasSeq!(64,64); array_t!sizer2D caseX; array2_t!sizer1D caseY;
Re: switch statement with variable branches
On Thursday, 19 January 2017 at 01:22:56 UTC, Yuxuan Shui wrote: Somehow I can't use ubyte variables behind 'case', but ulong works fine. Why is that? void main() { alias TestType = ulong; // won't compile if = ubyte import std.stdio; TestType a,b,c; readf("%s %s %s ", , , ); switch(c){ case a: writeln("a");break; case b: writeln("b");break; default: assert(false); } } It is a bug that this code compiled. Case Variables can only be used on const values, to prevent mutation of them inside the switch itself. try to make the type a const ubyte.
Re: Mixin template confusion / compiler error.
Thank you! So: 1 - Is there any way TO get the output 64,64? It seems like being able to get a comma out of a mixin is a useful feature. 2 - Is this very non-standard / unrecommended practice and there's a much better way to do this? For example, in my actual code, I have an enumerator: enum MAP_SIZE { PLANET = 2048, SHIP = 256, SHUTTLE = 64, (etc) } //this could also be translated to an array lookup. ala SHIP = 0, SHUTTLE = 1, etc. with an array holding the sizes. and then I pass MAP_SIZE, into a map class, which then builds layers into that map based on the MAP_SIZE. The layers are statically sized at compile-time by translating a given MAP_SIZE down to the actual required dimensions. So in plain English: Based on a MAP_SIZE, the inner structures are all sized appropriately at compile-time. So, for example: map_t!(MAP_SIZE.SHIP) x; goes into map_t(MAP_SIZE s) { layer_t!(mixin(sizer2D!(s))) layer; } which becomes map_t(MAP_SIZE s) { layer_t!(64,64) layer; } and in layer_t: layer_t(int width, int height) { int [width][height] data; } Is there a different way to go about this? Should I be building some sort of function inside a template that "decides" / "translates" a passed template parameter MAP_SIZE to width and height values? I guess I could try putting the mixin inside layer_t and put the values into the square brackets, instead of commas. But again, "no commas" seem so arbitrary from an abstract, novice perspective. What if I was pre-processing English statements which include commas? Thank you for your assistance. I appreciate it.
Re: Release Candidate 2.073.0-rc1
On Wednesday, 18 January 2017 at 13:48:06 UTC, Martin Nowak wrote: First release candidate for 2.073.0. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.073.0.html Comes with a couple of more fixes: https://github.com/dlang/dmd/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/druntime/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/phobos/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/dub/compare/v1.2.0-beta.2...v1.2.0-rc.1 Please report any bugs at https://issues.dlang.org -Martin Thanks a lot for the RC. I think the text "to be released Jan 18, 2017" can be removed since its slightly confusing.
Re: Mixin template confusion / compiler error.
On 01/19/2017 12:03 AM, Chris Katko wrote: > template sizer2D() // no params here for simplicity > { > const char [] sizer2D = "64,64"; > } > array_t!(mixin(sizer2D!())) case2; // FAILS (error below) > Error: template instance array_t!64 does not match template declaration > array_t(int width, int height) The comma operator strikes back but this time it's caught. :) The clue was exposed because my compilation has the following dmd flag: -de show use of deprecated features as errors (halt compilation) According to spec, "The text contents of the string must be compilable as a valid StatementList, and is compiled as such.": https://dlang.org/spec/statement.html#mixin-statement So, "64,64" is mixed in as two expressions around a comma operator and it gets the value 64. Ali
Re: Mixin template confusion / compiler error.
Addendum: Writing the following: writeln(mixin(sizer2D!())); simply dumps 64 to stdout. What's going on here? Have I run into a compiler bug?
Mixin template confusion / compiler error.
I've tried to narrow this down to the minimum code that exhibits the problem. When I use a mixin, to supply the parameters for a template, it works with ONE argument, but NOT TWO. template sizer2D() // no params here for simplicity { const char [] sizer2D = "64,64"; } template sizer1D() { const char [] sizer1D = "64"; } class why_t () { array_t!(64,64) case1; // works array_t!(mixin(sizer2D!())) case2; // FAILS (error below) array2_t!(64) case3; // works array2_t!(mixin(sizer1D!())) case4; // works array3_t!(64) case5; // works array3_t!(mixin(sizer2D!())) case6; // WORKS using ONE ARGUMENT method using default parameter for height (see class) } class array_t (int width, int height) { int [width][height] data; } class array2_t (int width) { int [width][width] data; } class array3_t (int width, int height=width) //note default param { int [width][height] data; } The error I get is: Error: template instance array_t!64 does not match template declaration array_t(int width, int height) Error: template instance a5test.why_t!() error instantiating And the strange thing is, it's like it's only outputting ONE of the two numbers. If it were outputting any other gibberish, it shouldn't compile at all. And I'm not misplacing the 1D vs 2D function names because originally there was NO 1D version at all. It was just the 2D and it wouldn't compile. Is there any way to get a PRINTOUT of the mixin code upon failure to see what it's actually trying to compile? - I'm using LDC2: LDC - the LLVM D compiler (e9b2b4): based on DMD v2.068.2 and LLVM 3.5.0
[Issue 8471] std.stdio.readf should be @trusted
https://issues.dlang.org/show_bug.cgi?id=8471 --- Comment #7 from Andrei Alexandrescu--- Cool, thanks, then the bug is legit. The fix would be a @safe function with a small @trusted core. --