Is this code available in any repo/archive somewhere?
/Per
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`
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
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
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
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
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
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
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.
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
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.
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
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
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
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
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)
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
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))
{
...
}
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?
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
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
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,
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
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
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]
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...
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;
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
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
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
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
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:
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
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
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
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?
On thing though...why did you choose SDL2 of GLFW3?
I of course mean SDL2 *over* GLFW3.
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.
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
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
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
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
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
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,
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
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
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
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
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?
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
If not, what would it require to implement it?
That would be an interesting task to fix :)
DMD source references anyone?
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)
{
You can't use reduce with a const seed.
This, surely, must be a compiler bug right?
/Per
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?
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
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]
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
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
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?
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
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:
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.
Have anybody put together some D code for reading out tables from
ELF files?
A range/slice based version would be nice.
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
again, it is quite simplistic). If you specify what you need a
bit more, I might be able to provide that.
Please, post :)
Here you go, https://github.com/yazd/elf-d.
Thanks!
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;
}
/**
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:
Its up: https://github.com/nordlow/justd/blob/master/enums.d
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 =
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
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
So that leaves me with using an array of bool and rank() then,
I guess...
Correction: I mean array of strings and find.
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
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
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
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
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
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
What is wrong?
For some reason the mixin declarations for op* are not imported
into the calling scope when others are.
Compiler bug?
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
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
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;
}
What is wrong?
Ping, anybody?
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.
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
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
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
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?
No. We've been able to return by ref for ages. However, when
Thx
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!
I commented in github.
Thx!
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
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?
Thx
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:
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: ,
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
BTW: Can DMD serve use file and line location of user defined
type aswell?
Thx!
Correction: I mean serve *us*
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 - 100 of 1421 matches
Mail list logo