Re: Warning on self assignment

2018-04-25 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 25 April 2018 at 03:32:09 UTC, Meta wrote: On Wednesday, 25 April 2018 at 02:32:32 UTC, Per Nordlöw wrote: On Wednesday, 25 April 2018 at 02:23:04 UTC, Mike Franklin wrote: Are people using self assignment of structs as a way of force-running the postblit? Is there a valid use ca

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-08-30 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 30 August 2018 at 16:12:24 UTC, kinke wrote: Nope, I now think this is more likely an issue with the default config (etc/ldc2.conf). It contains a new section for WebAssembly, which specificies `-link-internally`, which seems to be wrongly used for non-WebAssembly too in your case.

Re: Cannot make sense of LLD linker error with ldc 1.11.0

2018-09-01 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 30 August 2018 at 20:36:02 UTC, kinke wrote: On Thursday, 30 August 2018 at 19:41:38 UTC, Nordlöw wrote: I'm using the tar.xz for x64 Linux. Ok? You're explicitly adding `-link-internally` in your top-level dub.sdl: dflags "-link-internally" platform="linux-ldc" # use GNU gold

DIP 1000 and classes

2019-01-03 Thread Nordlöw via Digitalmars-d-learn
How does DIP 1000 treat the lifetime scoped class parameters and containers of classes?

Faster alternatives to std.xml

2017-07-08 Thread Nordlöw via Digitalmars-d-learn
What's the fastest XML-parser on code.dlang.org? Are there any benchmarks that show performance improvements compared to std.xml?

Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
I'm want to define a specialization of `append()` that takes only static arrays as inputs and returns a static array being the sum of the lengths of the inputs. Have anybody already implemented this? If not, I'm specifically interested in how to most conveniently infer the length (as an enum)

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 17:46:42 UTC, ag0aep6g wrote: int[n + m] result = a ~ b; Further, the expression `a ~ b` here will allocate and create a copy on the GC-heap before writing `result`. Maybe LDC optimizes away this now or in the future but DMD cannot. Yeah I know, kind of dumb b

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 17:46:42 UTC, ag0aep6g wrote: Like so? int[n + m] append(size_t n, size_t m)(int[n] a, int[m] b) { int[n + m] result = a ~ b; return result; } Thanks, but I'm talking about the variadic case where the number of input arguments are unknown (>= 2) where the fu

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 17:38:23 UTC, Nordlöw wrote: I'm want to define a specialization of `append()` that takes only static arrays as inputs and returns a static array being the sum of the lengths of the inputs. Have anybody already implemented this? If not, I'm specifically interested i

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 18:54:31 UTC, Stefan Koch wrote: So all you need to do make it so auto cat(T[]...)(T args) { T[] result; mixin(() { string mix = `result = `; foreach(i;args.length) { mix ~= `args[` ~ itos(i) ~ `] ~`; } mix[$-1] = ';';

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 18:54:31 UTC, Stefan Koch wrote: we have special code in the compiler to optimize a ~ b ~ c. Interesting, can you elaborate on what you mean with "optimize". In that case, is there a reason why int x[2]; int y[2]; int z[x.length + y.length] = x ~ y; isn

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 19:11:26 UTC, H. S. Teoh wrote: Hmm, since we already have sumOfLengths available at compile-time, what about: T[sumOfLengths!StaticArrays] append(StaticArrays...)(StaticArrays arrays) if (allSatisfy!(isStaticArray, StaticArrays)) {

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 20:10:31 UTC, H. S. Teoh wrote: On Mon, Jul 17, 2017 at 08:11:03PM +, Nordlöw via Digitalmars-d-learn wrote: [...] Does this have a place in Phobos? Never know till you try. :-D If so, - under what name: append, concat or cat? I'd vote for c

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 20:53:36 UTC, H. S. Teoh wrote: See the working implementation in my latest post on this thread. That version supports CommonType, and works correctly with empty tuples as well. T Thanks.

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 20:01:41 UTC, H. S. Teoh wrote: OK, here's an actual, compilable, runnable version: import std.algorithm : sum; import std.meta : allSatisfy, staticMap; import std.range : only; import std.traits : CommonType, isStaticArray; ali

Re: Appending static arrays

2017-07-17 Thread Nordlöw via Digitalmars-d-learn
On Monday, 17 July 2017 at 20:28:12 UTC, Nordlöw wrote: Made some adjustments with working unittest and put it up on https://github.com/nordlow/phobos-next/blob/master/src/algorithm_ex.d#L2467 Moved here https://github.com/nordlow/phobos-next/blob/master/src/array_ex.d#L2765

Re: Appending static arrays

2017-07-18 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 08:07:45 UTC, Jacob Carlborg wrote: append - add array or element to existing array concat (concatenate) - add to arrays (or element) together to create a new array Seems like this is a concatenation. But please avoid shortening the names. I vote you go with "conca

this r-value optimizations

2017-08-01 Thread Nordlöw via Digitalmars-d-learn
Given the `struct S` with lots of data fields, I've written the following functional way of initializing only a subset of the members in an instance of `S`: struct S { int i; float f; ... this(int i) { this.i = i; } S withF(float f) { // will this be optimized

readText with added null-terminator that enables sentinel-based search

2017-08-08 Thread Nordlöw via Digitalmars-d-learn
Has anybody written a wrapper around `std.file.readText` (or similar) that appends a final zero-byte terminator in order to realize sentinel-based search in textual parsers.

Cannot use std.array.Appender in recursive types

2017-08-09 Thread Nordlöw via Digitalmars-d-learn
Why doesn't appending to `subs` work with std.array.Appender in struct T { string src; import std.array : Appender; Appender!(T[]) subs; } T t; t.subs ~= T.init; // ERRORS t.subs.put(T.init); // ERRORS when it works with builtin arrays as in s

Re: Cannot use std.array.Appender in recursive types

2017-08-09 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 19:00:54 UTC, Steven Schveighoffer wrote: If I change the definition of ElementType to use R.init.front instead of R.init.front.init, it compiles. But I'm pretty sure this will break other ranges. If Phobos compiles with the change would that change deserve a PR?

(SIMD) Optimized multi-byte chunk scanning

2017-08-23 Thread Nordlöw via Digitalmars-d-learn
I recall seeing some C/C++/D code that optimizes the comment- and whitespace-skipping parts (tokens) of lexers by operating on 2, 4 or 8-byte chunks instead of single-byte chunks. This in the case when token-terminators are expressed as sets of (alternative) ASCII-characters. For instance, wh

Choosing between enum arrays or AliasSeqs

2017-08-24 Thread Nordlöw via Digitalmars-d-learn
Given enum e = ['a', 'b', 'c']; import std.meta : AliasSeq; enum a = AliasSeq!['a', 'b', 'c']; is it somehow possible to convert (at compile-time) `e` to `a`? Is it cheaper CT-performance wise to use AliasSeq instead of enum static arrays? My use case is expressed by the TODOs in t

Re: Choosing between enum arrays or AliasSeqs

2017-08-24 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 24 August 2017 at 22:38:29 UTC, Meta wrote: https://dlang.org/phobos/std_meta.html#aliasSeqOf Thanks! Your advice led to the following sample solution import std.meta : aliasSeqOf; immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) { re

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
On Friday, 25 August 2017 at 08:27:41 UTC, Jacob Carlborg wrote: Since you're converting the returned index to a bool, can't you use "canFind" instead? immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) { return englishIndefiniteArticles.canFind(s); }

Re: (SIMD) Optimized multi-byte chunk scanning

2017-08-25 Thread Nordlöw via Digitalmars-d-learn
On Friday, 25 August 2017 at 09:40:28 UTC, Igor wrote: As for a nice reference of intel intrinsics: https://software.intel.com/sites/landingpage/IntrinsicsGuide/ Wow, what a fabulous UX!

Re: Casting non-aliased mutable arrays to immutable in return values

2017-08-29 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 16:41:48 UTC, Jonathan M Davis wrote: Regardless, using assumeUnique or using a pure function to construct the object and implicitly convert it to immutable works for types in general. - Jonathan M Davis I'm, as always, grateful for your thorough answers, Jonath

High-level wrapper for readline package

2017-09-07 Thread Nordlöw via Digitalmars-d-learn
Have anybody cooked together high-level bindings on top of the C-bindings for libreadline here http://code.dlang.org/packages/readline ?

Re: High-level wrapper for readline package

2017-09-07 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 7 September 2017 at 13:44:52 UTC, Adam D. Ruppe wrote: On Thursday, 7 September 2017 at 13:37:16 UTC, Nordlöw wrote: Have anybody cooked together high-level bindings on top of the C-bindings for libreadline here Have you ever used readline? The basic C api is already very high le

Re: High-level wrapper for readline package

2017-09-07 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 7 September 2017 at 16:23:46 UTC, Adam D. Ruppe wrote: On Thursday, 7 September 2017 at 16:18:09 UTC, bauss wrote: Isn't it pointless to make "prompt" in? No, it promises the function isn't doing anything weird to it (modify, which immutable covers, but also scope.. .unless dmd

Re: High-level wrapper for readline package

2017-09-07 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 7 September 2017 at 15:31:13 UTC, Nemanja Boric wrote: Minor point: you should add_history only if `lineStringz && lineStringz[0] != '\0'` Wonderful. That prevented a crashs when writing history. Thanks!

Re: High-level wrapper for readline package

2017-09-07 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 7 September 2017 at 19:45:06 UTC, Adam D. Ruppe wrote: On Thursday, 7 September 2017 at 19:38:38 UTC, Nordlöw wrote: But I believe it's ok to relax it from `string` to `const(char)[]`, right? Yeah, it should be const(char)[] or even `in char[]` Ahh, correct.

Cannot make sense of link error

2017-09-09 Thread Nordlöw via Digitalmars-d-learn
When I clone master of https://github.com/nordlow/phobos-next.git and test it with DMD 2.076 as /usr/bin/dub test --compiler=dmd linking fails as Generating test runner configuration 'phobos-next-test-library' for 'library' (library). Performing "unittest" build using dmd for x86_64. phobos

Re: Cannot make sense of link error

2017-09-09 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 9 September 2017 at 15:41:48 UTC, Nordlöw wrote: When I compile it separately I don't get the linker error. /usr/bin/dmd --version: DMD64 D Compiler v2.076.0-dirty /usr/bin/dub --version: DUB version 1.5.0, built on Sep 1 2017 Making the contents of the module zio.d empty has no

extern(C) and slices

2017-09-11 Thread Nordlöw via Digitalmars-d-learn
If I have a function like `extern(C) void f(void *x, size_t x_sz)` can I instead declare it as `extern(C) void f(void[] x)` ?

Temporarily adding -vgc to a DUB build

2017-09-16 Thread Nordlöw via Digitalmars-d-learn
How do I temporarily enable -vgc when building my app with DUB? I've tried DFLAGS=-vgc /usr/bin/dub build --build=unittest but it doesn't seem to have any effect as it doesn't rebuild directly after the call /usr/bin/dub build --build=unittest I'm using DUB version 1.5.0 Or is adding a new

Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
How can T[n] asStatic(T, size_t n)(T[n] arr) { import std.traits : isCopyable; static if (isCopyable!T) { return arr; } else { static assert(false, "TODO support forwarding of uncopyable elements"); } } be extended to support uncopyable element types

Re: Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:00:04 UTC, Nordlöw wrote: How can ... be extended to support uncopyable element types? That is, when `T` is uncopyable.

Re: Forwarding Uncopyable Static Array Elements

2017-09-17 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 17 September 2017 at 13:00:04 UTC, Nordlöw wrote: How can T[n] asStatic(T, size_t n)(T[n] arr) { import std.traits : isCopyable; static if (isCopyable!T) { return arr; } else { static assert(false, "TODO support forwarding of uncopyable element

Re: Binary serialization of a struct

2017-09-18 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of all the rest(including recursive structures, arrays, etc) then deser

Choosing between __traits(compiles, { ... } ) and is(typeof( { ... } ))

2017-09-20 Thread Nordlöw via Digitalmars-d-learn
When is __traits(compiles, { ... } ) preferred over is(typeof( { ... } )) and vice versa when writing stuff like enum isCopyable(S) = is(typeof( { S foo = S.init; S copy = foo; } )); ? Further, are there cases where the two idioms aren't exchangable?

Re: Choosing between __traits(compiles, { ... } ) and is(typeof( { ... } ))

2017-09-20 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 12:20:18 UTC, Stefan Koch wrote: Yes there are. Prefer __traits(compiles) it includes stricter visibility checks then is() does. 1. Can you give example of such visibility checks? 2. If so, should `isCopyable` (along with more defs in std.traits) be convert

Cannot make LDC use LTO when called via DUB

2017-09-23 Thread Nordlöw via Digitalmars-d-learn
I've added buildType "release" { buildOptions "releaseMode" "optimize" "inline" dflags-posix-ldc "-flto=thin" "-Xcc=-fuse-ld=gold" } to my dub.sdl and built (on Linux) as /usr/bin/dub -v run --compiler=ldc2 --build=release but neither the flag "-flto=thin" nor "-Xcc=-fuse

Re: Cannot make LDC use LTO when called via DUB

2017-09-23 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 23 September 2017 at 15:19:09 UTC, Nordlöw wrote: I've added buildType "release" { buildOptions "releaseMode" "optimize" "inline" dflags-posix-ldc "-flto=thin" "-Xcc=-fuse-ld=gold" } to my dub.sdl and built (on Linux) as /usr/bin/dub -v run --compiler=ldc2 --

Re: Cannot make LDC use LTO when called via DUB

2017-09-25 Thread Nordlöw via Digitalmars-d-learn
On Monday, 25 September 2017 at 07:47:28 UTC, Sebastiaan Koppe wrote: Maybe you are looking for dflags "..." platform="..." Ahh, you're right. Thanks!

Inter-module symbol resolution error of template type-parameter when using mixins

2017-09-27 Thread Nordlöw via Digitalmars-d-learn
At https://github.com/nordlow/phobos-next/blob/03b4736fdd65ef84c6fc583eddee4196629cea81/src/variant_arrays.d I've implemented a lightweight-polymorphic array container I call `VariantArrays(Types...)` indexed by a corresponding polymorphic index I call `VariantIndex(Types...)`. It uses `.man

Re: Inter-module symbol resolution error of template type-parameter when using mixins

2017-09-28 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 18:24:04 UTC, Nordlöw wrote: At ... Thanks Adam for your advice at https://stackoverflow.com/questions/46454887/inter-module-symbol-resolution-error-of-template-type-parameter-when-using-mixin?noredirect=1#comment79867792_46454887 I made things work in this

When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Nordlöw via Digitalmars-d-learn
Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should be defined to enable foreach (isIterable).

Static introspection of suitable hash function depending on type of hash key

2017-10-02 Thread Nordlöw via Digitalmars-d-learn
Does anyone have any good reads on the subject of statically choosing suitable hash-functions depending on the type (and in turn size) of the key? I wonder because I'm currently experimenting with a hash set implementation at https://github.com/nordlow/phobos-next/blob/40e2973b74d58470a13a5a

@nogc formattedWrite

2017-10-07 Thread Nordlöw via Digitalmars-d-learn
Is it currently possible to somehow do @nogc formatted output to string? I'm currently using my `pure @nogc nothrow` array-container `CopyableArray` as @safe pure /*TODO nothrow @nogc*/ unittest { import std.format : formattedWrite; const x = "42"; alias A = CopyableArray!(char);

Array/range-version of emplace

2017-10-10 Thread Nordlöw via Digitalmars-d-learn
Why isn't there an array/range version of `emplace`, when there is one for `moveEmplace`, namely https://dlang.org/library/std/algorithm/mutation/move_emplace_all.html ?

Dustmite always reduced to empty set after two iterations

2017-10-11 Thread Nordlöw via Digitalmars-d-learn
Once again I need to pick up Dustmite to track down a DMD and LDC ICE in release mode for my project. But I can't figure out how call Dustmite correctly: When I build https://github.com/nordlow/phobos-next as /usr/bin/dub build --compiler=dmd --build=release it prints Performing "rel

Re: Array/range-version of emplace

2017-10-13 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 19:00:59 UTC, Nordlöw wrote: Why isn't there an array/range version of `emplace`, when there is one for `moveEmplace`, namely Ping!

Splitting a sequence using a binary predicate on adjacent elements

2017-10-17 Thread Nordlöw via Digitalmars-d-learn
I can't find any algorithm/range in Phobos that can be used to split (eagerly or lazily) a sequence using a binary predicate on adjacent elements as follows [1,2,3,5,10,11,12,13,20,21,100].splitBy!"a + 1 != b"() should evaluate to [[1,2,3], [5], [10,11,12,13], [20,21], [100]] . Is there one

Re: Splitting a sequence using a binary predicate on adjacent elements

2017-10-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 13:09:18 UTC, Nordlöw wrote: Is there one? If not, what should we call it?...yet another overload of `splitter()` with a binary predicate and only a single parameter `Range input`?

Re: Splitting a sequence using a binary predicate on adjacent elements

2017-10-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 15:47:25 UTC, Andrea Fontana wrote: More phobos-ized version: https://run.dlang.io/is/iwgeAl Thanks!

Re: Splitting a sequence using a binary predicate on adjacent elements

2017-10-17 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 14:15:02 UTC, Andrea Fontana wrote: auto splitBy(alias F, R)(R range) Because of lazyness shouldn't it be named something with splitter, say splitterBy, instead?

Re: Splitting a sequence using a binary predicate on adjacent elements

2017-10-18 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 07:01:19 UTC, Andrea Fontana wrote: If you try to use your data with chunkBy!"a != b+1", it does not work, as expected. What's the motivation behind this limitation? Without it chunkBy!"a + 1 == b" is exactly what I want.

Re: Making template instantiations more lazy

2017-10-18 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 09:32:39 UTC, Jonathan M Davis wrote: On Wednesday, October 18, 2017 09:13:47 Per Nordlöw via Digitalmars-d-learn wrote: Are there any nearby plans to make more template instantiations (especially aggregate members) lazy in DMD? Are there any specific

Re: Skynet 1M Fiber microbenchmark in D

2017-10-18 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 11:04:10 UTC, Biotronic wrote: On Wednesday, 18 October 2017 at 11:01:56 UTC, Per Nordlöw wrote: On Wednesday, 18 October 2017 at 09:01:30 UTC, Per Nordlöw wrote: Creates an actor (goroutine, whatever), which spawns 10 new actors, each of them spawns 10 more act

Re: Skynet 1M Fiber microbenchmark in D

2017-10-18 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 11:52:08 UTC, Biotronic wrote: It seems to make very little difference in terms of run time, though. I tried using a mix of these approaches - parallel at low depth, basically just to fill up the cores, and serial closer to the leaves. The difference is still ne

Re: Making template instantiations more lazy

2017-10-18 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 18 October 2017 at 11:18:31 UTC, Biotronic wrote: I'm not actually sure why D behaves this way - C++ doesn't. I guess there is some value as tests - instantiating the type tests that all its methods compile. Not actually sure that's more of a positive than a negative, but it's cer

Role of third argument to GC.addRange

2017-10-27 Thread Nordlöw via Digitalmars-d-learn
The docs for the third argument to https://dlang.org/library/core/memory/gc.add_range.html says: "The GC might use this information to improve scanning for pointers or to call finalizers." Can somebody elaborate a bit on what "improve scanning" means here?

Associative arrays with keys containing mutable indirections

2017-10-29 Thread Nordlöw via Digitalmars-d-learn
Shouldn't associative arrays with key types (K) having mutable indirections (std.traits.hasAliasing!K) such as string[ubyte[]] be disallowed? If not, in what cases do we want this?

Keyword scope as qualifier on destructors

2017-11-06 Thread Nordlöw via Digitalmars-d-learn
What effect does `scope`-qualification have for destructors such as ~this() @trusted scope; used here https://github.com/dlang/dmd/pull/7284/files#diff-da63c10313833b6da044c7e5e3a85c03R67 ?

LDC Intrinsics

2017-11-10 Thread Nordlöw via Digitalmars-d-learn
What kinds of intrinsics are explicitly available to the developer when compiling with LDC? And are there any docs?

Class allocators

2017-11-11 Thread Nordlöw via Digitalmars-d-learn
Have anybody used allocators to construct class instances?

Automatic insertion of D-style multiline-comments in Emacs

2017-11-12 Thread Nordlöw via Digitalmars-d-learn
Have anybody added logic to Emacs' `comment-dwim` that automagically inserts a (Ddoc-style) multi-line comment like /** ... */ void foo { } if the cursor is currently in front of a (function) definition (or declaration)? I realize that the challenge here is context detection; perhaps `begi

Re: Automatic insertion of D-style multiline-comments in Emacs

2017-11-12 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 12 November 2017 at 12:52:48 UTC, Nordlöw wrote: Have anybody added logic to Emacs' `comment-dwim` that automagically inserts a (Ddoc-style) multi-line comment like Posted also here: https://stackoverflow.com/questions/47249052/automatic-insertion-of-multiline-declaration-comments

Re: Class allocators

2017-11-12 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 12 November 2017 at 20:41:03 UTC, Basile B. wrote: No, the classes and structs of the examples are simply declared as 'static' because they are located in a 'unittest' block. You can ignore the keyword...it just means that they are declared as if they would stand at the global scope.

Inference of GC allocation scope

2017-11-16 Thread Nordlöw via Digitalmars-d-learn
Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour?

Re: Inference of GC allocation scope

2017-11-16 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 16 November 2017 at 17:39:02 UTC, Petar Kirov [ZombineDev] wrote: https://github.com/ldc-developers/ldc/blob/master/gen/passes/GarbageCollect2Stack.cpp Does this include GC allocations that don't fit on stack?

Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of `Isolated` to an existing such worker task via some low-latency (non-l

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated Further, what does "weakly isolated" mean here http://vibed.org/api/vibe.core.core/runWorkerTask ?

Re: Communicating between vibe.d's worker tasks

2017-11-23 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 23 November 2017 at 10:15:26 UTC, Nordlöw wrote: I'm looking at http://vibed.org/api/vibe.core.concurrency/makeIsolated which is a great idea for safe inter-thread communication. Are there any more usage examples for vibe's worker tasks that show how to send instances of `Isolate

No line numbers in stack trace (again)

2017-12-05 Thread Nordlöw via Digitalmars-d-learn
If I get the following stack trace ___without line numbers___ (instead ??:?) what's missing? core.exception.AssertError@src/knet/linking.d(444): Assertion failure ??:? _d_assertp [0x5092ab19] ??:? pure @safe knet.storage.Edge knet.linking.dlink!(knet.storage.ZingOf!(knet.stor

Tail-constness of class parameters

2017-12-25 Thread Nordlöw via Digitalmars-d-learn
In a graph library I'm working on I have the following algorithm bool hasContext(Node sub,// TODO in Node sup) nothrow // TODO in { Node curr = sub; while (true) { Node ctx = curr.context; if (!ctx) { break;} if (ctx is sup) retu

Re: Tail-constness of class parameters

2017-12-25 Thread Nordlöw via Digitalmars-d-learn
On Monday, 25 December 2017 at 15:16:55 UTC, ag0aep6g wrote: https://dlang.org/phobos/std_typecons.html#Rebindable Thanks.

Upcasting slice of class elements

2018-01-05 Thread Nordlöw via Digitalmars-d-learn
Why isn't class X {} class Y : X {} X[] xs = cast(X[])(Y[].init); compilable in safe D? What's unsafe about such a cast?

Checking @nogc-ness of an Allocator.allocate()

2018-01-11 Thread Nordlöw via Digitalmars-d-learn
How do I check whether an aggregate member function (call for a specific argument) is @nogc or not? I want to check whether Allocator.allocate(1) (for a any Allocator) is @nogc or not? Is https://dlang.org/phobos/std_traits.html#hasFunctionAttributes the way to do it?

calloc for std.experimental.allocator

2018-01-11 Thread Nordlöw via Digitalmars-d-learn
Is there no equivalent of `calloc()` for `std.experimental.allocator`, something like Allocator.zeroAllocate(size_t numberOfElements) ?

Re: calloc for std.experimental.allocator

2018-01-12 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 11 January 2018 at 21:57:28 UTC, MrSmith wrote: http://dpldocs.info/experimental-docs/std.experimental.allocator.makeArray.4.html Thanks!

Range over a container r-value with disabled postblit

2018-01-13 Thread Nordlöw via Digitalmars-d-learn
Given my combined hashmap and hashset container `HashMapOrSet` defined at https://github.com/nordlow/phobos-next/blob/master/src/hashmap_or_hashset.d with deterministic memory management and disabled copy constructions and a member byElement() defined as @property auto byElement()()

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 14 January 2018 at 14:04:46 UTC, kinke wrote: That sounds reasonable. For something like `foreach (e; makeRange().wrapRangeByRef())`, referencing the makeRange() struct rvalue by pointer in the wrapped range won't work, as the underlying range lifetime ends with the foreach range ex

Re: Range over a container r-value with disabled postblit

2018-01-14 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 14 January 2018 at 21:57:37 UTC, Nordlöw wrote: Note that __trait(isLvalue, this) cannot be used to detect whether `this` is an l-value or an r-value, which I find strange. Shall be __traits(isRef, this)

Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Nordlöw via Digitalmars-d-learn
Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a temp

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Nordlöw via Digitalmars-d-learn
On Monday, 15 January 2018 at 15:27:23 UTC, Meta wrote: void main() { auto arr = [1, 2, 3]; arr.remove!(_ => _ == 1); writeln(arr); } Or was that code meant as an example? The problem occurs when the templated function is a member of the struct `arr`. I've moved the algorithm into

@safe matching on subclass type

2018-01-17 Thread Nordlöw via Digitalmars-d-learn
Why isn't polymorphic down-casts such as in the following pattern matching on sub-class class Base {} class Sub : Base {} @safe unittest { auto base = new Base(); if (auto sub = cast(Sub)base) { // use sub } } allowed in safe D?

Re: @safe matching on subclass type

2018-01-17 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 17 January 2018 at 13:19:42 UTC, Nordlöw wrote: Why isn't polymorphic down-casts such as in the following pattern matching on sub-class class Base {} class Sub : Base {} @safe unittest { auto base = new Base(); if (auto sub = cast(Sub)base) { // use sub }

Class instance memory overhead lower than 3 words?

2018-01-24 Thread Nordlöw via Digitalmars-d-learn
Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit systems? I find that annoyingly much for my knowledge database application. I'm aware of extern(C++), having one word overhead, but such extern(C++)-classes cannot use all of D; I get compilation errors such

Re: Class instance memory overhead lower than 3 words?

2018-01-24 Thread Nordlöw via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 21:47:26 UTC, H. S. Teoh wrote: On Wed, Jan 24, 2018 at 09:48:21PM +, Nordlöw via Digitalmars-d-learn wrote: Why is the memory overhead for a class instance as high as 3 words (24 bytes on 64-bit systems? I find that annoyingly much for my knowledge

Faking a non-pure function as pure

2018-02-16 Thread Nordlöw via Digitalmars-d-learn
I'm struggling with my definition of assumePure that should make a non-pure function `f` callable as pure `pureF`. I've copied the definition of assumePure from the Phobos docs at https://dlang.org/phobos/std_traits.html#SetFunctionAttributes and managed to define pureF using it but I cannot c

Re: Cannot make my shared PureMallocator callable in pure functions

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 17 February 2018 at 12:33:25 UTC, Nordlöw wrote: PureMallocator.instance.allocate(16); currently errors as pure_mallocator.d(84,16): Error: pure function 'pure_mallocator.__unittest_pure_mallocator_82_0' cannot access mutable static data 'instance'

Cannot make my shared PureMallocator callable in pure functions

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
I'm struggling with making https://github.com/nordlow/phobos-next/blob/master/src/pure_mallocator.d callable in pure functions such as here https://github.com/nordlow/phobos-next/blob/master/src/pure_mallocator.d#L84 Shouldn't a shared static shared PureMallocator instance; make it possi

Re: Cannot make my shared PureMallocator callable in pure functions

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 17 February 2018 at 12:35:00 UTC, rikki cattermole wrote: in pure functions? pure means no globals. As in none :) I don't understand. I thought std.experimental.allocators API was designed to be able express these needs, @andralex?

Re: Cannot make my shared PureMallocator callable in pure functions

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 17 February 2018 at 12:35:00 UTC, rikki cattermole wrote: in pure functions? pure means no globals. As in none :) I guess one solution is to make the member functions in PureMallocator static and change how the template argument `Allocator` for a container is used to call these

Re: Faking a non-pure function as pure

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
On Friday, 16 February 2018 at 18:03:40 UTC, Ali Çehreli wrote: auto pureF = assumePure(&f); pureF(42); Ali Thanks!

Re: Cannot make my shared PureMallocator callable in pure functions

2018-02-17 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 17 February 2018 at 14:54:37 UTC, ag0aep6g wrote: Nordlöw's methods are only weakly pure. They have mutable indirections either in the return type or in a parameter type. So calls to them should not be optimized away. I found a solution at https://github.com/nordlow/phobos-next/b

Size threshold replace complex probing with linear search for small hash tables

2018-02-19 Thread Nordlöw via Digitalmars-d-learn
I'm currently developing a combined HashMap and HashSet with open addressing at https://github.com/nordlow/phobos-next/blob/master/src/open_hashmap_or_hashset.d with probing using steps of triangular numbers when length is a power of two at https://github.com/nordlow/phobos-next/blob/master/

Validity of cast(void*)size_t.max

2018-02-27 Thread Nordlöw via Digitalmars-d-learn
Is `cast(void*)size_t.max` always an invalid address? Is so, could it be used to indicate removed/delete elements in hash tables with open addressing and a key type being either a pointer or class? And will it work correctly with the GC?

  1   2   3   4   5   6   7   8   9   >