Re: Emacs d-mode indentation, 2 spaces to 4?
On 10/04/2017 09:57 PM, John Gabriele wrote: I'm using Emacs 25.2.2 with d-mode-20161022.717 on Debian Testing, and by default this mode indents by 2 spaces. Is there an easy way to configure it to use 4 spaces instead? I can't imagine it has its own tab width. d-mode is based on cc-mode. Setting the tab width in that mode or in general should work for d-mode as well. Just research tab width for Emacs. If nothing else works and you're happy with a global tab-width of 4, add this to your .emacs file: (setq-default tab-width 4) Ali
Emacs d-mode indentation, 2 spaces to 4?
I'm using Emacs 25.2.2 with d-mode-20161022.717 on Debian Testing, and by default this mode indents by 2 spaces. Is there an easy way to configure it to use 4 spaces instead?
[Issue 17635] [REG 2.066.0] cannot convert unique immutable(int)** to immutable
https://issues.dlang.org/show_bug.cgi?id=17635 --- Comment #7 from Walter Bright--- The trouble with the getIndirection() is that passing a type: int* and: struct S { int* p; } behave differently. The first passes 'int' to traverseIndirections(), losing the *, the second passes 'S', keeping the *. There's just no way to make that work consistently. Kenji had papered it over, which created the bug ag0ep6g found. But when I fixed that one, then this one (from testInference.d) started passing when it should fail: struct S2 { const(int)* ptr; } immutable(S2) foo2b(const int*[] prm) pure { S2 s; return s; } I can't make both work because of the getIndirection() inconsistency. --
[Issue 17635] [REG 2.066.0] cannot convert unique immutable(int)** to immutable
https://issues.dlang.org/show_bug.cgi?id=17635 --- Comment #6 from David Nadlinger--- (In reply to David Nadlinger from comment #5) > After a quick glance, I'm not sure whether this is indeed what is at fault > here. If it was indeed getIndirection() that was at fault, shouldn't it then > also be used to decompose aggregate members in traverseIndirections? Looking at my old changes, that used to indeed be the case, before I removed the corresponding check in https://github.com/dlang/dmd/commit/fa6898c3feb1c500085d73df716b9a1ce9e4afa1. It seems like my fix was indeed suboptimal/wrong, in that it left the code in an overly conservative state, and I suppose it might be easier to start from Kenji's original code again than from what I did. --
[Issue 17635] [REG 2.066.0] cannot convert unique immutable(int)** to immutable
https://issues.dlang.org/show_bug.cgi?id=17635 David Nadlingerchanged: What|Removed |Added CC||c...@klickverbot.at --- Comment #5 from David Nadlinger --- After a quick glance, I'm not sure whether this is indeed what is at fault here. If it was indeed getIndirection() that was at fault, shouldn't it then also be used to decompose aggregate members in traverseIndirections? In other words, wouldn't returning struct { T** } (or struct{ struct { T** } }, etc.) instead of T** still falsely trip. If I were to guess, I would say that traverseIndirections() is missing a condition that returns false if the constness of the outermost layers is not compatible instead of continuing to decompose the pointer types. That is, T* and const(T*) should be regarded as a definite non-match, irrespective of what T is. It seems like the previous `ta->immutableOf()->equals(tb->immutableOf())` check did that, but with false positives. --
Re: Imports
On Wednesday, 4 October 2017 at 16:31:35 UTC, Jiyan wrote: Hey, as i see it the -Ipath command for dmd just imports the files within a directory but it doesnt work for sub directories, so i can write something like: import subdirectoryFromPath.file; Also with dub this doesnt seem possible (sourcePaths seems to work as the -I command). Is there a way to do what i want? Or am i doing something wrong? If you have this directory tree: - mylib -- pack1 --- a.d --- b.d pack2 - c.d Then you would pass -Imylib to the compiler. In your code, you can write the following: import pack1.a; import pack1.pack2.c; You don't import files or directories, just packages and modules. By default, package names correspond to directory names and module names correspond to file names, but they don't have to (it's best practice, though). And by the way what is the difference from sourcePaths to importPaths? sourcePaths where DUB can find additional files, outside of the default source directory, to pass to the compiler for compilation. importPaths will all be passed to the compile as -I. It seems you think that importing a module causes its source file to be automatically compiled. That doesn't happen. imports are strictly for the compiler to know which symbols are available for the current module to use. It does not attempt to compile imported modules. Imported modules might be part of your program or they might be part of a precompiled library. In the latter case, they don't need to be compiled because they already are. So the compiler leaves it up to you to decide which modules need to be compiled. Dub, by default, will make sure all modules in your source directory are compiled. It will also guarantee the compiler knows where to find them for imports. Sometimes, you might also want to import files from a library that isn't available from code.dlang.org. You can use importPaths to tell dub additional paths to give the compiler. If those files are part of a precompiled library you can link the library and you're done. If they aren't, you can use sourcePaths to tell DUB that all the source modules in the additional paths also need to be passed to the compiler for compiling and linking into the final executable.
Iterating over functions in module in order?
Any ideas on how someone could iterate over functions in a module as they appear, rather than any random order, without having to manually label them?
[Issue 17635] [REG 2.066.0] cannot convert unique immutable(int)** to immutable
https://issues.dlang.org/show_bug.cgi?id=17635 --- Comment #4 from Walter Bright--- Bug introduced by: https://github.com/dlang/dmd/commit/f3b5817a3542f4fa4eb4a6e70658854e0d8e4aa3#diff-43282ebf5a2de5fdbcb3b5083ddf949dR3127 --
Re: Should we add `a * b` for vectors?
On 10/4/2017 3:35 PM, Petar Kirov [ZombineDev] wrote: On Wednesday, 4 October 2017 at 17:56:16 UTC, Walter Bright wrote: On 10/4/2017 2:28 AM, Dukc wrote: But you can't deny our solution eats expressive power: If you don't want to change code you're importing, you have to write a wrapper type for int[] here. Please present an example. I think that was the point of Timon's example. An example would be appreciated. Timon's example requires guesswork as to what he intended, because it does not compile in ways unrelated to his point.
[Issue 17635] [REG 2.066.0] cannot convert unique immutable(int)** to immutable
https://issues.dlang.org/show_bug.cgi?id=17635 --- Comment #3 from Walter Bright--- I found one of the problems in getIndirection() in func.d: extern (C++) Type getIndirection(Type t) { t = t.baseElemOf(); if (t.ty == Tarray || t.ty == Tpointer) return t.nextOf().toBasetype(); if (t.ty == Taarray || t.ty == Tclass) return t; if (t.ty == Tstruct) return t.hasPointers() ? t : null; // TODO // should consider TypeDelegate? return null; } https://github.com/dlang/dmd/blob/master/src/ddmd/func.d#L2459 The TODO means we're one level of indirection off, meaning all the rest of the code that relies on getIndirection() is botched with structs, including traverseIndirections(), which simply cannot work right with this error. --
Re: Should we add `a * b` for vectors?
On Wednesday, 4 October 2017 at 17:56:16 UTC, Walter Bright wrote: On 10/4/2017 2:28 AM, Dukc wrote: But you can't deny our solution eats expressive power: If you don't want to change code you're importing, you have to write a wrapper type for int[] here. Please present an example. I think that was the point of Timon's example. If you have a module A that implements a range algorithm, a module B that defines a range-like type (but actually its member function not matching the exact signature of range primitives), you (module C) as user of modules A and B are not able to provide range primitive wrapper functions for the type defined in module B (which you can't modify). So you can't use A's range algorithm on type defined in B. ADL solves this problem (adapting third-party libraries to your needs). Since D's modules are closed (can't be extended from the outside like namespaces), if we want to support some form of ADL (the primary use-case being algorithm libraries), we would probably need to introduce some form of open for extension scopes like namespaces. Or change extern (C++, namespace) to behave like people coming from C++ may expect.
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 12:06:43 UTC, John Colvin wrote: On Wednesday, 4 October 2017 at 10:03:56 UTC, aberba wrote: Upon reading this, It triggered an idea. People often call this "destructuring" or "unpacking" to avoid confusion with destructors. Thats the word I was looking for. Ha ha
[Issue 17877] New: Missing library path in LDC settings
https://issues.dlang.org/show_bug.cgi?id=17877 Issue ID: 17877 Summary: Missing library path in LDC settings Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: visuald Assignee: nob...@puremagic.com Reporter: thomas.hedst...@mail.com kernel32.lib is not found when compiling for LDC 32/64bit. The reason seems to be that paths in the "LDC Directories" are only: $(VCTOOLSINSTALLDIR)lib\x64 $(UCRTSdkDir)Lib\$(UCRTVersion)\ucrt\x64 but kernel32.lib is placed in: $(UCRTSdkDir)Lib\$(UCRTVersion)\um\x64 Adding this third path, makes LDC work in my system. Windows 10 VS2017 Community 15.3.5 VisualD v0.46.0-beta1 --
Re: Andrei's "The D Programming Language" book. Up to date?
Andrei's book contains some outdated and some not-yet-implemented things but it's still a great read. It explains core features and design decisions of D very well. Ali
Re: What the hell is wrong with D?
On 2017/09/19 19:40, EntangledQuanta wrote: writeln(x + ((_win[0] == '@') ? w/2 : 0)); writeln(x + (_win[0] == '@') ? w/2 : 0); The first returns x + w/2 and the second returns w/2! WTF!!! This stupid bug has caused me considerable waste of time. Thanks Walter! I know you care so much about my time! I assume someone is going to tell me that the compiler treats it as writeln((x + (_win[0] == '@')) ? w/2 : 0); Yeah, that is really logical! No wonder D sucks and has so many bugs! Always wants me to be explicit about the stuff it won't figure out but it implicitly does stuff that makes no sense. The whole point of the parenthesis is to inform the compiler about the expression to use. Not use everything to the left of ?. Thanks for wasting some of my life... Just curious about who will justify the behavior and what excuses they will give. When you get too angry about the little things in life. "There are people dying in the world and this angers you, chill".
Andrei's "The D Programming Language" book. Up to date?
Hi all, This is my first message to this forum. And what a pleasure it is to be here. :) I was just looking around at what D books are available. I see that Andrei's "The D Programming Language" was published in 2010. What's changed in the language, library, and community since then that I should be aware of if following along with and learning from that book? Incidentally, is a new edition is on its way any time soon? Thanks!
Re: Should we add `a * b` for vectors?
On 10/02/2017 07:15 AM, Timon Gehr wrote: If there are multiple definitions of the same name, different modules might not agree which one is being referred to. (This is particularly likely for overloaded operators, as the set of names is finite and small. This is what Manu means when he says it can lead to nasty surprises. This is very plausible, but I don't have a good example.) Indeed a good example would strengthen the argument considerably. -- Andrei
[Issue 17876] [REG 2.074] Internal error when comparing inout(Foo[][]) with Foo[][]
https://issues.dlang.org/show_bug.cgi?id=17876 ag0ae...@gmail.com changed: What|Removed |Added Keywords||ice CC||ag0ae...@gmail.com Component|phobos |dmd Hardware|x86_64 |All Summary|Internal error with red |[REG 2.074] Internal error |black tree of array of |when comparing |arrays |inout(Foo[][]) with Foo[][] OS|Linux |All Severity|normal |regression --- Comment #2 from ag0ae...@gmail.com --- Reduced (it's the result of using `binaryFun!"a < b"` in the `inout` method `_firstGreaterEqual`): bool _less(inout size_t[][] a, size_t[][] b) { return a < b; } I don't know if this should compile or throw an error. Any way, it shouldn't ICE. dmd2.073.0 accepts the code, making this a regression. Changing component to dmd as that's where the bug manifests as an ICE. The actual bug might be in druntime. --
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Wednesday, 4 October 2017 at 15:30:08 UTC, Ali Çehreli wrote: the hidden \r characters at the ends Those got me too! Here's my less than optimal solution: int main(string[] args) { import std.stdio; import std.algorithm.iteration : map, splitter, joiner, each; import std.algorithm.searching : countUntil; import std.range : enumerate; import std.string : chomp; if (args.length != 5 && args.length != 4) { stderr.writeln("Something went wrong and it's obviously your fault."); return 1; } immutable columnID = args[2]; immutable substitute = args[3]; auto data = File(args[1], "r").byLine.map!chomp; if (data.empty) { stderr.writeln("input file missing\n\n(actually it exists, it's just " ~ "empty)\n\n(your fault regardless)"); return 1; } File output; if (args.length == 5) output = File(args[4], "w"); else output = stdout; immutable matchedColumn = data.front.splitter(",").countUntil(columnID); if (matchedColumn < 0) { stderr.writeln("column name doesn’t exist in the input file\n\n(and " ~ "it's your fault)"); return 1; } output.writeln(data.front); data.popFront; data.map!(line => line .splitter(",") .enumerate .map!(a => a.index == matchedColumn ? substitute : a.value) .joiner(",")).each!(a => output.writeln(a)); return 0; } I think the biggest problem is the lack of support for quoted content.
[Issue 17876] Internal error with red black tree of array of arrays
https://issues.dlang.org/show_bug.cgi?id=17876 --- Comment #1 from Christian Durán--- Probably just needs a better error message because it seems to happen because there's no ordering for the type. --
[Issue 17876] New: Internal error with red black tree of array of arrays
https://issues.dlang.org/show_bug.cgi?id=17876 Issue ID: 17876 Summary: Internal error with red black tree of array of arrays Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: ovejacuant...@gmail.com Not sure if a problem with phobos or druntime. import std.container.rbtree; void main () { auto a = redBlackTree!(size_t [][]); } With command 'dmd file' or 'ldc file' (DMD 2.076.0 and LDC 1.4.0) gives: /usr/include/dlang/dmd/object.d(3462): Error: static assert "Internal error." /usr/include/dlang/dmd/std/functional.d-mixin-201(201):instantiated from here: __cmp!(const(ulong[]), ulong[]) /usr/include/dlang/dmd/std/container/rbtree.d(866):instantiated from here: binaryFun!(inout(ulong[][]), ulong[][]) /usr/include/dlang/dmd/std/container/rbtree.d(1832):instantiated from here: RedBlackTree!(ulong[][], "a < b", false) --
[Issue 17868] add pragma(crt_con/destructor[, priority])
https://issues.dlang.org/show_bug.cgi?id=17868 --- Comment #6 from Martin Nowak--- (In reply to Rainer Schuetze from comment #4) > This enables "system programming" by not adding every special case to the > compiler as it is done so far. It's a common enough use case to warrant a separate pragma. Also just adding pointers to a section is not enough, the section needs to be flagged accordingly for this to work (e.g. on OSX and ELF). See WIP https://github.com/MartinNowak/dmd/tree/fix17868. > Where custom args would vary based on what the compiler supports. This way, > the ctr_constructor part is standardized, but the custom args obviously > depend on support from the specific compiler. Use version statements as > needed. Version statements for pragmas are a pain, you need to add a forwarding function or repeat the implementations. version (DMD) pragma(constructor, 1234) void func() { /* repeat */ } else pragma(constructor) void func() { /* repeat */ } Pragma arguments don't expand AliasSeq tuples, so that cannot be used either. Also priority support is platform/linker dependent, not compiler dependent. IMO simply making it only do sth. on supported platforms is an easy solution to this. I'd rather drop support for priorities instead of complicating the usage, leaving priorities to GDC/LDC's non-standard intrinsics. We're not that likely to ever need it, but then again it would be cheap to just implement it right away, and someone coming from C/C++ might want to use it. --
Re: Does writing from NNTP work?
On 2017/10/04 21:20, Jonathan M Davis wrote: On Wednesday, October 04, 2017 17:26:36 ketmar via Digitalmars-d-learn wrote: Tristan B. Kildaire wrote: Does this work? btw. there is "D" newsgroup which you can use for testing your NNTP client. web interface: http://forum.dlang.org/group/D NNTP name: "D" You can also just post whatever actual content you wanted to post and see if it shows up on forum.dlang.org or not. - Jonathan M Davis Oh yes but at the time I didn't have anything to write so I tested this.
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Wednesday, 4 October 2017 at 15:26:02 UTC, Ali Çehreli wrote: On 10/04/2017 02:04 AM, Biotronic wrote: ... Hey where is the list of features used e.g: ranges, ufcs...
Re: Does writing from NNTP work?
On Wednesday, October 04, 2017 17:26:36 ketmar via Digitalmars-d-learn wrote: > Tristan B. Kildaire wrote: > > Does this work? > > btw. there is "D" newsgroup which you can use for testing your NNTP > client. > > web interface: http://forum.dlang.org/group/D > NNTP name: "D" You can also just post whatever actual content you wanted to post and see if it shows up on forum.dlang.org or not. - Jonathan M Davis
Re: Proposal: Object/?? Destruction
On 10/04/2017 05:06 AM, John Colvin wrote: > People often call this "destructuring" Thanks! Now it makes sense. :) Ali
Re: Should we add `a * b` for vectors?
On 10/4/2017 2:28 AM, Dukc wrote: But you can't deny our solution eats expressive power: If you don't want to change code you're importing, you have to write a wrapper type for int[] here. Please present an example.
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 12:06:43 UTC, John Colvin wrote: [...] People often call this "destructuring" or "unpacking" to avoid confusion with destructors. Or "Structured Bindings" ;) http://en.cppreference.com/w/cpp/language/structured_binding
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Wednesday, 4 October 2017 at 15:30:08 UTC, Ali Çehreli wrote: On 10/04/2017 02:26 AM, Atila Neves wrote: > in D so trivial it'd probably make me sleep out of boredom. I spent more time on this obviously trivial program than necessary. :( In addition to facing known template resolution issues, the hidden \r characters at the ends of some of the fields in the example textcolumns threw me off for a while. (Compounded by silly mistakes that I was making.) But it's not wasted time. You could also use it somewhere else. Blog post, updated version of your book, new book, etc.
Re: Looking for a mentor in D
On 10/02/2017 11:54 PM, eastanon wrote: > I would like to dive deeper into D, however sometimes it can get > intimidating when I read some of the discussions on the forums and I > realise I know nothing. I think it happens to everyone at different level. (Certainly happens to me all the time.) I find such discussion areas excellent places to improve myself. I started learning C++ on comp.lang.c++.moderated and D here without any CS background myself. Current discussions make it obvious what is in fashion these days and then you go ahead and read a little bit about the ones that are interesting to you. > Please let me know if you would like to be a D mentor. I think it's beneficial to others as well as to you if we keep the conversation on this forum. Many more opportunities to learn from others' questions and many less opportunities of BS by mentors... You can still email me, a person without CS background, at acehr...@yahoo.com. :) Ali
[Issue 17869] scope class object no longer deleted when created via factory function
https://issues.dlang.org/show_bug.cgi?id=17869 Ketmar Darkchanged: What|Removed |Added CC||ket...@ketmar.no-ip.org --
Re: Looking for a mentor in D
On Tuesday, 3 October 2017 at 06:54:01 UTC, eastanon wrote: I would like to choose D as my go to language and to do that I realise I need a mentor, someone who will walk and guide me and not get irritated by basic questions. I am pretty much a DIY person, so don't worry about mundane issues. I want to have someone with whom I can discuss some practical choices and algorithms. I am a self-taught programmer and never took CS classes. I am good in R, Python and Ruby. Please let me know if you would like to be a D mentor. I haven't seen anyone blasted for asking programming questions on these forms as long as they were using D to solve them. Though maybe that wouldn't be true if the forum was consumed by such questions. Feel free to shoot me an email though jesse.k.phill...@gmail.com and we can see how it goes.
Imports
Hey, as i see it the -Ipath command for dmd just imports the files within a directory but it doesnt work for sub directories, so i can write something like: import subdirectoryFromPath.file; Also with dub this doesnt seem possible (sourcePaths seems to work as the -I command). Is there a way to do what i want? Or am i doing something wrong? And by the way what is the difference from sourcePaths to importPaths?
Re: Vibe.d using Windows Certificate binding, possible?
On Wednesday, 4 October 2017 at 03:39:22 UTC, rikki cattermole wrote: On 04/10/2017 3:54 AM, Jesse Phillips wrote: https://msdn.microsoft.com/en-us/library/windows/desktop/cc307220(v=vs.85).aspx "Application program source files include the Http.h header file to access function prototypes and structure definitions for the HTTP Server API. Developers can use the Httpapi.lib library file to build applications that use the HTTP Server API. At runtime, applications link to the Httpapi.dll." So no, vibe.d can't work with it. This a special snow flake feature from 2k3 server days. Thank you, and it looks like core.sys.windows doesn't have this header file defined either. And now I've learned something new about MSDN docs.
Re: For fun: Expressive C++ 17 Coding Challenge in D
On 10/04/2017 02:26 AM, Atila Neves wrote: > in D so trivial it'd probably make me sleep out of boredom. I spent more time on this obviously trivial program than necessary. :( In addition to facing known template resolution issues, the hidden \r characters at the ends of some of the fields in the example textcolumns threw me off for a while. (Compounded by silly mistakes that I was making.) > Maybe that should be our new catchphrase: > > "D: Making programming boring" While still keeping it interesting enough to scratch your head once in a while. :) Ali
Re: For fun: Expressive C++ 17 Coding Challenge in D
On 10/04/2017 02:04 AM, Biotronic wrote: > I opted for writing to stdout instead, because 1) it's easier, x) it's > less code, and b) it's more flexible. Exactly! :) > a simple replacement of readText with an mmapped equivalent should > enable humongous file support with no other code change required. Here is one from me: import std.stdio; import std.algorithm; import std.string; import std.range; const delim = ","; auto byColumn(R)(R range) { return range .splitter(delim) .map!strip; } int main(string[] args) { if (args.length != 3) { stderr.writefln("USAGE: %s ", args[0]); return 1; } const columnName = args[1]; auto lines = stdin.byLine; const columnNumber = lines .front .byColumn .countUntil(columnName); if (columnNumber == -1) { stderr.writefln(`ERROR: Failed to find "%s".`, columnName); return 1; } writeln(lines.front); lines.popFront(); const replacement = args[2]; auto replaced = lines .map!(line => line .byColumn .enumerate .map!(t => (t[0] == columnNumber) ? replacement : t[1]) .joiner(delim)); writefln("%(%s\n%)", replaced); return 0; } Ali
[Issue 17868] add pragma(crt_con/destructor[, priority])
https://issues.dlang.org/show_bug.cgi?id=17868 --- Comment #5 from Steven Schveighoffer--- I've changed my mind a bit on this. It's OK to have a pragma that allows stuffing function pointers into a section for compiler purposes, obviously we already have custom pragmas anyway. But I still am leary of adopting the "integer priority" as an official API for it. What may be better is: pragma(ctr_constructor[, custom args]) Where custom args would vary based on what the compiler supports. This way, the ctr_constructor part is standardized, but the custom args obviously depend on support from the specific compiler. Use version statements as needed. --
Re: Does writing from NNTP work?
On Wednesday, 4 October 2017 at 14:26:36 UTC, ketmar wrote: Tristan B. Kildaire wrote: Does this work? btw. there is "D" newsgroup which you can use for testing your NNTP client. web interface: http://forum.dlang.org/group/D NNTP name: "D" Ah okay. Thanks.
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
04.10.2017 17:19, Daniel Kozák пишет: sajson loops are manually unrolled already. Very aggressive optimisation makes no sense and may unroll loops additionally and slowdown the program https://github.com/tamediadigital/asdf/pull/79
Re: Does writing from NNTP work?
Tristan B. Kildaire wrote: Does this work? btw. there is "D" newsgroup which you can use for testing your NNTP client. web interface: http://forum.dlang.org/group/D NNTP name: "D"
Re: Looking for a mentor in D
On 2017/10/03 08:54, eastanon wrote: I have been reading the D forums for a while and following on its amazing progress for a long time. Over time I have even written some basic D programs for myself, nothing major or earth shuttering. I have downloaded and read Ali's excellent book. I would like to dive deeper into D, however sometimes it can get intimidating when I read some of the discussions on the forums and I realise I know nothing. People argue on and on about a feature or lack of and the future of the language and it starts to cast doubts on my desire to learn and be proficient in D. I would like to choose D as my go to language and to do that I realise I need a mentor, someone who will walk and guide me and not get irritated by basic questions. I am pretty much a DIY person, so don't worry about mundane issues. I want to have someone with whom I can discuss some practical choices and algorithms. I am a self-taught programmer and never took CS classes. I am good in R, Python and Ruby. Please let me know if you would like to be a D mentor. I don't have a mentor or anything. I am doing CS next year but I went to school and did IT there (I am almost done with school). I recommend watching some computer science videos (like one on the fundamentals, binary, etc.) and then things start to make more sense (atleast for me). Also, this is a good place to ask for help and along with the IRC channel (#d on irc.freenode.net).
Re: Looking for a mentor in D
On 2017/10/03 08:54, eastanon wrote: I have been reading the D forums for a while and following on its amazing progress for a long time. Over time I have even written some basic D programs for myself, nothing major or earth shuttering. I have downloaded and read Ali's excellent book. I would like to dive deeper into D, however sometimes it can get intimidating when I read some of the discussions on the forums and I realise I know nothing. People argue on and on about a feature or lack of and the future of the language and it starts to cast doubts on my desire to learn and be proficient in D. I would like to choose D as my go to language and to do that I realise I need a mentor, someone who will walk and guide me and not get irritated by basic questions. I am pretty much a DIY person, so don't worry about mundane issues. I want to have someone with whom I can discuss some practical choices and algorithms. I am a self-taught programmer and never took CS classes. I am good in R, Python and Ruby. Please let me know if you would like to be a D mentor. Oh sorry I see you have read the book on D by Ali. Well we can always help you with your questions then.
Re: Does writing from NNTP work?
On 2017/10/04 16:20, Andrea Fontana wrote: On Wednesday, 4 October 2017 at 14:18:52 UTC, Tristan B. Kildaire wrote: Does this work? No, I don't read you. Try again :) Haha, thanks. :)
Re: Does writing from NNTP work?
On Wednesday, 4 October 2017 at 14:18:52 UTC, Tristan B. Kildaire wrote: Does this work? No, I don't read you. Try again :)
Re: Does writing from NNTP work?
Tristan B. Kildaire wrote: Does this work? if you can see this reply, it works.
Re: Does writing from NNTP work?
On Wednesday, 4 October 2017 at 14:18:52 UTC, Tristan B. Kildaire wrote: Does this work? Sorry about this guys, just wanted to check out if NNTP access worked on my side. Won't happen again.
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
On Wednesday, 4 October 2017 at 14:04:30 UTC, Nicholas Wilson wrote: On Wednesday, 4 October 2017 at 13:15:17 UTC, Ilya Yaroshenko wrote: On Wednesday, 4 October 2017 at 12:11:54 UTC, Kagamin wrote: On Sunday, 1 October 2017 at 14:38:04 UTC, Ilya Yaroshenko wrote: [1] https://github.com/tamediadigital/asdf/tree/master/benchmarks/sajson AFAIK, ldc translates dmd's -O option to llvm's -O3. sajson loops are manually unrolled already. Very aggressive optimisation makes no sense and may unroll loops additionally and slowdown the program. Any reason clang++ is only -O2, not -O{3,s,z}? sajson loops are manually unrolled already. Very aggressive optimisation makes no sense and may unroll loops additionally and slowdown the program
Does writing from NNTP work?
Does this work?
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
On Wednesday, 4 October 2017 at 13:15:17 UTC, Ilya Yaroshenko wrote: On Wednesday, 4 October 2017 at 12:11:54 UTC, Kagamin wrote: On Sunday, 1 October 2017 at 14:38:04 UTC, Ilya Yaroshenko wrote: [1] https://github.com/tamediadigital/asdf/tree/master/benchmarks/sajson AFAIK, ldc translates dmd's -O option to llvm's -O3. sajson loops are manually unrolled already. Very aggressive optimisation makes no sense and may unroll loops additionally and slowdown the program. Any reason clang++ is only -O2, not -O{3,s,z}?
[Issue 17415] std.conv.emplace does not forward arguments correctly
https://issues.dlang.org/show_bug.cgi?id=17415 --- Comment #2 from Eduard Staniloiu--- I might be wrong, but since you are disabling the postblit wouldn't you want to define the class ctor as: class C { this(const ref S) { /* magic */ } } --
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
On Wednesday, 4 October 2017 at 12:11:54 UTC, Kagamin wrote: On Sunday, 1 October 2017 at 14:38:04 UTC, Ilya Yaroshenko wrote: [1] https://github.com/tamediadigital/asdf/tree/master/benchmarks/sajson AFAIK, ldc translates dmd's -O option to llvm's -O3. sajson loops are manually unrolled already. Very aggressive optimisation makes no sense and may unroll loops additionally and slowdown the program.
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
On Sunday, 1 October 2017 at 14:38:04 UTC, Ilya Yaroshenko wrote: [1] https://github.com/tamediadigital/asdf/tree/master/benchmarks/sajson AFAIK, ldc translates dmd's -O option to llvm's -O3.
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 10:03:56 UTC, aberba wrote: Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: https://wiki.dlang.org/DIP88 I'd like to see DIP88 (Named Parameters) revived. Was this proposal rejected or is it just stale and needs a refresh? Named parameters can be implemented in a library, however, in my opinion they are useful enough to warrant a clean syntax with language support. I'd be willing to refresh the DIP so long as I know the idea has not already been rejected. DIP reminds me of object destruction. /* extracts success & message from returned type. Could be tuple or structure, etc. May even eliminate use of tuples for multiple return */ auto {success, message} = callVoldermortFunction(); This is concept is used in Kotlin. JavaScript es6 takes it even further (function parameters and arguments support object destruction) People often call this "destructuring" or "unpacking" to avoid confusion with destructors.
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 10:03:56 UTC, aberba wrote: Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: [...] DIP reminds me of object destruction. /* extracts success & message from returned type. Could be tuple or structure, etc. May even eliminate use of tuples for multiple return */ auto {success, message} = callVoldermortFunction(); This is concept is used in Kotlin. JavaScript es6 takes it even further (function parameters and arguments support object destruction) +1
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Wednesday, 4 October 2017 at 09:04:58 UTC, Biotronic wrote: Since the code uses ranges though, a simple replacement of readText with an mmapped equivalent should enable humongous file support with no other code change required. Drop-in replacement for readText: struct MmText { import std.mmfile; ulong _fileOffset; MmFile _file; this(string filename) { _file = new MmFile(filename); } dchar front() { auto end = min(_file.length, _fileOffset+4); auto data = cast(string)_file[_fileOffset..end]; return decodeFront(data); } void popFront() { auto end = min(_file.length, _fileOffset+4); auto data = cast(string)_file[_fileOffset..end]; size_t bytes; decodeFront(data, bytes); _fileOffset += bytes; } bool empty() { return _fileOffset >= _file.length; } } -- Biotronic
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 10:03:56 UTC, aberba wrote: auto {success, message} = callVoldermortFunction(); ❤ I want this syntax, plz! This solves the issue how to return multiple ref values. --Ilya
Proposal: Object/?? Destruction
Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: https://wiki.dlang.org/DIP88 I'd like to see DIP88 (Named Parameters) revived. Was this proposal rejected or is it just stale and needs a refresh? Named parameters can be implemented in a library, however, in my opinion they are useful enough to warrant a clean syntax with language support. I'd be willing to refresh the DIP so long as I know the idea has not already been rejected. DIP reminds me of object destruction. /* extracts success & message from returned type. Could be tuple or structure, etc. May even eliminate use of tuples for multiple return */ auto {success, message} = callVoldermortFunction(); This is concept is used in Kotlin. JavaScript es6 takes it even further (function parameters and arguments support object destruction)
Re: How to implement `isTemplate` traits?
04.10.2017 12:54, Biotronic пишет: template isTemplate(T...) if (T.length == 1) { enum isTemplate = __traits(isTemplate, T[0]); } -- Biotronic Thank you!
Re: Proposal: Object/?? Destruction
On Wednesday, 4 October 2017 at 09:52:39 UTC, aberba wrote: Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: [...] Upon reading the DIP, it reminds me of object destruction. // extracts success & message from returned type. Could be tuple or structure, etc. May even eliminate use of tuples for multiple return auto {success, message} = callVoldermortFunction(); This is concept is used in Kotlin. JavaScript es6 takes it even further (function parameters and arguments support object destruction) Oops. Wrong place. Will repost in general.
Re: How to implement `isTemplate` traits?
On Wednesday, 4 October 2017 at 09:32:31 UTC, drug wrote: I need to separate templates: ``` foreach(member; __traits(allMembers, V)) { static if (__traits(compiles, { auto _val = &__traits(getMember, value, member); }) { // a template needs to be instantiated to be addressable, so it works, but I think it's dirty hack instead of dry and clean way... } } ``` May be phobos has such traits somewhere? template isTemplate(T...) if (T.length == 1) { enum isTemplate = __traits(isTemplate, T[0]); } -- Biotronic
Proposal: Object/?? Destruction
Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: https://wiki.dlang.org/DIP88 I'd like to see DIP88 (Named Parameters) revived. Was this proposal rejected or is it just stale and needs a refresh? Named parameters can be implemented in a library, however, in my opinion they are useful enough to warrant a clean syntax with language support. I'd be willing to refresh the DIP so long as I know the idea has not already been rejected. Upon reading the DIP, it reminds me of object destruction. // extracts success & message from returned type. Could be tuple or structure, etc. May even eliminate use of tuples for multiple return auto {success, message} = callVoldermortFunction(); This is concept is used in Kotlin. JavaScript es6 takes it even further (function parameters and arguments support object destruction)
Re: ASDF v0.1.5-beta0: new parser is ~40% faster
On Sunday, 1 October 2017 at 14:38:04 UTC, Ilya Yaroshenko wrote: Hello, About ASDF - ASDF [3] is a cache oriented string based JSON representation. Besides, it is a convenient Json Library for D that gets out of your way. ASDF is specially geared towards transforming high volumes of JSON dataframes, either to new JSON Objects or to custom data types. [...] Good work on those benchmarks! Atila
How to implement `isTemplate` traits?
I need to separate templates: ``` foreach(member; __traits(allMembers, V)) { static if (__traits(compiles, { auto _val = &__traits(getMember, value, member); }) { // a template needs to be instantiated to be addressable, so it works, but I think it's dirty hack instead of dry and clean way... } } ``` May be phobos has such traits somewhere?
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Tuesday, 3 October 2017 at 19:25:56 UTC, Ali Çehreli wrote: Found on Reddit: https://www.reddit.com/r/programming/comments/740617/the_expressive_c17_coding_challenge/ How would you do it in D? Ali P.S. You can ignore the following note from the challenge text; I don't think it applies to D. Honestly, I don't think it matters for C++17 either. :) "You can assume input files won't be super large and can fit fully into memory." I can't bring myself to code a solution in C++17 or D. In C++17 it'd be too painful, and in D so trivial it'd probably make me sleep out of boredom. Maybe that should be our new catchphrase: "D: Making programming boring" :P Atila
Re: Should we add `a * b` for vectors?
On Tuesday, 3 October 2017 at 19:25:32 UTC, Walter Bright wrote: This is specifically designed to prevent nasty surprises. C++ has a big problem with ADL in that overloading is not encapsulated and any #included header can inadvertently add more overloads that may be entirely unrelated. Any .h can crack open any namespace and insert more overloads into it. It's completely unhygienic and uncontrollable. As for the specific example you gave, I get: a.d(3): Error: no property 'front' for type 'int[]' a.d(4): Error: no property 'save' for type 'int[]' b.d(8): Error: template instance a.sum!(int[]) error instantiating But you can't deny our solution eats expressive power: If you don't want to change code you're importing, you have to write a wrapper type for int[] here. Alias this helps, but because save() and slicing operators have to return the type of this, there's still manual work to do if you want Phobos algorithms to utilize it's random access. It may be that ADL or something similar would cause too much trouble to be worth it, don't know about that. But what I'm saying that we definitely have a considerable problem here and it would solve it.
Re: conversion error related to array index
On Wednesday, October 04, 2017 09:04:10 thorstein via Digitalmars-d-learn wrote: > Hi, > > I get the following compile error with this function below: > source\mod_data\matrices.d(66,12): Error: cannot implicitly > convert expression (j) of type ulong to uint > > (66,12) is [j] in row[j] > > Using uint as type for rows, cols (i.e. the indices) works. Is > ulong not allowed for array indices? I could not find the > respective information. Array indices - and array length - are size_t. If you're on a 32-bit system, that's an alias to uint, whereas on a 64-bit system, it's an alias to ulong. In general, code should be using size_t when dealing with arrays not uint or ulong (unless you're talking about having elements of uint or ulong). If you don't use size_t, then you're likely to run into problems when compiling for a different architecture. But if you have a ulong that you need to convert to a uint, then you can always cast or use std.conv.to!uint so long as the number will actually fit in a uint. - Jonathan M Davis
Re: For fun: Expressive C++ 17 Coding Challenge in D
On Tuesday, 3 October 2017 at 19:25:56 UTC, Ali Çehreli wrote: Found on Reddit: https://www.reddit.com/r/programming/comments/740617/the_expressive_c17_coding_challenge/ How would you do it in D? Ali P.S. You can ignore the following note from the challenge text; I don't think it applies to D. Honestly, I don't think it matters for C++17 either. :) "You can assume input files won't be super large and can fit fully into memory." https://gist.github.com/Biotronic/0bc6048b880d67bfdca970453cc47cf9 I opted for writing to stdout instead, because 1) it's easier, x) it's less code, and b) it's more flexible. The memory limitations certainly do apply - readText would fail upon reading humongous files, and for 32-bit programs the resulting string wouldn't be able to hold enough data. Since the code uses ranges though, a simple replacement of readText with an mmapped equivalent should enable humongous file support with no other code change required. -- Biotronic
conversion error related to array index
Hi, I get the following compile error with this function below: source\mod_data\matrices.d(66,12): Error: cannot implicitly convert expression (j) of type ulong to uint (66,12) is [j] in row[j] Using uint as type for rows, cols (i.e. the indices) works. Is ulong not allowed for array indices? I could not find the respective information. Thanks! 49 private double[][] matrix_uniform(ulong rows, ulong cols, double lbound, double ubound, ulong precision) 50 { 51double[][] array; 52double[] rowT; 53auto gen = Random(unpredictableSeed); 54auto rndUniform = uniform(lbound, ubound, gen); 55 56foreach(ulong i; 0..cols) 57{ 58 rowT ~= 0; 59} 60 61foreach(ulong i; 0..rows) 62{ 63 foreach(ulong j; 0..cols) 64 { 65rndUniform = uniform(lbound, ubound, gen); 66rowT[j] = to!double(rndUniform) / 10^^precision; 67 } 68 array ~= rowT.dup; 69} 70 return array; 71 }
Re: gdc is in
GCC 8 Dne 4. 10. 2017 8:10 dopoledne napsal uživatel "Suliman via Digitalmars-d" < digitalmars-d@puremagic.com>: > On Tuesday, 3 October 2017 at 22:00:51 UTC, Joakim wrote: > >> On Wednesday, 21 June 2017 at 15:11:39 UTC, Joakim wrote: >> >>> the gcc tree: >>> >>> https://gcc.gnu.org/ml/gcc/2017-06/msg00111.html >>> >>> Congratulations to Iain and the gdc team. :) >>> >>> I found out because it's on the front page of HN right now, where >>> commenters are asking questions about D. >>> >> >> An update, including the latest 2.076 frontend: >> >> https://www.phoronix.com/scan.php?page=news_item=D-GCC-v3-Patches >> > > Cool, which version of GCC will have it? >
[Issue 17875] New: Range violation in std.regex
https://issues.dlang.org/show_bug.cgi?id=17875 Issue ID: 17875 Summary: Range violation in std.regex Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: simen.kja...@gmail.com import std.regex; import std.array; import std.stdio; unittest { auto f = `abc`; auto re = `(()|(.+))`; writeln(f.matchAll(re)); // Line 8 writeln(f.matchAll(re).array); // Line 9 } In the above example, line 9 fails with: core.exception.RangeError@D:\github\phobos\std\regex\package.d(576): Range violation Changing the order of line 8 and 9, the problem disappears. Duplicating line 8 causes no exception. The regex is shortened to the smallest I found that exhibits this behavior. --
[Issue 17868] add pragma(crt_con/destructor[, priority])
https://issues.dlang.org/show_bug.cgi?id=17868 Rainer Schuetzechanged: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #4 from Rainer Schuetze --- I guess these construction/destruction mechanisms are a special case of putting function pointers into specific sections of the data segment. I'd prefer to not implement the special case, but the more general https://issues.dlang.org/show_bug.cgi?id=16300 This enables "system programming" by not adding every special case to the compiler as it is done so far. --
Re: gdc is in
On Tuesday, 3 October 2017 at 22:00:51 UTC, Joakim wrote: On Wednesday, 21 June 2017 at 15:11:39 UTC, Joakim wrote: the gcc tree: https://gcc.gnu.org/ml/gcc/2017-06/msg00111.html Congratulations to Iain and the gdc team. :) I found out because it's on the front page of HN right now, where commenters are asking questions about D. An update, including the latest 2.076 frontend: https://www.phoronix.com/scan.php?page=news_item=D-GCC-v3-Patches Cool, which version of GCC will have it?
Re: gdc is in
On Tuesday, 3 October 2017 at 22:00:51 UTC, Joakim wrote: On Wednesday, 21 June 2017 at 15:11:39 UTC, Joakim wrote: the gcc tree: https://gcc.gnu.org/ml/gcc/2017-06/msg00111.html Congratulations to Iain and the gdc team. :) I found out because it's on the front page of HN right now, where commenters are asking questions about D. An update, including the latest 2.076 frontend: https://www.phoronix.com/scan.php?page=news_item=D-GCC-v3-Patches Does this include DMD and static if?