libaio

2020-07-16 Thread Boris-Barboris via Digitalmars-d-announce
https://github.com/Boris-Barboris/libaio/blob/master/source/libaio/package.d https://code.dlang.org/packages/libaio If you need to write some shady block-level stuff for Linux libaio this thin Derelict loader can save a day of your time.

Why does foreach allow ref element for non-ref front() of std.range.enumerate()

2020-01-26 Thread Boris-Barboris via Digitalmars-d-learn
import std; import std.range; void main() { int[] a = [3, 5, 7]; foreach (i, ref ae; a.enumerate) { writeln(i, " ", ae); ae = 6; } writeln(a); assert(a[].equal([6, 6, 6])); // fails, a is in initial state } Why does the compiler allow such 'ref ae' loop,

Re: Bitfields

2019-05-21 Thread Boris-Barboris via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 17:16:05 UTC, Russel Winder wrote: Hi, Has anyone used D to work with arbitrary length bitfields with multiple occurences of a sub-bitfield. I am working with DVB Sections and EIT packets are defined as bitfields with loops in them and the header is 112 bits. The

Re: Tweakig -lowmem to be more eager

2019-05-20 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 19 May 2019 at 23:54:27 UTC, Anonymouse wrote: What makes it decide to collect? What triggers it? You can try setting heapSizeFactor option to something lower than 2 to increase collection frequency:

Re: Linked List iterating over and inserting an element around (before/after) the current position.

2019-05-19 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 19 May 2019 at 22:20:48 UTC, Josh wrote: This is just more curiosity, but do you happen to know why I have to use DList.linearRemove() instead of DList.remove()? These two functions are separate because they differ in complexity. remove is O(1), linearRemove on the other hand

Re: Anonymous mapped regions increases unlimitely on spawn

2018-12-14 Thread Boris-Barboris via Digitalmars-d-learn
On Friday, 14 December 2018 at 21:22:05 UTC, unDEFER wrote: So it looks like a bug, and I have reported about it: https://issues.dlang.org/show_bug.cgi?id=19487 Not an expert, but you may wish to try GC.minimize() (https://dlang.org/phobos/core_memory.html#.GC.minimize).

Re: Can you move a disabled this(this) struct in to a container type if it's an rvalue?

2018-12-13 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote: Ie: struct S { @disable this(this); this(int i) {} } struct Container(T) { T value; this(T value) { this.value = value; } } void main() { auto a = Container!S(S(3)); // can't do this. } I can build a

Re: Throwing constructors and member destructors

2018-11-20 Thread Boris-Barboris via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 13:20:08 UTC, Stanislav Blinov wrote: https://dlang.org/changelog/2.083.0.html#reboot14246 Wording "object" means both classes and structs?

Re: Throwing constructors and member destructors

2018-11-20 Thread Boris-Barboris via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 13:20:08 UTC, Stanislav Blinov wrote: https://dlang.org/changelog/2.083.0.html#reboot14246 Nvm, found the info in the issue tracker, thank you for the link.

Throwing constructors and member destructors

2018-11-20 Thread Boris-Barboris via Digitalmars-d-learn
https://run.dlang.io/is/LdylJX Notice no "B destructor" line in stdout. Just got bitten by the assumption that my Buffer struct that transactionally aquires multiple external resources in constructor will rollback via member destructors that were successfully completed before the throw.

Re: custom sorting of lists ?

2018-10-14 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 14 October 2018 at 01:31:26 UTC, Jonathan M Davis wrote: Unless there's something about the implementation that's tied to the list itself, I would think that it would make more sense to make it a generic algorithm, then it will work with any non-random-access range, and it avoids

Re: Thread-safe attribution

2018-10-07 Thread Boris-Barboris via Digitalmars-d
On Sunday, 7 October 2018 at 02:01:17 UTC, Manu wrote: ... but I'm really struggling to express it in terms of the type system... I'm pretty sure no simple attribute system is any more useful than current const\shared idiom. I am yet to see a language with semantics that actually help with

Re: Use nested functions as callbacks with Windows API functions?

2018-10-02 Thread Boris-Barboris via Digitalmars-d-learn
On Monday, 1 October 2018 at 23:07:29 UTC, spikespaz wrote: The problem with the code you have is that the callback needs to be extern (Windows). I don't know how to do that with a "lambda". Neither do I actually. Apparently it is impossible. Best I could squeeze out was this:

Re: Use nested functions as callbacks with Windows API functions?

2018-10-01 Thread Boris-Barboris via Digitalmars-d-learn
On Monday, 1 October 2018 at 20:27:43 UTC, spikespaz wrote: I was hoping I could use something more akin to JavaScript's syntax: (void* hWnd, long) => {}. I tried this but I'm getting errors with the signature, it says the function is a delegate and apparently Windows API can't accept a

Re: Dicebot on leaving D: It is anarchy driven development in all its glory.

2018-08-25 Thread Boris-Barboris via Digitalmars-d
On Saturday, 25 August 2018 at 20:52:06 UTC, Walter Bright wrote: I.e. a nothrow constructor now must call a throwing destructor. This is not some made up example, it breaks existing code: https://github.com/dlang/dmd/pull/6816 If I fix the bug, I break existing code, and apparently a

Re: Why do core.atomic functions require shared

2018-07-04 Thread Boris-Barboris via Digitalmars-d
On Wednesday, 4 July 2018 at 10:47:12 UTC, Jonathan M Davis wrote: At this point, to operate on anything that's shared, either means using atomics or protecting the data with a mutex (be that with a synchronized block / function or a mutex object) and temporarily casting away shared while

Why do core.atomic functions require shared

2018-07-04 Thread Boris-Barboris via Digitalmars-d
Given the pain of shared usage with std and pretty much every library in existence, I cowboyed the server without this qualifier. One of the mechanisms required atomic class reference compare-and-set, and the class reference is not shared, because it would otherwise require, like, 30 or 40

Re: Optional parameters?

2018-04-01 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 1 April 2018 at 22:44:45 UTC, Jonathan M Davis wrote: Which doesn't work in @safe code and doesn't work when you have an rvalue as you would when passing 42. Ultimately, using pointers ultimately either requires explicitly allocating stuff on the heap to be able to pass rvalues, or

Re: Optional parameters?

2018-04-01 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 1 April 2018 at 22:25:45 UTC, Jonathan M Davis wrote: How would a pointer help? Instead of doing foo(nullable(42)) he'd have to do foo(new int(42)) which is just one character shorter and ends up allocating on the heap, unlike with Nullable. - Jonathan M Davis foo();

Re: Optional parameters?

2018-04-01 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer wrote: I currently have a situation where I want to have a function that accepts a parameter optionally. I would simply use a pointer for this. Fighting D grammar seems too much of a hassle for such simple task.

Re: Fast GC allocation of many small objects

2018-03-31 Thread Boris-Barboris via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:31:35 UTC, Per Nordlöw wrote: Is there a faster way of allocating many small class objects such as... maybe something like this: import std.conv: to; import std.stdio; class Node {} class StrNode : Node { string value; } void main() {

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Boris-Barboris via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via Now that DIP 1000 is being implemented, and scope is actually going to do something for more than just delegates, it was deemed too dangerous to have in suddenly really

"in" no longer "scope" since 2.079.0?

2018-03-27 Thread Boris-Barboris via Digitalmars-d-learn
Hello! Can someone point me to the changelong entry or maybe a pull request, wich changed the "in" from "scope const" to "const"? I thought the previous matter of things was pretty natural, and current "in" is now redundant. Would be glad to read up on this design decision.

Re: opDispatch with string mixin does not work as I would expect.

2018-02-09 Thread Boris-Barboris via Digitalmars-d-learn
On Saturday, 10 February 2018 at 06:32:43 UTC, German Diago wrote: The mixin line does not work. I want to generate the access to the field. How could I achieve that? struct Outer { struct Inner { int a; float b; } Inner i;

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-06 Thread Boris-Barboris via Digitalmars-d
On Tuesday, 6 February 2018 at 23:08:48 UTC, David Nadlinger wrote: Apparently, GDC folks do not populate builtin module, so there's no easy way to look check it, besides actually trying to compile:

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-06 Thread Boris-Barboris via Digitalmars-d
On Tuesday, 6 February 2018 at 23:08:48 UTC, David Nadlinger wrote: Oh, look: https://github.com/ldc-developers/druntime/blob/7b77937c70b4aba720e98727dcaad3323c29bd8d/src/ldc/intrinsics.di#L579-L587 — David Not gcc, no platforms, BEBEBEBEBEBE. On the serious note: nice, good to see.

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-05 Thread Boris-Barboris via Digitalmars-d
On Tuesday, 6 February 2018 at 02:31:42 UTC, psychoticRabbit wrote: Plenty of others seems to have a different opinion ;-) That's just my opinion. My generation has plenty of C++ programmers, but I have no acquaintance who does userspace C. I would never do that too, unless forced to work

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-05 Thread Boris-Barboris via Digitalmars-d
On Monday, 5 February 2018 at 23:42:18 UTC, welkam wrote: There is PGO (Profile Guided Optimization) that can do that without additional language extensions. You need to find better example to support your claims. It is sometimes impossible. Some parts of the Linux kernel cannot be profiled

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-05 Thread Boris-Barboris via Digitalmars-d
On Monday, 5 February 2018 at 20:12:09 UTC, Walter Bright wrote: Most of those gcc builtin's I've never heard of, and I've been programming C for 35 years now. I've also never had a use for them. I find it hard to believe that list would be a deal breaker, especially since much of it seems to

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-05 Thread Boris-Barboris via Digitalmars-d
On Monday, 5 February 2018 at 05:28:54 UTC, Walter Bright wrote: True, D cannot directly read .h files. There are tools, though, to convert C .h files to D. 'Tools' sounds very capritious, but I have no experience with such things. I somehow doubt things like SWIG will work ok on kernel

Re: My choice to pick Go over D ( and Rust ), mostly non-technical

2018-02-04 Thread Boris-Barboris via Digitalmars-d
On Sunday, 4 February 2018 at 20:15:47 UTC, bpr wrote: Which benefits of C are lost? Ability to interface with C using C header files of a target library\executable as-is. Being able to understand the interfaces your operating system provides, described on the language it uses, is a huge

Re: Using Postgres connection functions

2018-01-16 Thread Boris-Barboris via Digitalmars-d-learn
On Saturday, 13 January 2018 at 17:58:14 UTC, Joe wrote: ...ddb. The latter perhaps has the distinction that it doesn't use libpq, but rather implements the Postgres FE/BE protocol. That's a bit *too* native for my taste. It means the library maintainer has to keep up with changes to the

Re: dpeq - native PSQL extended query protocol client

2017-09-05 Thread Boris-Barboris via Digitalmars-d-announce
On Tuesday, 5 September 2017 at 03:22:37 UTC, denizzzka wrote: On Monday, 4 September 2017 at 17:56:04 UTC, Boris-Barboris wrote: On Monday, 4 September 2017 at 16:05:17 UTC, denizzzka wrote: Sorry fot duplicate answer Ok, just FYI, I guess what I described was implemented in libpq for

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 16:05:17 UTC, denizzzka wrote: Sorry fot duplicate answer Ok, just FYI, I guess what I described was implemented in libpq for version 9.6 (but works on any PSQL since 8.4, since they all implement extended query protocol i wrote the client for) in a form of

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 15:53:30 UTC, denizzzka wrote: I dare say that you are engaged in premature optimization. Quite possible, but it took tolerable amount of time. I definetly will play with dpq2 more some day, maybe there is indeed no need to reinvent libpq. But what's done is

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 15:45:23 UTC, denizzzka wrote: Also, ORM is typical architecturial error. https://en.m.wikipedia.org/wiki/Object-relational_impedance_mismatch It's a tool. Error is when you use wrong tool for your job. ORMs surely help many people, and do a lot of good.

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 15:40:47 UTC, denizzzka wrote: This is just internal function. Don't try to call it from your application. I guess it's the Python curse Oh... What is it: PARSE + BIND + EXEC + SYNC ? Yeah, that's what I do currently, just write the whole command chain (same

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 15:28:11 UTC, denizzzka wrote: What do you mean? It seems like a very generic method way to send batched messages, wich would give a lot of freedom. Possible without any src modify. Will linux socket get a send called between them, or it will be buffered by

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 14:42:31 UTC, denizzzka wrote: https://github.com/denizzzka/vibe.d.db.postgresql uses dpq2 backend https://github.com/denizzzka/vibe.d.db.postgresql/blob/master/source/vibe/db/postgresql/package.d#L92 Very interesting read, thank you. Making this:

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 12:07:29 UTC, Jacob Carlborg wrote: Ah, ok. I didn't know about hb-ddb until you started this thread. I'm currently one of the maintainers of ddb and I haven't seen anything upstreamed there. Haha, yeah, I guess I've developed a habit of looking at github

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 09:30:06 UTC, Suliman wrote: Could you give an example how to make connection object if I need access to it from several classes? Should it be global? """Good way""" is probably to wrap it into some ConnectionPool (at least that's what I did). Snipper from

Re: dpeq - native PSQL extended query protocol client

2017-09-04 Thread Boris-Barboris via Digitalmars-d-announce
On Monday, 4 September 2017 at 06:40:09 UTC, Jacob Carlborg wrote: If would be great if you want to upstream your improvements. I think it's a bit unfortunate that everyone is rolling their own implementations in this community instead of working together. I would say that it's rare to need

dpeq - native PSQL extended query protocol client

2017-09-03 Thread Boris-Barboris via Digitalmars-d-announce
Hi! Couple of weeks ago I was approached with a task of writing simple microservice, and I decided to give D a chance. The problem with performance became apparent very soon, and I started to look for the cause. I tried all existing libraries, and noted pretty mature dpq2 and ddb (and it's

Re: daii - allocator-friendly closures and raii

2017-06-23 Thread Boris-Barboris via Digitalmars-d-announce
On Friday, 23 June 2017 at 20:13:07 UTC, ag0aep6g wrote: You've got bad `@trusted`s: Ty, I misunderstood the concept. I guess in a code like this it's mostly @system anyways, too many indirections to control safety level. I'm probably gonna remove most of the attributes.

daii - allocator-friendly closures and raii

2017-06-23 Thread Boris-Barboris via Digitalmars-d-announce
Hi, I wrote a small library, inspired by atilaneves automem. I didn't like some things, especially that smart pointers proxied underlying types, also I wanted class upcasting. https://github.com/Boris-Barboris/daii https://code.dlang.org/packages/daii What do you think about the

Re: struct template constructors

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 21:16:40 UTC, Ali Çehreli wrote: And yes, there should be one destructor, which may be a no-op if you grab its resource and set it to null. On all compilers... That's a relief, thank you for your help.

Re: struct template constructors

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 20:05:46 UTC, Ali Çehreli wrote: To be complete, 'auto ref' passes lvalues by reference and rvalues by value, which you can detect with __traits(isRef): struct S{ } void foo()(auto ref S s) { static if (__traits(isRef, s)) { pragma(msg, "lvalue");

Re: struct template constructors

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 19:17:13 UTC, Ali Çehreli wrote: No time to think about the rest of the design but just to get the code compiled, replace 'ref' with 'auto ref' like so: Ok, looks like this indeed passes rhs by reference, thank you. destcalls - number of times UniquePtr destructor

Re: struct template constructors

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 19:17:13 UTC, Ali Çehreli wrote: No time to think about the rest of the design but just to get the code compiled, replace 'ref' with 'auto ref' like so: this(DT)(scope auto ref UniquePtr!DT rhs) { // ... } Ali i added this static variable:

Re: Dealing with the interior pointers bug

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 19:11:19 UTC, Cym13 wrote: Here it's the programmer's fault really. You should never use casts in normal code, cast is the ultimate switch to say "Look, I know what I'm doing, so disable all safety, don't try to make sense of it, and let me do my thing. If I'm

struct template constructors

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
Hi https://dpaste.dzfl.pl/0def4e286564 Is there a cleaner way to go than the one on the line 26? And why is the constructor /d475/f781.d(37): f781.UniquePtr!(A).UniquePtr.__ctor(DT)(ref scope UniquePtr!DT rhs) unfit for line 51? Is it because the expression " = UniquePtr!B.make()" cannot

Re: Dealing with the interior pointers bug

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 13:56:29 UTC, ag0aep6g wrote: For example, the type system guarantees that immutable data never changes. But the compiler allows you to cast from immutable to mutable and change the data. It's an invalid operation, but the compiler is not expected to catch that for

Re: Dealing with the interior pointers bug

2017-06-22 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 22 June 2017 at 09:45:09 UTC, Russel Winder wrote: I think the term "systems programming language" contains no actual data, so needs to be retired. In this situation it provides no reason for conservative garbage collection. It means the intent of language designer to let you

Re: D structs weak identity and RAII

2017-06-19 Thread Boris-Barboris via Digitalmars-d-learn
On Monday, 19 June 2017 at 06:34:49 UTC, Ali Çehreli wrote: It's unreliable because structs are value types in D, which means that they can be moved around freely. This is why self-referencing structs are illegal in D. I guess it's more like the spec states, that they can be moved vithout

D structs weak identity and RAII

2017-06-18 Thread Boris-Barboris via Digitalmars-d-learn
Hello, I was trying to write some templated unique pointers. Idea was simple: struct UniquePointer that handles underlying pointer in RAII-style and WeakPointer struct that is spawned by UniquePointer. Weak pointer is handled differently in my collections, wich subscribe to the event of

Re: DList efficiency

2017-06-08 Thread Boris-Barboris via Digitalmars-d-learn
On Thursday, 8 June 2017 at 22:42:14 UTC, Boris-Barboris wrote: 1). Do I understand correctly, that there is currently no way (aside from editing the sources of course) to efficiently (using one underlying iteration) remove all\first element(s) from DList based on a predicate? Oh, sorry, I

DList efficiency

2017-06-08 Thread Boris-Barboris via Digitalmars-d-learn
Good day to you reader! I have a couple questions about Phobos: 1). Do I understand correctly, that there is currently no way (aside from editing the sources of course) to efficiently (using one underlying iteration) remove all\first element(s) from DList based on a predicate? Can such

Re: protected behaviour on base class member access from another module

2017-04-30 Thread Boris-Barboris via Digitalmars-d-learn
Ok, sorry, look's like that was always the case in C++, so it's too late to question it. I'll just elevate it to package, I guess.

protected behaviour on base class member access from another module

2017-04-30 Thread Boris-Barboris via Digitalmars-d-learn
Hi! I have a base class in module A: module A; ... class GuiElement: GuiComponent { protected { GuiElement _parent; ... } template isGuiElement(T) { enum isGuiElement = is(T: GuiElement); } ... and derived class in module B: module B; ... class Div(uint dim, uint odim):

Re: strange CFTE issue

2017-04-09 Thread Boris-Barboris via Digitalmars-d-learn
On Sunday, 9 April 2017 at 16:44:41 UTC, ag0aep6g wrote: Or you can make it a template value parameter [2] with type `string[]`: string[] sfilter(T, string[] fields)() { string[] result; foreach (f; aliasSeqOf!fields) { /* ... loop body as you have it ... */ }

Re: strange CFTE issue

2017-04-09 Thread Boris-Barboris via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 17:27:35 UTC, ag0aep6g wrote: Phobos has it: std.meta.aliasSeqOf "converts an input range [...] to an alias sequence." [1] Woops, forgot to give the URL for that "[1]". Here it is: http://dlang.org/phobos/std_meta.html#aliasSeqOf Hello, I have a similar

Re: Whole source-tree statefull preprocessing, notion of a whole program

2017-04-08 Thread Boris-Barboris via Digitalmars-d
On Saturday, 8 April 2017 at 17:57:11 UTC, Vladimir Panteleev wrote: Yes; in my opinion, I think that's desirable because it is aligned with the unidirectional flow of information from higher-level components to lower-level ones, and does not impose a particular configuration framework onto

Re: Whole source-tree statefull preprocessing, notion of a whole program

2017-04-08 Thread Boris-Barboris via Digitalmars-d
On Saturday, 8 April 2017 at 13:09:59 UTC, Vladimir Panteleev wrote: On Saturday, 8 April 2017 at 10:11:11 UTC, Boris-Barboris wrote: 2). After preprocessing I wish to have fully-typed, safe and fast Config class, that contains all the groups I defined for it in it's body, and not as

Whole source-tree statefull preprocessing, notion of a whole program

2017-04-08 Thread Boris-Barboris via Digitalmars-d
Hello! It's a bit long one, I guess, but I'd like to have some discussion of topic. I'll start with a concrete use case: For the sake of entertainment, I tried to wrote generic configuration management class. I was inspired by oslo_config python package that I have to deal with on work. I