Re: string mixup problem with stdin.byLine

2016-08-07 Thread Dave Akers via Digitalmars-d-learn
I do believe your problem is with the line... On Monday, 8 August 2016 at 02:44:20 UTC, torea wrote: string cleanLine = strip( cast(string)line ); It's casting a char[] to and immutable(char)[], causing the mutable buffer from byLine to be used as a string. what you want is...

string mixup problem with stdin.byLine

2016-08-07 Thread torea via Digitalmars-d-learn
Hi all, I'm still at beginner level in D and trying to make a simple note program in the terminal. I've been struggling with a simple problem for the last 2 hours so I could use some help! What I want to do is: if I write #m, I record the following lines in a specific string member of a

Cannot distinguish between template function wtih 0 args and 1 arg

2016-08-07 Thread Engine Machine via Digitalmars-d-learn
This really makes no sense Error: template Mem cannot deduce function from argument types !(cast(eException)1280L, "main.d", 38u, "main.WinMain")(int), candidates are: Mem(T, B = eX, string file = __FILE__, uint line = __LINE__, string func = __FUNCTION__)(size_t bytes) Mem(T, B = eX, string

Re: SortedRange.lowerBound from FrontTransversal

2016-08-07 Thread Michael Coulombe via Digitalmars-d-learn
On Monday, 8 August 2016 at 00:57:41 UTC, Michael Coulombe wrote: ... And looking at the source, the reason it fails when using TransverseOptions.assumeNotJagged is that it does not implement length or $. I made this into an enhancement request:

Re: SortedRange.lowerBound from FrontTransversal

2016-08-07 Thread Michael Coulombe via Digitalmars-d-learn
On Saturday, 6 August 2016 at 23:00:42 UTC, Alex wrote: Hi all... a technical question from my side... why the last line of the following gives the error? import std.stdio; import std.range; import std.algorithm; void main() { size_t[][] darr; darr.length = 2; darr[0] = [0, 1, 2,

Re: callback craziness

2016-08-07 Thread Engine Machine via Digitalmars-d-learn
On Sunday, 7 August 2016 at 23:02:26 UTC, ag0aep6g wrote: On 08/08/2016 12:08 AM, Engine Machine wrote: On Sunday, 7 August 2016 at 20:48:29 UTC, ag0aep6g wrote: [...] Delegates don't necessarily need a GC allocation. They only need it when they need a closure. Delegates of methods don't need

Re: callback craziness

2016-08-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 August 2016 at 23:02:26 UTC, ag0aep6g wrote: Not exactly. When you do something that requires a closure, it errors out. As I said, a delegate doesn't always require the allocation of a closure. You can also throw scope in there iff the delegate will never be stored: @nogc void

Re: callback craziness

2016-08-07 Thread ag0aep6g via Digitalmars-d-learn
On 08/08/2016 12:08 AM, Engine Machine wrote: On Sunday, 7 August 2016 at 20:48:29 UTC, ag0aep6g wrote: [...] Delegates don't necessarily need a GC allocation. They only need it when they need a closure. Delegates of methods don't need closures. And when you pass the delegate in a `scope`

Re: callback craziness

2016-08-07 Thread Engine Machine via Digitalmars-d-learn
On Sunday, 7 August 2016 at 20:48:29 UTC, ag0aep6g wrote: On 08/07/2016 10:01 PM, Engine Machine wrote: @nogc void foo(void delegate(int x) @nogc f); fails with the @nogc. Compiles just fine for me. 2nd, I cannot use a delegate because of the @nogc context, Delegates don't necessarily

Re: callback craziness

2016-08-07 Thread ag0aep6g via Digitalmars-d-learn
On 08/07/2016 10:01 PM, Engine Machine wrote: @nogc void foo(void delegate(int x) @nogc f); fails with the @nogc. Compiles just fine for me. 2nd, I cannot use a delegate because of the @nogc context, Delegates don't necessarily need a GC allocation. They only need it when they need a

callback craziness

2016-08-07 Thread Engine Machine via Digitalmars-d-learn
I use callbacks a lot and have trouble with D in a nogc context. First, I cannot declare the parameters with a nogc or I get a compile time error. @nogc void foo(void delegate(int x) @nogc f); fails with the @nogc. 2nd, I cannot use a delegate because of the @nogc context, @nogc void

Re: I need a @nogc version of hashOf(). What are the options?

2016-08-07 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 7 August 2016 at 18:37:19 UTC, ag0aep6g wrote: On 08/07/2016 07:10 PM, ag0aep6g wrote: https://github.com/dlang/druntime/pull/1624 Has been merged. Is going to be part of 2.072. Very cool! MurmurHash3 is a great addition too. Thanks guys.

Re: I need a @nogc version of hashOf(). What are the options?

2016-08-07 Thread ag0aep6g via Digitalmars-d-learn
On 08/07/2016 07:10 PM, ag0aep6g wrote: https://github.com/dlang/druntime/pull/1624 Has been merged. Is going to be part of 2.072.

Re: I need a @nogc version of hashOf(). What are the options?

2016-08-07 Thread ag0aep6g via Digitalmars-d-learn
On 08/07/2016 06:42 PM, Gary Willoughby wrote: I need a @nogc version of hashOf(). Here's one i'm currently using but it's not marked as @nogc. https://github.com/dlang/druntime/blob/master/src/object.d#L3170 That seems to be an oversight. https://github.com/dlang/druntime/pull/1624

Re: I need a @nogc version of hashOf(). What are the options?

2016-08-07 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Sunday, 7 August 2016 at 16:42:47 UTC, Gary Willoughby wrote: I need a @nogc version of hashOf(). Here's one i'm currently using but it's not marked as @nogc. https://github.com/dlang/druntime/blob/master/src/object.d#L3170 What are the options now? Is there anything D offers that I could

I need a @nogc version of hashOf(). What are the options?

2016-08-07 Thread Gary Willoughby via Digitalmars-d-learn
I need a @nogc version of hashOf(). Here's one i'm currently using but it's not marked as @nogc. https://github.com/dlang/druntime/blob/master/src/object.d#L3170 What are the options now? Is there anything D offers that I could use? I need a function that takes a variable of any type and