alias with lambda syntax: alias fun2=a=>fun(a);

2014-06-04 Thread Timothee Cour via Digitalmars-d-learn
Is there a way to do this? import std.algorithm; auto fun(T)(T a){return a;} template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and cannot be nested inside test() void main(){ //alias fun2=fun!int; //OK but needs to specify template params //none of those work: //alias

Re: how to get line number after readln

2014-06-04 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 5 June 2014 at 00:33:26 UTC, Ali Çehreli wrote: On 06/04/2014 05:05 PM, Robert Hathaway wrote: I've got a program that reads a text file line by line (using std.stdio readln()) Consider using byLine() instead. (Important: byLine uses an internal buffer for the line; so, don't fo

Re: how to get line number after readln

2014-06-04 Thread Ali Çehreli via Digitalmars-d-learn
On 06/04/2014 05:05 PM, Robert Hathaway wrote: I've got a program that reads a text file line by line (using std.stdio readln()) Consider using byLine() instead. (Important: byLine uses an internal buffer for the line; so, don't forget to make a copy if you want to store the line for later us

how to get line number after readln

2014-06-04 Thread Robert Hathaway via Digitalmars-d-learn
I've got a program that reads a text file line by line (using std.stdio readln()) and I'd like to refer to the line number when I send a message to stderr upon finding a mis-formatted line. Is there a way to get the current line number? Of course, I could create a counter and increment it wit

Arrays as template parameters

2014-06-04 Thread cal via Digitalmars-d-learn
I have the following code (on dpaste, http://dpaste.dzfl.pl/636c04430a33): enum : uint { a, b, c } enum list = [a, b]; void foo(T...)() { pragma(msg, T[0].length); // fine pragma(msg, T[0][0]); // fine pragma(msg, T[0][1]); // fine foreach(i; Iota!(0,T[0].length)) // fi

Re: why it said no identifier for declarator …

2014-06-04 Thread Jesse Phillips via Digitalmars-d-learn
I take it the output looks something like this: struct S { int a; } S s; s.a = 3; void main() { } Hope this clears up this next problem. Module scope doesn't get to utilize a variable, it can only initialize at compile-time.

Re: Kernel in D

2014-06-04 Thread Kagamin via Digitalmars-d-learn
On Saturday, 31 May 2014 at 23:27:45 UTC, Qox wrote: On Saturday, 31 May 2014 at 07:57:18 UTC, Kagamin wrote: http://www.xomb.org/ ? seems to be outdated, but its another OS written in D. It's dead for only a year, the developer have probably graduated.

Re: Building 32bit program with MSVC?

2014-06-04 Thread Kagamin via Digitalmars-d-learn
LLVM never supported OMF. LDC uses msvcrt runtime, and MS claims that whatever can link with msvcrt, it also can link with later versions of msvcrt.

Re: why it said no identifier for declarator …

2014-06-04 Thread bioinfornatics via Digitalmars-d-learn
On Wednesday, 4 June 2014 at 00:07:35 UTC, Jesse Phillips wrote: On Tuesday, 3 June 2014 at 22:10:06 UTC, bioinfornatics wrote: I do not see why it fail in debug output we see that tuple have a field with given name. Your generated output (short and formatted) alias TL = Tuple!(int,"x",

Re: override toString() for a tuple?

2014-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 04 Jun 2014 06:25:53 + Steve D via Digitalmars-d-learn wrote: > You would think the promise of OO and Inheritance > would make it easy and free us from hacks like this ;) That would require using OO and inheritance, which has nothing to do with Tuple. ;) And actually, I find that I

Re: why it said no identifier for declarator …

2014-06-04 Thread bioinfornatics via Digitalmars-d-learn
On Wednesday, 4 June 2014 at 00:07:35 UTC, Jesse Phillips wrote: On Tuesday, 3 June 2014 at 22:10:06 UTC, bioinfornatics wrote: I do not see why it fail in debug output we see that tuple have a field with given name. Your generated output (short and formatted) alias TL = Tuple!(int,"x",