On Thursday, 31 March 2016 at 11:47:34 UTC, MGW wrote:
--
Help me to optimize this source code. How to apply here delegates
and generally whether possibly to make it here
On 01/04/2016 3:05 PM, Taylor Hillegeist wrote:
SO i have a maximum scope depth tool, that i just put together it is
super simple.
but when i use it in a drive other that C:\ i get an error. Even though
i just checked for a valid path.
Any ideas?
SO i have a maximum scope depth tool, that i just put together it
is super simple.
but when i use it in a drive other that C:\ i get an error. Even
though i just checked for a valid path.
Any ideas?
C:\Users\taylor.hillegeist\Documents\CodeSync\D
projects\Toys\TOOLS>NestCheck.exe
On 3/16/2016 4:18 AM, Johan Engelen wrote:
I've found discussions, but not an actual "recommended" solution for the
problem of "statement is not reachable" warnings in templates with early
returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
static if (is(U == bool)) {
On 03/31/2016 05:34 PM, learner wrote:
Hi,
I have the following code in C++.
rectangles.erase(rectangles.begin() + index);
where rectangles is:
std::vector rectangles;
how can I do something similar in D.
Learner.
import std.stdio;
void main() {
int[] a = [ 1, 2, 3, 4, 5 ];
Hi,
I have the following code in C++.
rectangles.erase(rectangles.begin() + index);
where rectangles is:
std::vector rectangles;
how can I do something similar in D.
Learner.
On 03/30/2016 11:39 PM, Dsby wrote:
> Like this:
>
> ubyte[] fun()
> {
> ubyte[] str = cast(ubyte[])"hello world";
> ubyte[] by = Mallocator.instance.allocate(str.length);
> by[] = str[];
> return by[5..$];
> }
>
> void mian()
> {
> ubyte[] aa = fun();
> // i want
On Thursday, 31 March 2016 at 13:48:46 UTC, Steven Schveighoffer
wrote:
stdio.readf is buffered. It does not deal with async io
properly I think.
-Steve
Yes, I must use core.sys.posix.unistd.read, which was actually
what A.D.Ruppe suggested, I think.
On Thursday, 31 March 2016 at 18:25:45 UTC, H. S. Teoh wrote:
On Thu, Mar 31, 2016 at 06:23:21PM +, ParticlePeter via
Digitalmars-d-learn wrote:
Example from docs:
string s = "hello!124:34.5";
string a;
int b;
double c;
formattedRead(s, "%s!%s:%s", , , );
assert(a == "hello" && b == 124 &&
On Thursday, 31 March 2016 at 18:25:46 UTC, jacob wrote:
I try to implement chunk (something like lock-free fixedsize
queue)
...
Check out this implementation
https://github.com/MartinNowak/lock-free/blob/master/src/lock_free/rwqueue.d
On Thu, Mar 31, 2016 at 06:23:21PM +, ParticlePeter via Digitalmars-d-learn
wrote:
> Example from docs:
> string s = "hello!124:34.5";
> string a;
> int b;
> double c;
> formattedRead(s, "%s!%s:%s", , , );
> assert(a == "hello" && b == 124 && c == 34.5);
>
> now changing the first
I try to implement chunk (something like lock-free fixedsize
queue)
--
import core.atomic;
shared struct Chunk(T, uint N)
{
shared T[N] data;
shared uint count;
shared uint queueCounter;
@property uint capacity() { return N; }
@property uint count() {
Example from docs:
string s = "hello!124:34.5";
string a;
int b;
double c;
formattedRead(s, "%s!%s:%s", , , );
assert(a == "hello" && b == 124 && c == 34.5);
now changing the first formattedRead argument to a string literal:
formattedRead("hello!124:34.5", "%s!%s:%s", , , );
results in this
On Thu, Mar 31, 2016 at 07:43:38PM +0200, ag0aep6g via Digitalmars-d-learn
wrote:
> On 30.03.2016 20:12, jmh530 wrote:
> >I wrote a version of cartesianProduct that will return the cartesian
> >product when the some of the types are not ranges. The original code
> >is below.
> >
> >My issue is
On 30.03.2016 20:12, jmh530 wrote:
I wrote a version of cartesianProduct that will return the cartesian
product when the some of the types are not ranges. The original code is
below.
My issue is that I can't figure out how to turn it into a variadic
template. The latest thing I tried is:
auto
On Thursday, 31 March 2016 at 13:47:25 UTC, Steven Schveighoffer
wrote:
Bug, but probably of the enhancement variety I think (I don't
think this is a small project). Receive should canonicalize the
input and requested receive type. That is,
receiveOnly!(const(int)) should really call
On 3/31/16 10:30 AM, Q. Schroll wrote:
On Thursday, 31 March 2016 at 13:51:00 UTC, Steven Schveighoffer wrote:
I think it's a bug. foreach and opApply are specially coded in the
compiler I think, so there's bound to be inconsistencies between them
and normal overload rules.
I have never
On Thursday, 31 March 2016 at 13:51:00 UTC, Steven Schveighoffer
wrote:
I think it's a bug. foreach and opApply are specially coded in
the compiler I think, so there's bound to be inconsistencies
between them and normal overload rules.
-Steve
I have never filed a bug report. Should this be
On Thursday, 31 March 2016 at 13:48:27 UTC, Adam D. Ruppe wrote:
It is trying to look up a name i in global scope, and calling
writeln on it.
This is why the .name syntax exists: so you can bypass local
variables with the same name when trying to access a global.
It would compile if you put
On 3/31/16 6:23 AM, Q. Schroll wrote:
Simple as that, shouldn't this work?
struct X
{
int opApply(int delegate(string) dg)
{
return dg("impure");
}
int opApply(int delegate(string) pure dg) pure
{
return dg("pure");
}
}
void main()
{
X x;
On Thursday, 31 March 2016 at 13:39:25 UTC, ixid wrote:
What is going on with UFCS and foreach?
foreach(i;0..5).writeln;
This is not UFCS; it is calling writeln on module scope. See
http://dlang.org/spec/module.html#module_scope_operators
Your code is semantically identical with
foreach
On 3/30/16 10:06 PM, Basile B. wrote:
On Thursday, 31 March 2016 at 01:12:50 UTC, Adam D. Ruppe wrote:
On Thursday, 31 March 2016 at 00:50:16 UTC, Basile B. wrote:
There should be a way to know how many bytes are available ?
You are already using poll()... I'd just use read() directly on the
On Thursday, 31 March 2016 at 13:39:25 UTC, ixid wrote:
What is going on with UFCS and foreach?
There's no such thing as UFCS on foreach. UFCS only works on
variables, not a foreach statement.
foreach(i;0..5).writeln;
You can add a line break and optional braces there to see what it
On Thursday, 31 March 2016 at 13:39:25 UTC, ixid wrote:
What is going on with UFCS and foreach?
foreach(i;0..5).writeln;
This prints five line breaks.
foreach(i;0..5).i.writeln;
This will not compile.
foreach(i;0..5).writeln(i);
This writes out 1 to 4 on separate lines. Is this supposed to
On 3/30/16 8:01 PM, Ali Çehreli wrote:
As expected, the following trivial case works:
void main() {
auto func = delegate(int i) {}; // expects int
func(const(int)(42));// passes const(int)
}
The following concurrency program fails at runtime:
import core.thread;
What is going on with UFCS and foreach?
foreach(i;0..5).writeln;
This prints five line breaks.
foreach(i;0..5).i.writeln;
This will not compile.
foreach(i;0..5).writeln(i);
This writes out 1 to 4 on separate lines. Is this supposed to
work? I thought a.b would be rewritten to b(a) with
On Thursday, 31 March 2016 at 12:49:57 UTC, ag0aep6g wrote:
I get theses timings then:
auto-decoding 642 ms, 969 μs, and 1 hnsec
byCodeUnit 84 ms, 980 μs, and 3 hnsecs
And 643 / 85 ≅ 8.
Ok, so not as bad as 100x, but still not great by any means. I
think I
On 31.03.2016 07:40, Jack Stouffer wrote:
$ ldc2 -O3 -release -boundscheck=off test.d
$ ./test
auto-decoding1 sec, 757 ms, and 946 μs
byCodeUnit87 ms, 731 μs, and 8 hnsecs
byGrapheme14 secs, 769 ms, 796 μs, and 6 hnsecs
So the auto-decoding version takes about twenty
On Thursday, 31 March 2016 at 10:27:41 UTC, Artur Skawina wrote:
auto mixedCartesianProduct(T...)(T x)
{
import std.range, std.algorithm : cartesianProduct;
return
mixin(`cartesianProduct(`~iota(T.length).map!`"conditionalOnly(x["~text(a)~"])"`().join(",")~`)`);
}
On Thursday, 31 March 2016 at 11:41:17 UTC, Rene Zwanenburg wrote:
std.algorithm.findAdjacent!((a, b) => a != b+1)(range).empty;
Correction: Should be:
std.algorithm.findAdjacent!((a, b) => a+1 != b)(range).empty;
Thanks!
I for myself write Qt-5 wrapper. I use calls from Qt (C ++) as
extern (C) calls.
Prompt how to write this code well and with use of abilities to
integrate D and C ++
--
// ex4.d - Concepts of QAction.QtE5
// compile -
// dmd ex4 qte5
import core.runtime;
import
On Thursday, 31 March 2016 at 11:33:36 UTC, Nordlöw wrote:
Is there a function in Phobos to check if a range of integral
elements is adjacent, that is
x[i+1] == x[i] + 1
where x[i] is the i:th element of the range.
(untested)
std.algorithm.findAdjacent!((a, b) => a !=
Is there a function in Phobos to check if a range of integral
elements is adjacent, that is
x[i+1] == x[i] + 1
where x[i] is the i:th element of the range.
On Thursday, 31 March 2016 at 08:53:46 UTC, Kagamin wrote:
AFAIK when you request a string, whatever value is there gets
converted to string. Or you can just add code to extract blobs,
that would be less effort than writing everything from scratch.
I have contact with it's developer. Hope for
On 03/30/16 20:12, jmh530 via Digitalmars-d-learn wrote:
> I wrote a version of cartesianProduct that will return the cartesian product
> when the some of the types are not ranges. The original code is below.
>
> My issue is that I can't figure out how to turn it into a variadic template.
>
Simple as that, shouldn't this work?
struct X
{
int opApply(int delegate(string) dg)
{
return dg("impure");
}
int opApply(int delegate(string) pure dg) pure
{
return dg("pure");
}
}
void main()
{
X x;
string result;
x.opApply(
AFAIK when you request a string, whatever value is there gets
converted to string. Or you can just add code to extract blobs,
that would be less effort than writing everything from scratch.
Like this:
ubyte[] fun()
{
ubyte[] str = cast(ubyte[])"hello world";
ubyte[] by = Mallocator.instance.allocate(str.length);
by[] = str[];
return by[5..$];
}
void mian()
{
ubyte[] aa = fun();
// i want free the aa's momeny.
//Mallocator.instance.deallocate(aa);// it is
38 matches
Mail list logo