Re: How do I check if this field is of this template struct?
On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote: give below template struct, how can I list the members x, y and z? I've tried something with OriginalType and TemplateOf but no luck... it seems if I do foo!"str1" the "str1" became "part of type"? give .stringof from typeof(__traits(getMember, foo, field)) I thought the type would be foo!string or something. Template parameter cannot only be types but also values, including strings. If you instantiate a template with different values you get different types. -- struct foo(T) { } struct bar(string s) {} alias a = foo!string; // type of a is foo!string alias b = bar!"str1"; // type of b is bar!"str1" alias c = bar!"str2"; // typo of c is bar!"str2" static assert (!is(typeof(c) == typeof(b))); --
Re: SIGUSR1, SIGUSR2
On Friday, 11 December 2020 at 17:32:54 UTC, Adam D. Ruppe wrote: On Friday, 11 December 2020 at 17:29:12 UTC, Panke wrote: But somehow my process gets signalled with USR1 and USR2 all the time. If I do The garbage collector uses sig usr1/2 to pause threads so it can do its collection work. When debugging just ignore them. My .gdbinit has these lines: handle SIGUSR1 noprint handle SIGUSR2 noprint since most D programs will have these. For lldb breakpoint set -n _Dmain --auto-continue true -N OnMain breakpoint command add -o "pro hand -p true -s false -n false SIGUSR1 SIGUSR2" OnMain does the trick.
Re: SIGUSR1, SIGUSR2
On Friday, 11 December 2020 at 17:32:54 UTC, Adam D. Ruppe wrote: On Friday, 11 December 2020 at 17:29:12 UTC, Panke wrote: But somehow my process gets signalled with USR1 and USR2 all the time. If I do The garbage collector uses sig usr1/2 to pause threads so it can do its collection work. When debugging just ignore them. My .gdbinit has these lines: handle SIGUSR1 noprint handle SIGUSR2 noprint since most D programs will have these. Thanks, good to know!
SIGUSR1, SIGUSR2
I have as vibe.d application that opens some websockets, reads messages and does something with them (currently mostly writing them to disk). The processing happens in background threads started with runWorkerTask, the websocket code runs as a normal task (runTask), everything is synchronized over a central circular buffer. But somehow my process gets signalled with USR1 and USR2 all the time. If I do $ strace -etrace=epoll_wait the disruptions of epoll by SIGUSR1/2 just scroll down. According to the strace output I got new, the source of the signals is the process itself. This happens if I do not install a signal handler myself. While this makes debugging a pain, at least the program seems to work. If I install signal handlers for USR1/USR2 via eventcore than vibe.d never seems to be able to establish the websocket connection. The same happens if I do signal(SIGUSR1, SIG_IGN). Maybe some kind of deadlock (all threads seem to be waiting on some condition variables or a in a spinlock). Does anyone have a idea what's going on here?
Re: DIP1028 - Rationale for accepting as is
On Tuesday, 26 May 2020 at 13:21:08 UTC, Johannes Loher wrote: Am 26.05.20 um 15:10 schrieb Panke: The bazel community has lots of such switches. Basically every new behaviour get's introduced with a --preview switch, that will turn into a --revert after some time. For each switch there is a github issue, explaining the change it detail. Why it was necessary, what the changed behaviour is, how to migrate and the timeline for this particular switch. D has the same thing (e.g. -preview=safedefault will enable this DIP). The main difference to Johannes T's suggestion is that these preview and revert switches are only a temporary measure to ease the transition. They do not create different versions of the language permanently. What we don't have is good documentation and a clear timeline for the switches.
Re: DIP1028 - Rationale for accepting as is
On Tuesday, 26 May 2020 at 12:38:54 UTC, Johannes Loher wrote: A switch might help but the whole purpose of this DIP is to get the defaults right. In my opinion, such a switch should be enabled by default. There is also the danger of creating 2 versions of the language that are incompatible with each other. Only giving this a quick thought, I believe it could work (you can still link libraries compiled with and without the switch) but I'm not completely sure. The bazel community has lots of such switches. Basically every new behaviour get's introduced with a --preview switch, that will turn into a --revert after some time. For each switch there is a github issue, explaining the change it detail. Why it was necessary, what the changed behaviour is, how to migrate and the timeline for this particular switch.
Re: DIP1028 - Rationale for accepting as is
On Tuesday, 26 May 2020 at 12:20:31 UTC, Johannes T wrote: On Tuesday, 26 May 2020 at 03:37:29 UTC, Walter Bright wrote: [..] Thank you very much for your patience with all the negative feedback. Yes, good think to stop once in a while and appreciate it. "To not complain is sufficient praise", does not always cut it.
Re: DIP1028 - Rationale for accepting as is
On Monday, 25 May 2020 at 16:29:24 UTC, Atila Neves wrote: A few years ago I submitted several PRs to Phobos to mark all unittests that could with @safe explicitly. I'd say that was a good example of nobody reviewing them for their @systemness. Ideally you should be able to blindly mark every function definition with @safe, because the compiler will catch you if you fall. Only if you type @trusted you should need to be careful.
Re: Using Vibe.d for not HTTP
On Monday, 25 May 2020 at 12:04:12 UTC, Russel Winder wrote: Now I need to find out how to spawn a task that can send out data even when the connection handler is blocked awaiting something to read. https://vibed.org/api/vibe.core.core/runTask ?
Re: DIP1028 - Rationale for accepting as is
On Monday, 25 May 2020 at 12:22:25 UTC, Zoadian wrote: there is no such thing as a trustworthy @trusted. not with how the whole safety system work now. you can break previously verified @trusted code by just writing @safe code today. Do you have an example of code that was correctly labeled @trusted in DMD version X, which may not be labeled @trusted in DMD version Y because of changes to @safe/@trusted@/@system?
Re: Using Vibe.d for not HTTP
On Sunday, 24 May 2020 at 16:14:58 UTC, Russel Winder wrote: On Sun, 2020-05-24 at 17:01 +0100, Russel Winder wrote: […] connection.read(buffer, IOMode.once); What an idiot I am, this call returns the read count, which makes it fine. Progress now being made. I had a look. Documentation could be better. I think the other call does not return it, because it always reads until the buffer is filled.
Re: DIP1028 - Rationale for accepting as is
On Sunday, 24 May 2020 at 08:55:32 UTC, Walter Bright wrote: I infer your position is the idea that putting @trusted on the declarations isn't greenwashing, while @safe is. I can't see a practical difference between: @safe extern (C) void whatevs(parameters); @trusted extern (C) void whatevs(parameters); Both require that whatevs() provide a safe interface. The difference between them is in the implementation of those functions, not the interface. Since the D compiler cannot see those implementations, they are immaterial to the compiler and user. I've always understood that the @safe,@trusted,@system machinery provides the following guarantee once all holes are fixed: If I have a memory corruption in my code than I need to only look at the @trusted and @system parts to find it. Marking whatevs @safe violates this, marking it @trusted does not.
Re: Spawn a Command Line application Window and output log information
On Monday, 18 May 2020 at 16:36:11 UTC, BoQsc wrote: I'd like to have application as small as possible with a simple Command Line Window. I'd use that Window to output notices, log information and the like. Would this require GUI library and how can this be achieved? If you do not want to create the library yourself, you could spawn a terminal application like konsole or kitty and start a simple cli app. You'd need to have some form of inter process communication setup for this though.
Re: Hunt Framework 3.0.0 Released, Web Framework for DLang!
On Friday, 8 May 2020 at 06:41:59 UTC, Jan Hönig wrote: On Thursday, 7 May 2020 at 05:04:12 UTC, zoujiaqing wrote: On Wednesday, 6 May 2020 at 22:28:28 UTC, Dukc wrote: On Friday, 1 May 2020 at 10:54:55 UTC, zoujiaqing wrote: [snip] Thanks, but: Some of the files have Apache license, but some have none. I think you should add a license to the whole repository that would cover those files that don't have their own. OK, thanks ;) I have a somewhat stupid question. I asked it on reddit, but I got no answer there. I haven't done much with web or networking in general until now, thus excuse my ignorance. What is the difference between hunt and vibe-d? I can say anything about hunt, but vibe-d is three things: 1. https://github.com/vibe-d/eventcore This is the core of it and gives you a proactor for async programming with callbacks. Instead of a blocking 'write(data)' call you do 'write(data, dlg)' where dlg is a delegate that is called once the write has finished. 2. https://github.com/vibe-d/vibe-core Writing non-trivial programs with a bare proactor quickly leads to callback hell. Far easier is to hide the callback behind fibers. This is what vibe-core does. Everything runs as a fiber, which gets suspended on call to eventcore's async interface and is automatically resumed after the async call finishes. 3. https://github.com/vibe-d/vibe.d This implements stuff that's useful for web programming on top of 2. HTTP, WebSockets, databases, serialization, stuff like that.
Re: Luneta: terminal fuzzy finder
On Monday, 4 May 2020 at 22:49:49 UTC, Felipe wrote: Hi, I develop an interactive terminal fuzzy finder in D with ncurses. Feel free to check it out and contribute. Any feedback is welcome. Thanks, Felipe [1] https://github.com/fbeline/luneta [2] https://code.dlang.org/packages/luneta [3] https://code.dlang.org/packages/fuzzyd What's the difference to fzf?
Does anyone have gdb pretty printers for buildin types like associative arrays?
At least on my installation they are printed as just a pointer. Should this just work and by box is not correctly configured or do I need some pretty printers? If so, has someone already made them?
Re: Typescript with vibe.d
On Monday, 9 March 2020 at 09:42:16 UTC, GreatSam4sure wrote: I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if it is possible What do you want to do?
Re: swaywm-ipc
On Sunday, 8 March 2020 at 16:34:24 UTC, Martin Brezel wrote: If you are using swaywm (swaywm.org), then it may interest you that i started to implement its IPC interface: https://github.com/mab-on/swaywm-ipc `swaywmipc.core` is the implementation of https://www.mankier.com/7/sway-ipc `swaywmipc.client` is a higher-level client, easy to use. (https://github.com/mab-on/swaywm-ipc/blob/master/examples/client/source/app.d) Have fun! Nice to see that. I am a recent sway user myself. What are you using it for?
Re: Blog post on calling C from Python via D
On Wednesday, 26 February 2020 at 17:37:17 UTC, jmh530 wrote: On Wednesday, 26 February 2020 at 16:17:06 UTC, Panke wrote: [snip] If you had an RSS feed, I would subscribe. Wasn't there a planet D in the past? I've been subscribed on feedly without any issues. I can't recall what I actually did to subscribe as I can't seem to replicate it, but you can try https://atilaoncode.blog/feed/ Can't say for sure with other RSS readers. That works great, thanks!
Re: Blog post on calling C from Python via D
On Wednesday, 26 February 2020 at 14:51:06 UTC, Atila Neves wrote: On Wednesday, 19 February 2020 at 16:30:04 UTC, Atila Neves wrote: https://atilaoncode.blog/2020/02/19/want-to-call-c-from-python-use-d/ Discussion elsewhere: https://www.reddit.com/r/programming/comments/f6agvt/want_to_call_c_from_python_use_d/ https://news.ycombinator.com/item?id=22365166 A lot of the comments were about how stupid I was for not just using ctypes or cffi. I tried today and both of them are horrible. As I say in the blog post below, either they didn't read the article (people on the internet commenting on things they didn't even read? Shock! Horror!) or just aren't lazy enough. My followup: https://atilaoncode.blog/2020/02/26/seriously-just-use-d-to-call-c-from-python/ Very good read. I my opinion your work with integrating different languages with D is the most exciting stuff going on in the moment. If you had an RSS feed, I would subscribe. Wasn't there a planet D in the past?
Re: GSOC 2020 projects
On Monday, 24 February 2020 at 02:52:04 UTC, RazvanN wrote: On Tuesday, 18 February 2020 at 05:59:47 UTC, RazvanN wrote: Hello everyone! In a couple of days we should find out if The Dlang Foundation was accepted as a mentoring organization for Google Summer of Code 2020. If we get accepted, I think that we should have a list of priority projects that we should propose to students. I have started tagging what I find the most useful projects with the gsoc2020 tag [1]. If you want to help in this process you can: [...] Unfortunately, Dlang has not been accepted this year as a GSOC mentoring organization. Maybe we will have better luck next year, Cheers, RazvanN Do we know why?
best practices for a new project
When I start a new project is there anything that I should get right from the start? Like using a specific set of compiler flags (e.g. -dip1000)? Is there an overview over the status of upcoming language changes (-preview=?), e.g. what about -preview=rvaluerefparam? Should I use it?
Re: std.variant.Algebraic, self referential types and delegate members
On Sunday, 8 November 2015 at 11:28:05 UTC, Jonathan M Davis wrote: On Sunday, November 08, 2015 10:31:11 Panke via Digitalmars-d-learn wrote: import std.variant, std.stdio; --- struct NodeTypeA(T) { T[] children; } struct NodeTypeB(T) { Tree children; } struct Leaf(T) { T delegate() dg; } alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This); void main() { Tree t; } --- yields tmp.d(6): Error: functions cannot return opaque type This by value tmp.d(8): Error: template instance tmp.Leaf!(This) error instantiating This limitation seems arbitrary to me. What's the reason here? Okay. Several things here. For starters, NodeTypeA, NodeTypeB, and Leaf are not actually types. They're templates for types. If you want a type, you have to instantiate them. So, something like Algebraic!Leaf doesn't make any sense. You need an instantiation of Leaf - e.g. Algebraic!(Leaf!int) - rather than just Leaf. My failure, I've played with the code while crafting the post. I've used --- alias Tree = Algebraic!(Leaf!This, NoteTypeA!This, NoteTypeB!This) --- So no templates, just types. Next, you have a recursive template instantiation going on here. Tree depends on knowing what a NodeTypeB looks like, because it's using it in its instantiation of Algebraic. Algebraic!(Foo, Bar) is told to hold either a Foo or a Bar, which means that it needs to know their definitions - not just their names. You need to be using pointers if you want to be able to avoid having to know the actual definition of the type. So, when you tell NodeTypeB to hold a Tree when a Tree holds a NodeTypeB, it's impossible to figure out what the actual layout of those types. You have a recursive expansion. If you want to have a recursive type definition, you _must_ use pointers so that the actual definition of the type is not required. Thing is that delegate is nothing more than a glorified pair of pointers. Also, I have no idea what the deal with the This in your code is. IIRC, there's a feature involving This with template definitions, but you're just using it outside of a template definition, so I don't know if that's legal. It's a recent feature of Algebraic to allow recursive definitions. I'd assume that it uses pointers under the hood. Older compiler but same error message: http://goo.gl/P0wmqe
std.variant.Algebraic, self referential types and delegate members
import std.variant, std.stdio; --- struct NodeTypeA(T) { T[] children; } struct NodeTypeB(T) { Tree children; } struct Leaf(T) { T delegate() dg; } alias Tree = Algebraic!(Leaf, NodeTypeA!This, NodeTypeB!This); void main() { Tree t; } --- yields tmp.d(6): Error: functions cannot return opaque type This by value tmp.d(8): Error: template instance tmp.Leaf!(This) error instantiating This limitation seems arbitrary to me. What's the reason here?
dbgVerifySorted is not nothrow
I've updated my compiler and ran into this regression: https://issues.dlang.org/show_bug.cgi?id=14981 Code: --- import std.algorithm, std.container; void main() { static bool compare(P a, P b) { return a.curColumn < b.curColumn; } Array!P a = make!(Array!P); sort!compare(a[]); } struct P { int curColumn = 0; } --- Result: /usr/include/dlang/dmd/std/algorithm/sorting.d(982): Error: template instance std.range.assumeSorted!(compare, RangeT!(Array!(P))) error instantiating tmp.d(10):instantiated from here: sort!(compare, cast(SwapStrategy)0, RangeT!(Array!(P))) 1 tobias@akela ~ [i] % dmd -debug tmp.d /usr/include/dlang/dmd/std/range/package.d(7189): Error: 'std.range.SortedRange!(RangeT!(Array!(P)), compare).SortedRange.dbgVerifySorted' is not nothrow /usr/include/dlang/dmd/std/algorithm/sorting.d(982): Error: template instance std.range.assumeSorted!(compare, RangeT!(Array!(P))) error instantiating tmp.d(10):instantiated from here: sort!(compare, cast(SwapStrategy)0, RangeT!(Array!(P))) What I don't understand is, why dbgVerifySorted has to be nothrow in the first place. Is that an new requirement for contracts? I couldn't find any hint in the language spec.
Re: How to use std.experimental.logger?
Ah, I tried to format a custom struct that has a non-pure toString, because std.conv.to isn't pure either, sigh :(
How to use std.experimental.logger?
I tried it on Windows today using the latest DMD installer, all default logger and settings. I get: safe function [...].logImplf cannot call system function 'std.format.formattedWrite!(MsgRange, char, Result!()).formattedWrite' How do I make formatted logging work?
Re: A few thoughts on std.allocator
On Sunday, 10 May 2015 at 10:51:54 UTC, Michel Fortin wrote: On 2015-05-10 09:50:00 +, Andrei Alexandrescu seewebsiteforem...@erdani.org said: 3. Thread-local vs. shared objects Currently in D it's legal to allocate memory in one thread and deallocate it in another. (One simple way to look at it is casting to shared.) This has a large performance cost that only benefits very few actual cases. It follows that we need to change the notion that you first allocate memory and then brand it as shared. The will be shared knowledge must be present during allocation, and use different methods of allocation for the two cases. Shared is implicit in the case of immutable. Think carefully: if you implement this and it has any efficiency benefit for non-shared allocations, const-allocated objects and arrays will become more performant than immutable-allocated ones. People will thus have an incentive to stay away from immutable. If immutable does not pull its weight in other ways, it's just not worth it.
Re: Literan/constant ranges
On Sunday, 26 April 2015 at 06:43:22 UTC, Manu wrote: Man, I suck so hard at navigating the std library! Practically nothing is named anything I expect or am familiar with _ It shouldn't be easier to write my own than to find what I want in the lib. There are some differences though; repeat() is not a literal, and repeats infinitely, which means you need to conjoin take(n), which leads to a long and less-readable line. There is a second overload.
Re: Vectorization examples
No that's not true. On modern x86 processors using unaligned loading instructions on aligned data does not incur additional overhead, therefore you can always use unaligned load for everything, but loading unaligned data is still slower than aligned data. Thanks for clarifying.
Re: Today's programming challenge - How's your Range-Fu ?
Yes, again and again I encountered length related bugs with Unicode characters. Normalization is not 100% reliable. I think it is 100% reliable, it just doesn't make the problems go away. It just guarantees that two strings normalized to the same form are binary equal iff they are equal in the unicode sense. Nothing about columns or string length or grapheme count.
Re: Vectorization examples
On Monday, 20 April 2015 at 09:41:09 UTC, bearophile wrote: Utilizing the other 80% of your system's performance: Starting with Vectorization by Ulrich Drepper: https://www.youtube.com/watch?v=DXPfE2jGqg0 It shows two still missing parts of the D type system: a way to define strongly typed byte alignments for arrays (something better than the aligned() shown here, because I prefer the alignment to be part of the type), and a way to tell the type system that some array slices are fully distinct (the __restrict seen here, I think this information doesn't need to be part of a type). Bye, bearophile Aren't unaligned loads as fast as aligned loads on modern x86?
Re: Today's programming challenge - How's your Range-Fu ?
This can lead to subtle bugs, cf. length of random and e_one. You have to convert everything to dstring to get the expected result. However, this is not always desirable. There are three things that you need to be aware of when handling unicode: code units, code points and graphems. In general the length of one guarantees anything about the length of the other, except for utf32, which is a 1:1 mapping between code units and code points. In this thread, we were discussing the relationship between code points and graphemes. You're examples however apply to the relationship between code units and code points. To measure the columns needed to print a string, you'll need the number of graphemes. (d|)?string.length gives you the number of code units. If you normalize a string (in the sequence of characters/codepoints sense, not object.string) to NFC, it will decompose every precomposed character in the string (like é, single codeunit), establish a defined order between the composite characters and then recompose a selected few graphemes (like é). This way é always ends up as a single code unit in NFC. There are dozens of other combinations where you'll still have n:1 mapping between code points and graphemes left after normalization. Example given already in this thread: putting an arrow over an latin letter is typical in math and always more than one codepoint.
Re: Today's programming challenge - How's your Range-Fu ?
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote: On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote: To measure the columns needed to print a string, you'll need the number of graphemes. (d|)?string.length gives you the number of code units. Even that's not really true. Why? Doesn't string.length give you the byte count?
Re: Today's programming challenge - How's your Range-Fu ?
That doesn't make sense to me, because the umlauts and the accented e all have Unicode code point assignments. Yes, but you may have perfectly fine unicode text where the combined form is used. Actually there is a normalization form for unicode that requires the combined form. To be fully correct phobos needs to handle that as well.
Re: Today's programming challenge - How's your Range-Fu ?
On Saturday, 18 April 2015 at 08:18:46 UTC, Walter Bright wrote: On 4/18/2015 12:58 AM, John Colvin wrote: On Friday, 17 April 2015 at 18:41:59 UTC, Walter Bright wrote: On 4/17/2015 9:59 AM, H. S. Teoh via Digitalmars-d wrote: So either you have to throw out all pretenses of Unicode-correctness and just stick with ASCII-style per-character line-wrapping, or you have to live with byGrapheme with all the complexity that it entails. The former is quite easy to write -- I could throw it together in a couple o' hours max, but the latter is a pretty big project (cf. Unicode line-breaking algorithm, which is one of the TR's). It'd be good enough to duplicate the existing behavior, which is to treat decoded unicode characters as one column. Code points aren't equivalent to characters. They're not the same thing in most European languages, I know a bit of German, for what characters is that not true? Umlauts, if combined characters are used. Also words that still have their accents left after import from foreign languages. E.g. Café Getting all unicode correct seems a daunting task with a severe performance impact, esp. if we need to assume that a string might have any normalization form or none at all. See also: http://unicode.org/reports/tr15/#Norm_Forms
Re: Today's programming challenge - How's your Range-Fu ?
On Friday, 17 April 2015 at 19:44:41 UTC, ketmar wrote: On Fri, 17 Apr 2015 11:17:30 -0700, H. S. Teoh via Digitalmars-d wrote: Well, talk is cheap, so here's a working implementation of the non-Unicode-correct line wrapper that uses ranges and does not allocate: there is some... inconsistency: `std.string.wrap` adds final \n to string. ;-) but i always hated it for that. A range of lines instead of inserted \n would be a good API as well.
Re: Printing an std.container.Array
On Thursday, 16 April 2015 at 19:55:53 UTC, Bayan Rafeh wrote: How am I supposed to interpret this? The array contains two elements. The first equals one and the second equals two. What happens under the hood is that Array does no provide a toString method, instead a default is used. This results in your first output. For ranges - and the slice of the array is a range while the array is not - writeln prints the elements as a special case which leads to your second output.
Re: Printing an std.container.Array
Yep, but problem is almost no one expect this, or know this. We definitely should do better. How?
Re: How D could gain more traction?
The problem with a kitchen sink approach is that you have to make sure the libraries stay up to date - and phobos already has a few rotting modules. Which modules do you mean? There are some modules that are considered to have a bad design or lacking implementation, but none that do not work anymore with the newest DMD. See: python, many people actively avoid using the standard library in favor of third party libraries that accomplish the same task. There will always be a better solution in the future than the implementation included in the standard library today. However that is no argument against the kitchen sink.
Re: Named unittests
We need template to use compile time reflection. Please don't make it all compile time. It is useful to register tests at runtime as well. Like one tests per SAT instance in a given SAT benchmark. Practically only thing we need is a standard way to register a test function as a unittest and associate a key-value store with it.
Re: Gary Willoughby: Why Go's design is a disservice to intelligent programmers
Umm that was me... I don't feel confident enough to write at a Phobos standard yet and might be a little while before I am experienced enough. But I see your point. Fastest way to get better is to submit PRs and get reviewed.
Re: Named unittests
On Monday, 30 March 2015 at 21:57:33 UTC, Andrei Alexandrescu wrote: On 3/30/15 2:55 PM, Panke wrote: I've implemented this in a library and I'm sure others have as well. Are you sure, you want a language solution? With attributes? That might be palatable but only as a standard solution. I'd want to add that to Phobos. -- Andrei In my case: no. I wrote it before UDA and wanted to be able to generate testcases at runtime. Used this to register a test case for a SAT solver for every instance in a subdirectory etc.
Re: Named unittests
Backward compatibility is not an issue seeing this is a pure addition. Andrei I mean that it lives peacefully alongside normal unittest blocks.
Re: Named unittests
I've implemented this in a library and I'm sure others have as well. Are you sure, you want a language solution? Basic principle: --- unittest { testCase(a testcase, { // actual test code here }); } --- Testcase registers the structure and the runtime just runs the unittest as is does today and than calls all closures registered during the unittest. Makes this fully backward compatible.
Re: Named unittests
On Monday, 30 March 2015 at 21:52:35 UTC, Andrei Alexandrescu wrote: We're having a strong need for named unittests at Facebook for multiple reasons. 1. We have sophisticated tooling that verifies whether unittests are flaky. The automated monitor (for e.g. C++) figures whether a given unittest fails several times across several commits. Unittests are identified by name; relying on file/line is impossible because the line of a failure is not stable across changes. 2. Again for efficient automated testing and flakiness detection, one should be able to run only a subset of unittests by mentioning them by line in the command line. Note that this implies there's no interdependency between distinct unittests, which is fine because the new ability is opt-on; I'd say is pure style anyway. 3. Mentioning unittest names in failure messages helps human communication (e.g. AddPeer is failing after your change). This is impossible with file and line numbers. I'd like to make a DIP for named unittests. Who can help me with that? Andrei I've implemented this in a library and I'm sure others have as well. Are you sure, you want a language solution?
Re: Human unreadable documentation - the ugly seam between simple D and complex D
On Thursday, 26 March 2015 at 21:36:56 UTC, rumbu wrote: On Thursday, 26 March 2015 at 19:45:19 UTC, Alex Parrill wrote: On Thursday, 26 March 2015 at 19:32:53 UTC, Idan Arye wrote: ...snip... So tl;dr; make the template constraints in ddoc less prominent? The new library reference preview under Resources seems to already have this (example: http://dlang.org/library/std/algorithm/searching/starts_with.html) This will not solve the readability problem: - what is a range? - what is a needle? - what is a predicate? Phobos is reinventing the OOP encapsulation without providing the minimal tools. IMHO, something similar to interface is mandatory to define constraints for range and the relationship between needle and range. Never heard that complain about python's protocols which have no language support whatsoever.
Re: How to generate a random string ...
On Monday, 16 March 2015 at 13:33:55 UTC, Robert burner Schadek wrote: ... from all Unicode characters in an idiomatic D way? (std.interal.unicode_*) ``` T genUnicodeString(T)(size_t minChars, size_t maxChars) if(isSomeString!T) { ... } ``` You'll need two things. A uniform distribution of { 0 ... 113,020 }, this should be easy using phobos. And a mapping of { 0 ... 113,020 } - unicode ( or UTFX directly ). Since the unicode planes or not connected, this might involve some kind of table. Then just generate your uniform distribution and apply the mapping.
Re: A few notes on choosing between Go and D for a quick project
How do you keep it around if you cant declare a member to hold it? It's all well and good explaining the reason for them but it doesnt void the fact that they are a PITA if you say want to use cvsReader to parse some records and keep the results as a class member. I don't think csvReader supports your point. The input range returned is not for permanent storage, just store the struct if you've used csvReadder!SomeStruct or store cells individually as Contents if you used csvReader!Contents. (by default Contents is string). I think it's a very good api.