Re: Template not seeming to instantiate a second time with default alias parameter

2016-08-30 Thread ag0aep6g via Digitalmars-d-learn
On 08/30/2016 11:28 PM, wobbles wrote: I'll have to try find a workaround for now :/ This also seems to work, but has a slightly different meaning: class Node(T, alias func = t => t*t) {/* ... */} The default func is a template here. Equivalent to this: auto square(T)(T t) {

Re: Template not seeming to instantiate a second time with default alias parameter

2016-08-30 Thread ag0aep6g via Digitalmars-d-learn
On 08/30/2016 11:28 PM, wobbles wrote: I'll have to try find a workaround for now :/ This seems to work and isn't too ugly: class Node(T, alias func) {/*...*/} alias Node(T) = Node!(T, (T t) => t*t);

Re: Template not seeming to instantiate a second time with default alias parameter

2016-08-30 Thread wobbles via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 20:55:20 UTC, ag0aep6g wrote: On 08/30/2016 10:41 PM, wobbles wrote: class Node(T, alias func = (T t => t*t))(){ //whatever } //instantiate Node!(int) intNode; Node!(float) floatNode; // fails as lambda func expects an int. Am I doing something wrong or is

Re: Template not seeming to instantiate a second time with default alias parameter

2016-08-30 Thread ag0aep6g via Digitalmars-d-learn
On 08/30/2016 10:41 PM, wobbles wrote: class Node(T, alias func = (T t => t*t))(){ //whatever } //instantiate Node!(int) intNode; Node!(float) floatNode; // fails as lambda func expects an int. Am I doing something wrong or is this a bug? Proper test case: class Node(T, alias func =

Re: Error when running vibe.d example application, not sure of the cause.

2016-08-30 Thread e-y-e via Digitalmars-d-learn
On Monday, 29 August 2016 at 20:32:27 UTC, e-y-e wrote: [...] Does anyone know of anywhere else I can get help with this error? It's a blocker on me using vibe.d, which is quite frustrating.

Template not seeming to instantiate a second time with default alias parameter

2016-08-30 Thread wobbles via Digitalmars-d-learn
Hi, Code here: https://gist.github.com/grogancolin/066a8a8c105fa473dfee961e2481a30e Basically, it seems when a template has an alias parameter like class Node(T, alias func = (T t => t*t))(){ //whatever } //instantiate Node!(int) intNode; Node!(float) floatNode; // fails as lambda func

Re: Prevent copy of range in foreach

2016-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2016 12:06 PM, Yuxuan Shui wrote: Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? It's not possible. You can't do much with such a range anyway. For example, even r.take(10) requires

Re: is this a typographical bug?

2016-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2016 10:25 AM, WhatMeWorry wrote: Error: module std.string import 'removeChars' not found, did you mean template 'removechars(S)(S s, in S pattern) if (isSomeString!S)'? Shouldn't it be removeChars? All the other library calls seem to be camelCased. Should i not bother to open a

Re: Does D have anything like the generators of Python and some other languages?

2016-08-30 Thread A D dev via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 00:57:05 UTC, Meta wrote: There's a Generator class in std.concurrency. I haven't used https://dlang.org/phobos/std_concurrency.html#.Generator Thanks, Meta.

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 19:03:06 UTC, Nordlöw wrote: https://github.com/nordlow/phobos-next/blob/master/src/dbg.d#L58 Renamed to https://github.com/nordlow/phobos-next/blob/master/src/dbgio.d#L58

Prevent copy of range in foreach

2016-08-30 Thread Yuxuan Shui via Digitalmars-d-learn
Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? Should I use move()?

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 17:11:48 UTC, Johannes Pfau wrote: Nice! Here's a slightly modified version: https://dpaste.dzfl.pl/8c5ec90c5b39 This version does not need an additional delegate. It can be used like this: assumeNogc!writefln("foo %s", 42); assumeNogc!writeln("foo", 42);

is this a typographical bug?

2016-08-30 Thread WhatMeWorry via Digitalmars-d-learn
Error: module std.string import 'removeChars' not found, did you mean template 'removechars(S)(S s, in S pattern) if (isSomeString!S)'? Shouldn't it be removeChars? All the other library calls seem to be camelCased. Should i not bother to open a change request because this would cause too

Re: Debug prints in @nogc

2016-08-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 30 Aug 2016 16:37:53 + schrieb Cauterite : > On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote: > > Just being able to print a string is not good enough. I want > > the variadic part writeln so I can debug-print values in my > > buggy code. Do you have a

Re: Debug prints in @nogc

2016-08-30 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote: Just being able to print a string is not good enough. I want the variadic part writeln so I can debug-print values in my buggy code. Do you have a similar solution? Take a look at the example here:

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 11:52:21 UTC, Johannes Pfau wrote: import std.stdio; debug { enum writelnPtr = !string; enum void function(string) @nogc writelnNoGC = cast(void function(string) @nogc)writelnPtr; } void main() @nogc { debug writelnNoGC("foo"); } Just being

Re: D to C++

2016-08-30 Thread eugene via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote: Is it possible to compile from D to C++? Explanation: I do some competition programming and would like to write it in D instead of C++ :) maybe will help https://wiki.dlang.org/Calypso

Re: Debug prints in @nogc

2016-08-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 30 Aug 2016 10:26:28 + schrieb Nordlöw : > I'm struggling with debug printing in my @nogc-containers. > > The alternatives: > > assert(false, "Fixed message with no parameters"); > > is not enough for my needs > > debug writeln("Fixed"); > >

Re: Debug prints in @nogc

2016-08-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/08/2016 11:10 PM, Nordlöw wrote: On Tuesday, 30 August 2016 at 10:36:13 UTC, rikki cattermole wrote: On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 10:36:13 UTC, rikki cattermole wrote: On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug

Re: Debug prints in @nogc

2016-08-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And temporary commenting out

Re: Debug prints in @nogc

2016-08-30 Thread Seb via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 10:26:28 UTC, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And

Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And temporary commenting out @nogc is cumbersome. I'm aware of

Re: RDTSCP from dlang

2016-08-30 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 02:04:55 UTC, kookman wrote: I need to access the x86_64 RDTSCP assembly instruction from D. I found this for C++: http://stackoverflow.com/questions/14783782/which-inline-assembly-code-is-correct-for-rdtscp Does anyone here know how (if?) I can do this from D?