Re: static / global operator overload

2013-08-18 Thread monarch_dodra
On Sunday, 18 August 2013 at 21:23:05 UTC, Namespace wrote: On Sunday, 18 August 2013 at 15:29:26 UTC, Ali Çehreli wrote: On 08/18/2013 07:34 AM, Namespace wrote: > In C++ you can declare operator overloads inside and outside of classes > (the latter is more popular) The latter is popular beca

Re: more enum and pragma troubles

2013-08-18 Thread JS
On Monday, 19 August 2013 at 04:37:58 UTC, captaindet wrote: On 2013-08-17 21:54, JS wrote: On Sunday, 18 August 2013 at 00:17:22 UTC, captaindet wrote: On 2013-08-17 14:36, Jesse Phillips wrote: Third you've declared a variable, bar, which will store your enumerated value, 4. Variables are no

Re: more enum and pragma troubles

2013-08-18 Thread captaindet
On 2013-08-17 21:54, JS wrote: On Sunday, 18 August 2013 at 00:17:22 UTC, captaindet wrote: On 2013-08-17 14:36, Jesse Phillips wrote: Third you've declared a variable, bar, which will store your enumerated value, 4. Variables are not compile time, even if the value stored came from a compile t

Re: Does a Priority Queue implementation exist out there?

2013-08-18 Thread Dylan Knutson
On Sunday, 18 August 2013 at 22:53:50 UTC, bearophile wrote: Dylan Knutson: I can't find a priority queue implementation in Phobos. In Phobos there's no general priority queue, but there's a heap, is it enough? Bye, bearophile Actually, I do think that will work :-) Thank you!

Re: cannot build LDC on OSX

2013-08-18 Thread Timothee Cour
ok i updated the issue on the git hub link i posted On Sun, Aug 18, 2013 at 7:43 PM, Tyler Jameson Little wrote: > On Sunday, 18 August 2013 at 23:31:58 UTC, Timothee Cour wrote: > >> I'm bumping up this issue here >> https://github.com/ldc-**developers/ldc/issues/436

Re: scoped imports

2013-08-18 Thread Jonathan M Davis
On Monday, August 19, 2013 04:36:37 Joseph Rushton Wakeling wrote: > On Monday, 19 August 2013 at 01:16:44 UTC, Timothee Cour wrote: > > goal1: avoid polluting global module name space: > > void fun(){ > > version=A; > > //now the code below in fun() scope has version(A) set > > } > > > > goal2: >

Re: cannot build LDC on OSX

2013-08-18 Thread Tyler Jameson Little
On Sunday, 18 August 2013 at 23:31:58 UTC, Timothee Cour wrote: I'm bumping up this issue here https://github.com/ldc-developers/ldc/issues/436 as it's been 16 days with no answer ... am i doing something wrong? it used to work a while ago, IIRC. I don't know if you noticed, but there's an LD

Re: scoped imports

2013-08-18 Thread Joseph Rushton Wakeling
On Monday, 19 August 2013 at 01:16:44 UTC, Timothee Cour wrote: goal1: avoid polluting global module name space: void fun(){ version=A; //now the code below in fun() scope has version(A) set } goal2: void fun(){ version(none): //all the code below this IN THIS FUNCTION becomes versioned out //(a

Re: scoped imports

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 7:52 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: > On Sunday, 18 August 2013 at 09:52:29 UTC, Timothee Cour wrote: > >> On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < >> joseph.wakel...@webdrake.net> wrote: >> >> On Sunday, 18 August 2013

cannot build LDC on OSX

2013-08-18 Thread Timothee Cour
I'm bumping up this issue here https://github.com/ldc-developers/ldc/issues/436 as it's been 16 days with no answer ... am i doing something wrong? it used to work a while ago, IIRC.

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread John Colvin
On Sunday, 18 August 2013 at 20:54:14 UTC, Joseph Rushton Wakeling wrote: On Sunday, 18 August 2013 at 19:48:39 UTC, John Colvin wrote: On Sunday, 18 August 2013 at 18:56:02 UTC, Dicebot wrote: Looking at Tuple implementation, this information gets lost at template instatiation time. I think it

Re: Does a Priority Queue implementation exist out there?

2013-08-18 Thread bearophile
Dylan Knutson: I can't find a priority queue implementation in Phobos. In Phobos there's no general priority queue, but there's a heap, is it enough? Bye, bearophile

Re: static / global operator overload

2013-08-18 Thread Namespace
On Sunday, 18 August 2013 at 15:29:26 UTC, Ali Çehreli wrote: On 08/18/2013 07:34 AM, Namespace wrote: > In C++ you can declare operator overloads inside and outside of classes > (the latter is more popular) The latter is popular because a global operator takes advantage of implicit type conve

Does a Priority Queue implementation exist out there?

2013-08-18 Thread Dylan Knutson
Hello, I can't find a priority queue implementation in Phobos. This struck me as odd, because std.container has a few common containers already, and priority queues are used very often. Perhaps it exists in another module? In case there is indeed not a PQ container in Phobos, is there a pri

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Joseph Rushton Wakeling
On Sunday, 18 August 2013 at 19:48:39 UTC, John Colvin wrote: On Sunday, 18 August 2013 at 18:56:02 UTC, Dicebot wrote: Looking at Tuple implementation, this information gets lost at template instatiation time. I think it is worth a pull request to store properly ordered tuple of field aliases

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread John Colvin
On Sunday, 18 August 2013 at 18:56:02 UTC, Dicebot wrote: Looking at Tuple implementation, this information gets lost at template instatiation time. I think it is worth a pull request to store properly ordered tuple of field aliases in Tuple type. To get the names: https://github.com/D-Progra

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Dicebot
Looking at Tuple implementation, this information gets lost at template instatiation time. I think it is worth a pull request to store properly ordered tuple of field aliases in Tuple type.

Re: Win32: How to get the stack trace when compiling with a windows subsystem?

2013-08-18 Thread Nick Sabalausky
On Sun, 18 Aug 2013 16:07:20 +0200 Andrej Mitrovic wrote: > > catch (Throwable thr) > { > stderr.writeln(thr.msg); stderr.writeln(thr.msg); // No trace stderr.writeln(thr); // Includes trace However, I'm guessing it probably doesn't solve the other problem: > The > 'info' fi

Re: scoped imports

2013-08-18 Thread monarch_dodra
On Sunday, 18 August 2013 at 14:52:04 UTC, Joseph Rushton Wakeling wrote: On Sunday, 18 August 2013 at 09:52:29 UTC, Timothee Cour wrote: On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: On Sunday, 18 August 2013 at 01:33:51 UTC, Timothee Cour wro

Re: static / global operator overload

2013-08-18 Thread monarch_dodra
On Sunday, 18 August 2013 at 15:29:26 UTC, Ali Çehreli wrote: On 08/18/2013 07:34 AM, Namespace wrote: > In C++ you can declare operator overloads inside and outside of classes > (the latter is more popular) The latter is popular because a global operator takes advantage of implicit type conve

Re: static / global operator overload

2013-08-18 Thread Ali Çehreli
On 08/18/2013 07:34 AM, Namespace wrote: > In C++ you can declare operator overloads inside and outside of classes > (the latter is more popular) The latter is popular because a global operator takes advantage of implicit type conversions. A global operator+ allows using an int even on the lef

Re: scoped imports

2013-08-18 Thread Joseph Rushton Wakeling
On Sunday, 18 August 2013 at 09:52:29 UTC, Timothee Cour wrote: On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: On Sunday, 18 August 2013 at 01:33:51 UTC, Timothee Cour wrote: granted, that's not ideal. How about the other points I mentioned? vo

Re: Win32: How to get the stack trace when compiling with a windows subsystem?

2013-08-18 Thread Andrej Mitrovic
On 8/18/13, Adam D. Ruppe wrote: > extern(Windows) void AllocConsole(); // not sure if that's the > perfect signature but it works > > void main() { > debug AllocConsole(); > throw new Exception("test"); > } > > > The problem is the console will close before you can actually > read it! But

static / global operator overload

2013-08-18 Thread Namespace
I can't find anything so I ask here: what was the decision to disallow static or global operator overloads? In C++ you can declare operator overloads inside and outside of classes (the latter is more popular), so why wasn't this introduced in D also? Thanks in advance. :)

Re: Win32: How to get the stack trace when compiling with a windows subsystem?

2013-08-18 Thread Adam D. Ruppe
On Sunday, 18 August 2013 at 14:10:07 UTC, Andrej Mitrovic wrote: Actually it would be even better if I could create a console window when building with subsystem:windows, for debugging purposes. extern(Windows) void AllocConsole(); // not sure if that's the perfect signature but it works

Re: Win32: How to get the stack trace when compiling with a windows subsystem?

2013-08-18 Thread Andrej Mitrovic
On 8/18/13, Andrej Mitrovic wrote: > if (!GetConsoleWindow()) Actually it would be even better if I could create a console window when building with subsystem:windows, for debugging purposes. I'll have a look at MSDN on ways to do this, unless someone already knows this and posts it here. No

Win32: How to get the stack trace when compiling with a windows subsystem?

2013-08-18 Thread Andrej Mitrovic
When you compile with -L/SUBSYSTEM:WINDOWS you're essentially building an app without a console, so if you want to print out messages you'd have to log them to a file. For example: - import core.sys.windows.windows; import std.stdio; extern(Windows) HWND GetConsoleWindow(); void main() {

Re: Getting core.exception.OutOfMemoryError error on allocating large arrays

2013-08-18 Thread John Colvin
On Sunday, 18 August 2013 at 12:40:42 UTC, zorran wrote: Interesting... What happens if you use core.memory.GC.malloc? enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); for(int i=0; i Well that proves malloc is actually allocating the memory. I'd say fi

Re: Getting core.exception.OutOfMemoryError error on allocating large arrays

2013-08-18 Thread zorran
On Sunday, 18 August 2013 at 12:40:42 UTC, zorran wrote: Interesting... What happens if you use core.memory.GC.malloc? i am using in sample import std.c.stdlib; GC.malloc also written core.exception.OutOfMemoryError

Re: Getting core.exception.OutOfMemoryError error on allocating large arrays

2013-08-18 Thread zorran
Interesting... What happens if you use core.memory.GC.malloc? enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); for(int i=0; i

Re: Getting core.exception.OutOfMemoryError error on allocating large arrays

2013-08-18 Thread John Colvin
On Sunday, 18 August 2013 at 12:07:02 UTC, zorran wrote: on my machine (core i7, 16 gb ram, win7/64) next code written core.exception.OutOfMemoryError: enum long size= 1300_000_000; auto arr = new byte[size]; but next code work fine: enum long size= 1300_000_000; byte * p = cast(

Re: Getting core.exception.OutOfMemoryError error on allocating large arrays

2013-08-18 Thread zorran
on my machine (core i7, 16 gb ram, win7/64) next code written core.exception.OutOfMemoryError: enum long size= 1300_000_000; auto arr = new byte[size]; but next code work fine: enum long size= 1300_000_000; byte * p = cast(byte *) malloc(size); i compiled in 64 bi

Re: scoped imports

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 2:31 AM, Joseph Rushton Wakeling < joseph.wakel...@webdrake.net> wrote: > On Sunday, 18 August 2013 at 01:33:51 UTC, Timothee Cour wrote: > >> that's not DRY: in my use case, a group of functions use certain imports, >> it would be annoying and not DRY to do that. What I su

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
and this: auto tupleFields(T)()if(isTuple!T){ string[T.length]ret; foreach(i;Iota!(T.length)) ret[i]=tupleField!(T,i); return ret; } unittest{ import std.typecons; auto t=Tuple!(int,"foo",double,"bar")(2,3.4); alias T=typeof(t); static assert(tupleFields!T==["foo","bar"]); } On

Re: scoped imports

2013-08-18 Thread Joseph Rushton Wakeling
On Sunday, 18 August 2013 at 01:33:51 UTC, Timothee Cour wrote: that's not DRY: in my use case, a group of functions use certain imports, it would be annoying and not DRY to do that. What I suggest (allowing {} grouping at module scope) seems simple and intuitive; any reason it can't be done?

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
On Sun, Aug 18, 2013 at 2:15 AM, John Colvin wrote: > On Sunday, 18 August 2013 at 08:46:17 UTC, Timothee Cour wrote: > >> A) >> how do I get the ith field of a std.typecons.Tuple ? >> ideally, it should be as simple as: >> >> auto t=Tuple!(int,"name",double,"**name2")(1); >> static assert(t.fiel

Re: how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread John Colvin
On Sunday, 18 August 2013 at 08:46:17 UTC, Timothee Cour wrote: A) how do I get the ith field of a std.typecons.Tuple ? ideally, it should be as simple as: auto t=Tuple!(int,"name",double,"name2")(1); static assert(t.fields[0] == "name"); field is the old name for expand, retained for compatib

how do I get the ith field of a std.typecons.Tuple ?

2013-08-18 Thread Timothee Cour
A) how do I get the ith field of a std.typecons.Tuple ? ideally, it should be as simple as: auto t=Tuple!(int,"name",double,"name2")(1); static assert(t.fields[0] == "name"); It seems the necessary items are private, so how do I get the ith field of a std.typecons.Tuple ? I really don't want to p

Re: how to get enclosing function as symbol ? (eg: __function__.stringof ==__FUNCTION__)

2013-08-18 Thread Nicolas Sicard
On Sunday, 18 August 2013 at 02:50:32 UTC, JS wrote: On Sunday, 18 August 2013 at 01:52:50 UTC, Timothee Cour wrote: Is there any way to get the enclosing function as symbol ? I'd like something like that: alternative names would be: __function__ __context__ auto fun(alias caller=__functi