Re: Problem with object understanding and datatypes

2013-06-23 Thread Nordlöw
Is this code available in any repo/archive somewhere? /Per

Reflections on Serialization APIs in D

2013-11-17 Thread Nordlöw
In the road to develop a new kind of search engine that caches types, statistics, etc about files and directories I'm currently trying to implement persistent caching of my internal directory tree using `msgpack-d`: Why doesn't `msgpack-d` and, from what I can see also, `std.serialization`

Accessing a Hash table as a Value-Sorted Range

2013-11-19 Thread Nordlöw
If I have a hash-table `File[string] _subs` and want to access its values in a sorted way is there a better than simply through auto ssubs = new File[_subs.length]; // preallocate sorted subs size_t ix = 0; foreach (sub; _subs) { ssubs[ix++] = sub; // set new reference

Re: Accessing a Hash table as a Value-Sorted Range

2013-11-19 Thread Nordlöw
On Tuesday, 19 November 2013 at 21:14:01 UTC, Brad Anderson wrote: On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote: If I have a hash-table `File[string] _subs` and want to access its values in a sorted way is there a better than simply through auto ssubs = new File

Re: Accessing a Hash table as a Value-Sorted Range

2013-11-19 Thread Nordlöw
On Tuesday, 19 November 2013 at 22:42:10 UTC, Nordlöw wrote: On Tuesday, 19 November 2013 at 21:14:01 UTC, Brad Anderson wrote: On Tuesday, 19 November 2013 at 21:11:42 UTC, Nordlöw wrote: If I have a hash-table `File[string] _subs` and want to access its values in a sorted way

Calling a C Function with C-style Strings

2013-11-30 Thread Nordlöw
I'm struggling to call mktemp in D: import core.sys.posix.stdlib; import std.string: toStringz; auto name = alpha; auto tmp = mktemp(name.toStringz); but I can't figure out how to use it so DMD complains: /home/per/Work/justd/fs.d(1042): Error: function

Stream-Based Processing of Range Chunks in D

2013-12-10 Thread Nordlöw
I'm looking for an elegant way to perform chunk-stream-based processing of arrays/ranges. I'm building a file indexing/search engine in D that calculates various kinds of statistics on files such as histograms and SHA1-digests. I want these calculations to be performed in a single pass with

Demangling D Symbols when Profiling D Programs with perf

2013-12-13 Thread Nordlöw
I've just discovered the fantastic tool perf on Linux. I profiled a D program with this but when I call perf report the symbols are not demangled. I'm aware of `ddemangle` but this only works in batch-processing mode. I could always dump the output to a file for viewing. But it would be

Forward Difference Algorithm

2014-01-08 Thread Nordlöw
Is/Are there a function(s) in `std.algorithm` or `std.range` with which to lazily compute a forward difference? I need this to differentially pack sorted elements (integers) in a range. The integers happen to be `SysTime` timestamps.

Re: Forward Difference Algorithm

2014-01-08 Thread Nordlöw
On Wednesday, 8 January 2014 at 19:40:34 UTC, Nordlöw wrote: Is/Are there a function(s) in `std.algorithm` or `std.range` with which to lazily compute a forward difference? I need this to differentially pack sorted elements (integers) in a range. The integers happen to be `SysTime` timestamps

Value or Reference Semantics Trait

2014-01-12 Thread Nordlöw
Is there a trait to check whether a type has value or reference semantics? I need this in a template struct that adaptively (using static if) represent histogram bins as either a dense static array or a sparse associative array.

In-Place Ordering of Elements

2014-01-13 Thread Nordlöw
Does Phobos have some variadic algorithm to order l-value reference arguments in place? Something like int a=3; int b=2; int c=1; orderInPlace(a,b,c); // a is now 1 // b is now 2 // c is now 3 Also a functional variant, say `order(a, b, c)`, that returns a tuple

DMD linking fails because of missing _adCmp2 and _adEq2

2014-01-19 Thread Nordlöw
I regularly rebuild and use DMD git master locally on Ubuntu 13.10. Yesterday my toolchain dmd fails to link all D programs with the error: Example compilation output from dmd

Generic Span/Limits/MinMax Type

2014-01-20 Thread Nordlöw
Has anyone cooked up a generic D struct that groups together min and max values of a type and default-initializes them in the correct way? Something like struct Limits(T) { /* TODO: Fix purity of this by fixing Bytes.value() */ auto init() @trusted /* pure */ nothrow

Re: Manipulating Bits of Any Value Type

2014-01-26 Thread Nordlöw
On Sunday, 26 January 2014 at 23:27:58 UTC, Stanislav Blinov wrote: On Sunday, 26 January 2014 at 20:56:29 UTC, Nordlöw wrote: My idea to make `getBit` work on all types that have value semantics. All of them? Arbitrary structs too? floating point types? Static arrays? Might I ask... why do

Getting NotNull Right

2014-02-05 Thread Nordlöw
Hi! I've changed Adam D Ruppes module notnull.d a bit to allow assignment of a NotNull inherited class instance to a NotNull base class using /** Assignment from $(D NotNull) Inherited Class $(D rhs) to $(D NotNull) Base Class $(D this). */ typeof(this)

Re: Getting NotNull Right

2014-02-05 Thread Nordlöw
On Wednesday, 5 February 2014 at 22:13:00 UTC, Adam D. Ruppe wrote: On Wednesday, 5 February 2014 at 21:58:08 UTC, Nordlöw wrote: Members of a derived class T become inaccessible in NotNull!T with this approach. Do you have any clue to why? aaah, of course, now alias this returns the base

Higher Order Type Tuple Predicate

2014-02-13 Thread Nordlöw
Is there some trait in Phobos to check if each element of a type tuple fulfil a type predicate? I want this in a variadic function limiter to assert that all its arguments function fulfils a predicate. Something like: void f(T...)(T args) if (All!(T,SomePredicate)) { ... }

Range Construction Pattern

2014-02-22 Thread Nordlöw
Assumed I have the following code SysTime[] times; const n = 3; foreach (i; 0..n) times ~= Clock.currTime; is there a simpler, perhaps functional, higher order pattern with which to achieve the same goal?

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
On Saturday, 22 February 2014 at 12:40:42 UTC, Tobias Pankrath wrote: On Saturday, 22 February 2014 at 12:29:11 UTC, Nordlöw wrote: Assumed I have the following code SysTime[] times; const n = 3; foreach (i; 0..n) times ~= Clock.currTime; is there a simpler, perhaps functional

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
times = iota(3).map!(x = Clock.currTime).array; -- Ok here's my try so far: auto create(alias fun)(size_t n) { import std.range: iota, map; return n.iota.map!(n = fun); } Now what remains is to retstrict create to only take a fun with *no* input arguments and a non-void return. How

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
On Saturday, 22 February 2014 at 14:03:11 UTC, Philippe Sigaud wrote: Now what remains is to retstrict create to only take a fun with *no* input arguments and a non-void return. How do I do that? With a template contraint. Not tested: import std.traits: isCallable, ParameterTypeTuple,

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
My try so far: import std.traits: isCallable, ReturnType, arity, ParameterTypeTuple; enum arityMin0(alias fun) = __traits(compiles, fun()); // new syntax in 2.064 auto repeat(alias fun)(size_t n) if (isCallable!fun arityMin0!fun

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
btw, I'd call this template 'apply', because repeat already exists in Phobos with a different use. Good idea! I'll rename it. I have a pile of extensions to std.algorithm, std.traits, std.numeric, I'll pull some day when I get the time... /Per

Scalability in std.parallelism

2014-02-22 Thread Nordlöw
In the following test code given below of std.parallelism I get some interesting results: when compiled as dmd -release -noboundscheck -O -inline -w -wi -wi ~/Work/justd/t_parallelism.d -oft_parallelism My scalability measures says the following 3.14159 took 221[ms] 3.14159 took 727[ms]

Re: Range Construction Pattern

2014-02-22 Thread Nordlöw
I have a pile of extensions to std.algorithm, std.traits, std.numeric, I'll pull some day when I get the time... I mean push...

Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Nordlöw
Is it possible void construct a dynamic array such as b in int n = 3; auto b = new float[n]; similar to what we do with static arrays as in int[3] c = void;

Re: Non-Initialized Dynamic Arrays Construction

2014-02-24 Thread Nordlöw
On Monday, 24 February 2014 at 11:29:39 UTC, bearophile wrote: TheFlyingFiddle: http://dlang.org/phobos/std_array.html#.uninitializedArray is what you want. Wouldn't it be nice to have some kind of syntactic sugar for this similar to what we have for static arrays? BTW: Why isn't simply

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
On Thursday, 27 February 2014 at 23:38:34 UTC, Nordlöw wrote: Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm trying to figure out how to implement automatic detection of unused return values from calls to strictly pure

DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm trying to figure out how to implement automatic detection of unused return values from calls to strictly pure functions. The closest I have come is the function

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
https://d.puremagic.com/issues/show_bug.cgi?id=3882 Bye, bearophile Did you set this as WONTFIX because of too many warnings from functions that may throw or just do asserts such as unittests? If so does anyone see any way to restrict warnings even further for example by checking if a

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-28 Thread Nordlöw
I believe I found a good solution to Issue 3882: https://d.puremagic.com/issues/show_bug.cgi?id=3882 It works as expected and I found two bugs in my code with it. My current solution is to add the following at line 147 in dmd/src/sideeffect.c: case TOKcall: /* Issue 3882:

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-28 Thread Nordlöw
On Friday, 28 February 2014 at 10:40:04 UTC, bearophile wrote: Nordlöw: Did you set this as WONTFIX because of too many warnings from functions that may throw or just do asserts such as unittests? It's a RESOLVED LATER. I think it was not me to tag it like that. And it was tagged like

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-28 Thread Nordlöw
that. And it was tagged like that because of too many warnings in templated functions. Were those warnings emitted also by non-void return functions? /Per

Type-Safer Modern High-Level Performant OpenGL

2014-03-06 Thread Nordlöw
Does anybody have some sample code (example or project) lying around that shows modern use of OpenGL (3 or 4) using some or all of the following libraries: - DerelictGL3 (Org) - DerelictGLFW3 (Org) - Glamour - gl3n I'm planning a graph visualization engine in D and I would like to use as

Re: Type-Safer Modern High-Level Performant OpenGL

2014-03-06 Thread Nordlöw
GFM (my own, PLEASE, PLEASE CHOOSE ME) From what I've seen so far I like the structure of GFM the most :) On thing though...why did you choose SDL2 of GLFW3?

Re: Type-Safer Modern High-Level Performant OpenGL

2014-03-06 Thread Nordlöw
On thing though...why did you choose SDL2 of GLFW3? I of course mean SDL2 *over* GLFW3.

Re: Type-Safer Modern High-Level Performant OpenGL

2014-03-06 Thread Nordlöw
GFM (my own, PLEASE, PLEASE CHOOSE ME) I'm trying to build your package using dub but I get the error θ61° [per:~/justd/gfm] master ± dub Error executing command run: Main package must have a binary target type, not none. Cannot build. I'm using a recent build of dub from git master.

Hacking DMD to Query Context Information at Source File Offset

2014-03-08 Thread Nordlöw
Where should I put logic-and-printfs in DMD to show lexical, syntactic and semantic information about a symbol and/or expression at given position in the source file being parsed. I'm guessing for some iteration in the lexical, syntactic and semantic passes respectively where I need to check

Explicit Declaration of Pureness and Throwness of Higher Order Ranges

2014-03-10 Thread Nordlöw
Is it, in D today, possible to explicitly tag higher order ranges such as for example `map` with their pureness, safeness and throwness based on the corresponding properties on their function arguments such as `fun...`? And is this motivated? now that the D compiler deduce these properties

Re: Explicit Declaration of Pureness and Throwness of Higher Order Ranges

2014-03-10 Thread Nordlöw
I'm not quite sure what you're asking. You either mark a function as @safe, pure, and/or nothrow - or you don't, in which case, if it's a templated function, the attributes are inferred to the best of the compiler's capabilities, and if it's not, then the function doesn't have those

GDC/LDC on Sparc Solaris

2014-03-18 Thread Nordlöw
Does GDC and/or LDC have sparc solaris backend support? I'm trying to make my company use D and we have a bunch of legacy machines that unfortunately run on sparc-solaris 2.10. /Per

Ada-Style Range Types with Value Range Propagation in Arithmetic

2014-03-19 Thread Nordlöw
I'm trying to extend my wrapper class Bound to support CTFE Value Range Propagation in primary in opUnary and opBinary similar to what Ada's Range Types. My current try so far for binary arithmetic is auto opBinary(string op, U, U lower_rhs = U.min, U

Re: Ada-Style Range Types with Value Range Propagation in Arithmetic

2014-03-19 Thread Nordlöw
Ideas anyone? I cracked it: auto opBinary(string op, U, string file = __FILE__, int line = __LINE__)(U rhs) { static if (is(U == Bound)) { alias C = CommonType!(T, U.type); Bound!(C,

Syntactic Sugar for Construction of Empty Dynamic Arrays of a Given Type

2014-03-23 Thread Nordlöw
Is there a convenicene function for assigning an empty dynamic array of a given type to a variable? cast(int[])[]; I'm using this in ForwardDifference constructor: auto forwardDifference(R)(R r) if (isInputRange!R) { import std.range: front, empty, popFront, dropOne; struct

Re: Syntactic Sugar for Construction of Empty Dynamic Arrays of a Given Type

2014-03-23 Thread Nordlöw
On Sunday, 23 March 2014 at 14:58:53 UTC, bearophile wrote: Nordlöw: Is there a convenicene function for assigning an empty dynamic array of a given type to a variable? cast(int[])[]; _range = cast(D[])[]; If the variable is already typed, you can use [] otherwise

Re: Syntactic Sugar for Construction of Empty Dynamic Arrays of a Given Type

2014-03-23 Thread Nordlöw
Ok. Enough for now...but Is there a way to avoid this array special handling: static if (isArray!R) _range = (D[]).init; else _range = R(); // return empty range through some initializer expression for _range that covers

Re: GDC/LDC on Sparc Solaris

2014-03-24 Thread Nordlöw
On Sunday, 23 March 2014 at 22:00:23 UTC, andro wrote: On Tuesday, 18 March 2014 at 23:52:49 UTC, Nordlöw wrote: Does GDC and/or LDC have sparc solaris backend support? I'm trying to make my company use D and we have a bunch of legacy machines that unfortunately run on sparc-solaris 2.10

Avoiding Range Checks in Slice Expressions

2014-03-30 Thread Nordlöw
Does DMD currently avoid range checks in array slice expressions such as f(x[0..$/2]) f(x[$/2..$]) typically found in divide-and-conquer algorithms such as quicksort? If not, what would it require to implement it?

Re: Avoiding Range Checks in Slice Expressions

2014-03-31 Thread Nordlöw
If they are range-checked, it would be a good addition to the optimizer to remove them. My guess is that it is range-checked. $/n is of course always within range if n is positive integer = 1. But what about in the general indexing/slicing case? In that case it would be useful if we could

Re: Avoiding Range Checks in Slice Expressions

2014-03-31 Thread Nordlöw
If not, what would it require to implement it? That would be an interesting task to fix :) DMD source references anyone?

Trying Multiple Aggregate reduce

2014-03-31 Thread Nordlöw
I'm trying to figure out how to use reduce with multiply funs. Here's my try on minmaxElement: import std.typecons: tuple; /** Returns: Tuple of Minmum and Maximum Element in X. */ auto minmaxElement(alias F = min, alias G = max, R)(in R range) @safe pure nothrow if (isInputRange!R) {

Re: Trying Multiple Aggregate reduce

2014-03-31 Thread Nordlöw
You can't use reduce with a const seed. This, surely, must be a compiler bug right? /Per

Re: Trying Multiple Aggregate reduce

2014-04-02 Thread Nordlöw
so happens to support this. So I added your code to the test cases: Great! BTW: Why is static qualifier needed on definition of minmaxElement() in the unittest?

Query Context at Source File and Offset in DMD

2014-04-05 Thread Nordlöw
I'm working on a feature in DMD to query lexical, syntactic and semantic context at a given byte offset in a given source file. In the long run my vision is to add libclang-like functionality directly into DMD and a specific mode in DMD that just starts up DMD to query some information at a

Re: Query Context at Source File and Offset in DMD

2014-04-06 Thread Nordlöw
The Lexer's constructor takes a Module as the first parameter [1]. A Module has the original argument name [2], I assume that's the filename. Just store the module/filename as an instance variable in the lexer and access it where you need it. [1]

DMD Source Hot Spot for Expression Type Deduction

2014-04-08 Thread Nordlöw
I'm looking for hot spots in the DMD source where deduction of types of expressions are performed. I want to use this to extract information about the type of an expression before/after point. Is this logic spread all over .*Exp::semantic .*Exp::semantic2 .*Exp::semantic3 or is there a hot

Continued: DMD Source Hot Spot for Expression Type Deduction

2014-04-08 Thread Nordlöw
So far I figured that what I typically want to do is printf(Type: %s, e-type-toChars()); whenever I find a type-deduced expression e that fulfils (e-loc-linnum == QUERY_LINE e-loc-charnum = QUERY_COLUMN QUERY_COLUMN (e-loc-charnum + e-length_of_expression_in_code)) Can I

Re: Continued: DMD Source Hot Spot for Expression Type Deduction

2014-04-08 Thread Nordlöw
I just realized that maybe the best way is to recurse down the AST until I find node(s) whose token range cover my query point right?

Multi-Type Enumerations

2014-04-15 Thread Nordlöw
Could somebody, please, give me some enlightening examples of when it can be useful to have a enumerators with different types such as in enum { A = 1.2f, // A is 1.2f of type float B, // B is 2.2f of type float int C = 3, // C is 3 of type int D // D is 4 of type int

On Concurrency

2014-04-18 Thread Nordlöw
Could someone please give some references to thorough explainings on these latest concurrency mechanisms - Go: Goroutines - Coroutines (Boost): - https://en.wikipedia.org/wiki/Coroutine - http://www.boost.org/doc/libs/1_55_0/libs/coroutine/doc/html/coroutine/intro.html - D:

Re: On Concurrency

2014-04-18 Thread Nordlöw
Correction: The references I gave _are_ theoretically thorough, so I'm satisified with these for now. I'm however still interested in the D-specific questions I asked.

Reading ELF Files

2014-05-01 Thread Nordlöw
Have anybody put together some D code for reading out tables from ELF files? A range/slice based version would be nice.

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
I have some simple proof of concept code. It is currently able to read elf64 (can be easily adjusted to read elf32 too) headers, extract sections and read string tables. If this is what you need, then I'll upload my code somewhere (although again, it is quite simplistic). If you specify what

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
again, it is quite simplistic). If you specify what you need a bit more, I might be able to provide that. Please, post :)

Re: Reading ELF Files

2014-05-01 Thread Nordlöw
Here you go, https://github.com/yazd/elf-d. Thanks!

Making enum join variadic

2014-05-01 Thread Nordlöw
How can I make `join` variadic (by filling in njoin) in the following code? import std.stdio: writeln; import std.traits; string enumsHelper(S...)(S s) { typeof(return) r; foreach (i, e; s) { if (i = 1) r ~= , ; r ~= e; } return r; } /**

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
artur Thx! Here's my final version that compiles and run: import std.stdio: writeln; import traits_ex: isEnum; import std.typetuple: allSatisfy; /** Join/Chain/Concatenate/Unite Enums $(D E1), $(D E2), ... into $(D E). See also:

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
Its up: https://github.com/nordlow/justd/blob/master/enums.d

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
I'd be verbose. It's an uncommon operation, bound to surprise a reader a bit.It's better to type a few more letters. See update. I did not try to compile it, but what happens if the enum elements have the same name ? The same min/max/values ? Like this: enum E1 { a, b, c } alias E111 =

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
On Friday, 2 May 2014 at 12:45:44 UTC, Nordlöw wrote: I'd be verbose. It's an uncommon operation, bound to surprise a reader a bit.It's better to type a few more letters. See update. I did not try to compile it, but what happens if the enum elements have the same name ? The same min/max

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
On Friday, 2 May 2014 at 14:36:16 UTC, Meta wrote: On Friday, 2 May 2014 at 13:38:39 UTC, Nordlöw wrote: enums.d(25,46): Error: static variable allMembers cannot be read at compile time enums.d(25,21):while evaluating: static assert(a in allMembers) Is there a solution

Re: Making enum join variadic

2014-05-02 Thread Nordlöw
So that leaves me with using an array of bool and rank() then, I guess... Correction: I mean array of strings and find.

Re: Reading ELF Files

2014-05-02 Thread Nordlöw
On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote: On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote: Here you go, https://github.com/yazd/elf-d. Thanks! Anytime. By the way, if you need more stuff out of it or help, post an issue on github. I think I'll be able to help a bit more

Re: In need for CommonOriginalType

2014-05-02 Thread Nordlöw
is(CommonType!(OriginalType!T1, OriginalType!T2) ... ? I need it to be variadic. I cracked it: import std.typetuple: staticMap; import std.traits: CommonType, OriginalType; alias CommonOriginalType(T...) = CommonType!(staticMap!(OriginalType, T)); /per

Conversion and Assignment on EnumUnion and EnumChain

2014-05-03 Thread Nordlöw
I've put up a module https://github.com/nordlow/justd/blob/master/enums.d that provides two type constructors - EnumChain - EnumUnion that can be used to combine names or names-and-values from one or more enums. I would now like to define rules for assignments and implicit conversions

Re: Conversion and Assignment on EnumUnion and EnumChain

2014-05-04 Thread Nordlöw
I would now like to define rules for assignments and implicit conversions with the following checks I believe I found a good solution through struct wrappers. See update at: https://github.com/nordlow/justd/blob/master/enums.d

Template mixins has no effect

2014-05-04 Thread Nordlöw
I'm trying to improve https://github.com/nordlow/justd/blob/master/enums.d through use of template mixins http://dlang.org/template-mixin.html to improve EnumUnion as follows: struct EnumUnion(E...) { alias OriginalType = CommonOriginalType!E; alias U = UnionEnum!(E);// Wrapped

Re: Reading ELF Files

2014-05-04 Thread Nordlöw
On Sunday, 4 May 2014 at 18:11:45 UTC, yazd wrote: On Friday, 2 May 2014 at 15:25:55 UTC, Nordlöw wrote: On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote: On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote: Here you go, https://github.com/yazd/elf-d. Thanks! Anytime. By the way

Re: Template mixins has no effect

2014-05-04 Thread Nordlöw
What is wrong? For some reason the mixin declarations for op* are not imported into the calling scope when others are. Compiler bug?

Re: Reading ELF Files

2014-05-05 Thread Nordlöw
On Sunday, 4 May 2014 at 18:11:45 UTC, yazd wrote: On Friday, 2 May 2014 at 15:25:55 UTC, Nordlöw wrote: On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote: On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote: Here you go, https://github.com/yazd/elf-d. Thanks! Anytime. By the way

Re: Reading ELF Files

2014-05-05 Thread Nordlöw
On Monday, 5 May 2014 at 13:51:12 UTC, Mike Parker wrote: On 5/5/2014 8:17 PM, Nordlöw wrote: One thing though: You cannot call a filename the same as a keyword: package.d because import elf.package; fails with fs.d(144,12): Error: identifier expected following package Actually

Re: Is it possible to check if a type is an instance of a template?

2014-05-05 Thread Nordlöw
template IsAFoo(T) { static if (is(T t == Foo!U, U)) { enum IsAFoo = true; } else { enum IsAFoo = false; } } Can we make Foo a template parameters aswell, here? I tried this template IsA(T, K) { static if (is(T t == K!U, U)) { enum IsA = true; }

Re: Template mixins has no effect

2014-05-22 Thread Nordlöw
What is wrong? Ping, anybody?

Separate Piping of dmd stdout and stderr through ddemangle

2014-05-22 Thread Nordlöw
Is there a Bash way to pipe stdout and stderr *separately* through ddemangle? I'm aware of 21 but this removes separation of stdout and stderr.

@safe @nogc memory allocation

2014-05-28 Thread Nordlöw
I would like my radix sort function radixSortImpl() at https://github.com/nordlow/justd/blob/master/intsort.d to not use the GC. However, when I tag with @nogc I get the error: intsort.d(195,47): Error: @nogc function 'isort.radixSortImpl!(byte[], a, false).radixSortImpl' cannot call

Re: @safe @nogc memory allocation

2014-05-28 Thread Nordlöw
malloc? There's no wrapper around it though, like there is for uninitializedArray. Is the fact that malloc() can't be pure when new is a limitiation in the type system? Do we need a yet another code tag for this? /Per

Re: @safe @nogc memory allocation

2014-05-28 Thread Nordlöw
It is also because `malloc` can return null when out of memory and `new` will throw an Error. Wrapper around `malloc` that throws `OutOfMemoryError` on null can be considered of same purity class as `new`. Does this mean that I should write and use such a wrapper for malloc? /Per

On ref return in DMD

2014-06-03 Thread Nordlöw
The title More ref return fixes in std.datetime now that the compiler allows them of https://github.com/D-Programming-Language/phobos/pull/2227/files made me curious to what is meant by ref return. Is this a recent improvement in DMD?

Re: On ref return in DMD

2014-06-03 Thread Nordlöw
No. We've been able to return by ref for ages. However, when Thx

Don't Understand why Phobos Auto-Tester fails for PR #3606

2014-06-07 Thread Nordlöw
My recent https://github.com/D-Programming-Language/dmd/pull/3606 fails in all the Auto-Testers but I don't understand why. Running make unittest locally in phobos using my locally built branch of dmd passes all tests. Please help!

Re: Don't Understand why Phobos Auto-Tester fails for PR #3606

2014-06-08 Thread Nordlöw
I commented in github. Thx!

Re: findBack: find a needle in a haystack from the back

2014-06-09 Thread Nordlöw
using retro seems inefficient because of all the decodings Phobos git master just got support for next-gen string processing: https://github.com/D-Programming-Language/phobos/pull/2043 I believe x.byChar.retro is what you want

DMD Compiler Version Dependent Conditional Compilation

2014-06-09 Thread Nordlöw
Can I use the version keyword or static if to perform conditional compilation that depends on the version of DMD? I typicall something like version(= DMD_2.0.66) { // use new byChar, byWchar, byDchar, byCodepoint } else { // use old style slower version } If so how?

Re: DMD Compiler Version Dependent Conditional Compilation

2014-06-09 Thread Nordlöw
Thx

Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement pretty printing to multiple backends (currently testing HTML) using as much of D's compile time reflection as possible:

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
On Tuesday, 10 June 2014 at 16:13:31 UTC, Adam D. Ruppe wrote: Two options: do allMembers and filter it out to only be data members, or do some slicing of tupleof.stringof: What trait should I use to filter out data members? S s; foreach(idx, member; s.tupleof) { writeln(Name: ,

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
I am not sure I understand the question. Does this help? struct A { int x; double y; } void main() { foreach (idx, elem; A.init.tupleof) { pragma(msg, __traits(identifier, A.tupleof[idx])); } } // output: // x // y Exactly what I

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
BTW: Can DMD serve use file and line location of user defined type aswell? Thx! Correction: I mean serve *us*

Re: Class Data Members Name Reflection

2014-06-10 Thread Nordlöw
On Tuesday, 10 June 2014 at 17:29:35 UTC, Dicebot wrote: On Tuesday, 10 June 2014 at 16:10:09 UTC, Nordlöw wrote: Is there a way to iterate over the symbolic names of the data members of a class instance? I'm currently using .tupleof to get its values (and in turn types) to implement

  1   2   3   4   5   6   7   8   9   10   >