I am having trouble understanding how to navigate the tree
returned by std.json. I am new to D programming, I have tried
reading the std.json source code but I am still stumped.
I want to iterate the tree of JSONValue(s) by the json objects
key names and I need to be test the type of the valu
On Sun, 26 Jan 2014 18:41:00 -0500, Nicolas Sicard
wrote:
Running a piece of code that can be reduced to:
---
import std.stdio;
void main()
{
import std.range;
foreach(item; iota(0, 10).transform(2))
writeln(item);
}
auto transform(T)(T list, real x)
{
On 2014-01-26 09:59, Pierre Talbot wrote:> Hi,
>
> I was wondering why CTFE is context sensitive, why don't we check
> every expressions and run the CTFE if it applies?
Mostly because it's not necessary, and takes more time than simply
compiling it. For an optimization step, opportunistic CTFE w
On Sunday, 26 January 2014 at 20:34:27 UTC, bearophile wrote:
Do you know that module level variables in D are thread-local?
If you don't what that, you have to use __gshared.
Bye,
bearophile
Perfect, thanks!
If anyone wants to make things easy on stupid people like me,
using a module level
On 01/26/2014 04:06 PM, Pierre Talbot wrote:
On Sunday, 26 January 2014 at 13:48:47 UTC, Timon Gehr wrote:
On 01/26/2014 10:59 AM, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we check
every expressions and run the CTFE if it applies?
When does it apply?
You might want to consider submitting a bug report on account of
cartesianProduct() not being able to deal with ranges of
immutable elements. The worst that can happen is that you'd get a
real expert's explanation on why it's not a bug. But who knows,
perhaps it is :)
On Sunday, 26 January 2014 at 23:54:02 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 23:37:40 UTC, Nordlöw wrote:
The closest would be std.traits.hasIndirections.
Does this work recursively on containing types?
AFAIK no, it just checks immediate fields (if any).
OTOH, it see
On Sunday, 26 January 2014 at 23:37:40 UTC, Nordlöw wrote:
Might I ask... why do you need this sort of thing? :)
For bit-parallel run-length encoding for efficient
serialization of sets of std.datetime:SysTime structures (16
bytes).
SysTime's representation consists of a long and
Rebindab
Running a piece of code that can be reduced to:
---
import std.stdio;
void main()
{
import std.range;
foreach(item; iota(0, 10).transform(2))
writeln(item);
}
auto transform(T)(T list, real x)
{
auto t = /* new */ Transformer(x); // line 12
retu
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
On Sunday, 26 January 2014 at 22:19:47 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 21:49:37 UTC, matovitch wrote:
Short answer: with std.algorithm - you can't. Because internally
it (Zip, actually) performs assignments, and you can't assign to
immutable(T).
Why?
Here is the pro
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 you need this sort of thing? :)
That's why I need the cast (I think
On Sunday, 26 January 2014 at 22:52:56 UTC, Jakob Ovrum wrote:
On Sunday, 26 January 2014 at 22:32:32 UTC, matovitch wrote:
You mean that two input ranges are created from the immutable
arrays when I call the function ?
Zip doesn't compiles while zip compile. :/
`Zip` must be explicitly inst
On Sunday, 26 January 2014 at 22:32:32 UTC, matovitch wrote:
You mean that two input ranges are created from the immutable
arrays when I call the function ?
Zip doesn't compiles while zip compile. :/
`Zip` must be explicitly instantiated, which allows you to
attempt to instantiate it with he
On Saturday, 25 January 2014 at 15:34:57 UTC, Philippe Sigaud
wrote:
On Fri, Jan 24, 2014 at 10:25 PM, Benjamin Thaut
wrote:
What Plattform are you profiling on?
Linux 32bits. Does it change something? I'm not using any
OS-specific
part of Phobos, AFAICT.
Doesn't really change something.
On Sunday, 26 January 2014 at 22:19:47 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 21:49:37 UTC, matovitch wrote:
void main() {
immutable int[] B = [ 1, 2, 3 ];
immutable int[] C = [ 4, 5, 6 ];
auto BC = zip(B, C);
writeln(BC);
}
Here B and C aren't inputRange thoug
On Sunday, 26 January 2014 at 21:49:37 UTC, matovitch wrote:
void main() {
immutable int[] B = [ 1, 2, 3 ];
immutable int[] C = [ 4, 5, 6 ];
auto BC = zip(B, C);
writeln(BC);
}
Here B and C aren't inputRange thought acording to the template
constraint of zip there should be. H
I posted a question on stackoverflow about the cartesian product
of immutable ranges :
http://stackoverflow.com/questions/21368501/cartesian-product-of-immutable-ranges
There are a lot of various thing I don't understand.
This code compiles and run :
import std.stdio;
import std.range;
import
On Sunday, 26 January 2014 at 17:15:10 UTC, Marco Leise wrote:
Since shared hasn't change much in the last years, I assume it
is somewhat accepted in its current state. My understanding is
that if something cannot be attributed to a single thread, it
is "shared". So far so good.
Now I wrote an ob
Has anybody cooked up some generic functions that extend
`core.bitop` bitmanipulations to work on any value type?
Something like
bool getBit(T)(in T a, int bitnum); // bt
T setBit(T)(in T a, int bitnum); // bts
auto ref setBitInPlace(T)(ref T a, int bitnum);
I know this is relative
Andrew Klaassen:
This happens with dmd, ldc2 and gdc, so I assume it's something
I'm doing wrong rather than a bug. What's the explanation?
What am I doing wrong?
Do you know that module level variables in D are thread-local? If
you don't what that, you have to use __gshared.
Bye,
bearophi
On Sunday, 26 January 2014 at 09:59:01 UTC, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we
check
every expressions and run the CTFE if it applies?
The halting problem possibly?
On Sunday, 26 January 2014 at 15:06:30 UTC, Pierre Talbot wrote:
On Sunday, 26 January 2014 at 13:48:47 UTC, Timon Gehr wrote:
On 01/26/2014 10:59 AM, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we
check
every expressions and run the CTFE if it applies?
Since shared hasn't change much in the last years, I assume it
is somewhat accepted in its current state. My understanding is
that if something cannot be attributed to a single thread, it
is "shared". So far so good.
Now I wrote an object pool struct with two properties: it can
be used by multiple
I've got some code which sets values in a 2D array. Each value
is independent, so I'm using std.parallelism to set the values a
row at a time. When my variables are class variables it seems to
work (though it's hard to tell, given that the effect is
intermittent), but when I use module-level
Hi,
While solving a unrelated programming problem I ended up copying
a CRC16-CCITT implementation Google found for me. After I thought
it would be nice to make a D style implementation with some
compile time magic.
My idea was to implement something similar to:
http://www.ross.net/crc/download/crc
On Sunday, 26 January 2014 at 13:48:47 UTC, Timon Gehr wrote:
On 01/26/2014 10:59 AM, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we
check
every expressions and run the CTFE if it applies?
When does it apply?
According to http://dlang.org/function.htm
On Sunday, 26 January 2014 at 14:22:16 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 13:33:58 UTC, matovitch wrote:
s/immutable/enum/
?
I just get the vi style ! :D
It works exactly as expected. Thank you very much for your help !
On Sunday, 26 January 2014 at 14:29:54 UTC, matovitch wrote:
s/immutable/enum/
?
I am a *total* beginner so I am sure my code should look at
least strange to experts. How should I write this ? Why ?
I am not sure exactly what are you trying to achieve. My comment
meant "ditch immutable, r
On Sunday, 26 January 2014 at 14:32:48 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 14:24:35 UTC, matovitch wrote:
Well in a for loop, you only need one more index variable
whereas here we store the whole index range.
Not the *whole* range, that would be impossible since it's
i
On Sunday, 26 January 2014 at 14:24:35 UTC, matovitch wrote:
Well in a for loop, you only need one more index variable
whereas here we store the whole index range.
Not the *whole* range, that would be impossible since it's
infinite :) In this particular instance, index range is a struct
cons
On Sunday, 26 January 2014 at 14:22:16 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 13:33:58 UTC, matovitch wrote:
Now DMD compiler segfaulted. Here is my code if you are
interested...
struct Bernstein(alias K, int S)
if (isBernstein!(K))
{
immutable typeof(K) kernel = K;
On Sunday, 26 January 2014 at 14:13:28 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 13:45:32 UTC, matovitch wrote:
Anyway, the proposed solutions use twice much memory than a
simple for loop...
???
Well in a for loop, you only need one more index variable whereas
here we sto
On Sunday, 26 January 2014 at 13:33:58 UTC, matovitch wrote:
Now DMD compiler segfaulted. Here is my code if you are
interested...
struct Bernstein(alias K, int S)
if (isBernstein!(K))
{
immutable typeof(K) kernel = K;
immutable int shift = S;
}
s/immutable/enum/
?
On Sunday, 26 January 2014 at 13:49:34 UTC, bearophile wrote:
Stanislav Blinov:
We need generic enumerate() in Phobos :(
It will come soon :-)
https://github.com/D-Programming-Language/phobos/pull/1866
Cool!
This also shows we need a good syntax to unpack tuples:
100% agree.
myRang
On Sun, 2014-01-26 at 12:11 +, Russel Winder wrote:
[…]
> However with Python 2 the example from:
>
>https://bitbucket.org/ariovistus/pyd/wiki/QuickStart
>
> leads to:
>
> |> python setup.py build
> Traceback (most recent call last):
> File "setup.py", line 11, in
> d_lump=True
>
On Sunday, 26 January 2014 at 13:45:32 UTC, matovitch wrote:
Anyway, the proposed solutions use twice much memory than a
simple for loop...
???
is the compiler smart enougth to optimize this kind of code ?
There are ongoing discussions on what and how current D compilers
optimize nowadays
I get the following error message :
/usr/include/dmd/phobos/std/range.d(4220): Error: Internal
Compiler Error: CTFE literal Tuple(void, void)._expand_field_0
dmd: ctfeexpr.c:359: Expression* copyLiteral(Expression*):
Assertion `0' failed.
Aborted (core dumped)
Someone already encounter this
On 01/26/2014 10:59 AM, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we check
every expressions and run the CTFE if it applies?
When does it apply?
Extract it into a function and stick it into your library, it's
extremely useful :)
Anyway, the proposed solutions use twice much memory than a
simple for loop...is the compiler smart enougth to optimize this
kind of code ?
Stanislav Blinov:
We need generic enumerate() in Phobos :(
It will come soon :-)
https://github.com/D-Programming-Language/phobos/pull/1866
(Take a look at my comment about foreach there)
This also shows we need a good syntax to unpack tuples:
void main() {
auto myRange = iota(0,10
On Sunday, 26 January 2014 at 13:24:06 UTC, matovitch wrote:
Zipping an index array is uglier in my opinion... ;-)
Extract it into a function and stick it into your library, it's
extremely useful :)
import std.range;
import std.algorithm;
import std.stdio;
auto enumerate(R)(R r) {
On Sunday, 26 January 2014 at 12:52:38 UTC, Martin Cejp wrote:
On Sunday, 26 January 2014 at 09:59:01 UTC, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we
check
every expressions and run the CTFE if it applies?
Speed?
Hmm, I knew I shouldn't have dupli
Now DMD compiler segfaulted. Here is my code if you are
interested...
The berstein.d file :
import std.array;
import std.range;
import std.traits;
import std.algorithm;
bool isBernstein(alias K)() {
static if (isArray!(typeof(K)) &&
(K.empty || isNumeric!(typeof(K[0]
On Sunday, 26 January 2014 at 13:21:24 UTC, Stanislav Blinov
wrote:
But it's easy to avoid the multiplication and replace it with
a conditional neg.
Bye,
bearophile
How would you do this ?
map!(a => (a.index & 1) ? a : -a)([1, 2]) ? (index field isn't
available of course)
import std.range
But it's easy to avoid the multiplication and replace it with
a conditional neg.
Bye,
bearophile
How would you do this ?
map!(a => (a.index & 1) ? a : -a)([1, 2]) ? (index field isn't
available of course)
import std.range;
import std.algorithm;
import std.stdio;
void main() {
aut
On Sunday, 26 January 2014 at 13:06:38 UTC, bearophile wrote:
matovitch:
I got a problem which I'm sure can be solved by a smart one
liner. I would like to obtain the term by term product of a
given range by the infinite cyclic range cycle([1,-1]). How
can I do that ?
void main() {
impo
matovitch:
I got a problem which I'm sure can be solved by a smart one
liner. I would like to obtain the term by term product of a
given range by the infinite cyclic range cycle([1,-1]). How can
I do that ?
void main() {
import std.stdio, std.range, std.algorithm;
auto r = [10, 20, 3
On Sunday, 26 January 2014 at 13:05:55 UTC, Stanislav Blinov
wrote:
On Sunday, 26 January 2014 at 12:50:05 UTC, matovitch wrote:
Hello !
I got a problem which I'm sure can be solved by a smart one
liner. I would like to obtain the term by term product of a
given range by the infinite cyclic r
On Sunday, 26 January 2014 at 12:50:05 UTC, matovitch wrote:
Hello !
I got a problem which I'm sure can be solved by a smart one
liner. I would like to obtain the term by term product of a
given range by the infinite cyclic range cycle([1,-1]). How can
I do that ?
dpaste seems to be somewha
On Sunday, 26 January 2014 at 09:59:01 UTC, Pierre Talbot wrote:
Hi,
I was wondering why CTFE is context sensitive, why don't we
check
every expressions and run the CTFE if it applies?
Speed?
Hello !
I got a problem which I'm sure can be solved by a smart one
liner. I would like to obtain the term by term product of a given
range by the infinite cyclic range cycle([1,-1]). How can I do
that ?
On Sun, 2014-01-26 at 01:33 +, Ellery Newcomer wrote:
> On Friday, 24 January 2014 at 10:55:34 UTC, Russel Winder wrote:
> >
> > Probably want to use a virtualenv for this rather than install
> > into the
> > base installation
> >
>
> you can also do
>
> python setup.py build
> python runtes
On Saturday, 25 January 2014 at 23:20:47 UTC, Johannes Pfau wrote:
Yes, I came to the same conclusion. If we combine volatile
and shared into one qualifier we'll always have a certain
performance
hit.
This is what GDC does now.
Hi,
I was wondering why CTFE is context sensitive, why don't we check
every expressions and run the CTFE if it applies?
56 matches
Mail list logo