Re: std.typecons wrap interface with NVI

2014-02-01 Thread Jesse Phillips
On Sunday, 2 February 2014 at 01:19:22 UTC, Matthew Dudley wrote: This is the general outline of what I'm trying to do: import std.typecons; //wrap import std.stdio; interface FooBar { public: void foo(); void bar(); final void both() // NVI {

Re: std.typecons wrap interface with NVI

2014-02-01 Thread TheFlyingFiddle
On Sunday, 2 February 2014 at 01:19:22 UTC, Matthew Dudley wrote: This is the general outline of what I'm trying to do: import std.typecons; //wrap import std.stdio; interface FooBar { public: void foo(); void bar(); final void both() // NVI {

Re: Undefined identifier error with enum in the separate module

2014-02-01 Thread evilrat
On Saturday, 1 February 2014 at 21:00:18 UTC, Nemanja Borić wrote: Hello, I am having troubles to use the enum defined in the separate module. When I try to access it, I am getting "Undefined symbol" error: // CodeEnum.d enum CodeEnum { OK = 200, FAIL = 400 } unittest {

std.typecons wrap interface with NVI

2014-02-01 Thread Matthew Dudley
This is the general outline of what I'm trying to do: import std.typecons; //wrap import std.stdio; interface FooBar { public: void foo(); void bar(); final void both() // NVI { foo(); bar();

Re: Python calling D

2014-02-01 Thread Ellery Newcomer
On Saturday, 1 February 2014 at 22:02:24 UTC, Russel Winder wrote: My problem of the moment is segmentation faults during execution, and I have no model of how to go about providing useful data to debug this :-(( It wouldn't by any chance be related to https://bitbucket.org/ariovistus/pyd/i

Re: std.array.array broken?

2014-02-01 Thread Francesco Cattoglio
On Saturday, 1 February 2014 at 22:52:24 UTC, Andrej Mitrovic wrote: On Saturday, 1 February 2014 at 22:47:54 UTC, deed wrote: Docs also say: /** Note: Each $(D front) will not persist after $(D popFront) is called, so the caller must copy its contents (e.g. by calling $(D to!string)) if rete

Re: std.array.array broken?

2014-02-01 Thread deed
On Saturday, 1 February 2014 at 22:59:12 UTC, bearophile wrote: deed: auto lines = File(filename).byLine.array; writeln(lines); // Crap --- Beside the answers that others have already given you, another way to do that is to read the whole file (with read or readText) and then use splitlines

Re: std.array.array broken?

2014-02-01 Thread deed
On Saturday, 1 February 2014 at 22:52:24 UTC, Andrej Mitrovic wrote: On Saturday, 1 February 2014 at 22:47:54 UTC, deed wrote: Docs say: - std.stdio.byLine returns an input range - std.array.array takes an input range Docs also say: /** Note: Each $(D front) will not persist after $(D popFron

Re: std.array.array broken?

2014-02-01 Thread bearophile
deed: auto lines = File(filename).byLine.array; writeln(lines); // Crap --- Beside the answers that others have already given you, another way to do that is to read the whole file (with read or readText) and then use splitlines on the string. Bye, bearophile

Re: std.array.array broken?

2014-02-01 Thread Andrej Mitrovic
On Saturday, 1 February 2014 at 22:47:54 UTC, deed wrote: Docs say: - std.stdio.byLine returns an input range - std.array.array takes an input range Docs also say: /** Note: Each $(D front) will not persist after $(D popFront) is called, so the caller must copy its contents (e.g. by calling $(

std.array.array broken?

2014-02-01 Thread deed
--- import std.stdio; import std.array; auto lines = File(filename).byLine.array; writeln(lines); // Crap --- dmd 2.064(.2 I think) Docs say: - std.stdio.byLine returns an input range - std.array.array takes an input range

Re: Undefined identifier error with enum in the separate module

2014-02-01 Thread bearophile
Philippe Sigaud: In D, do not use the same symbol for a module and one of its inner symbols. I have seen other people hit this problem (like problems caused by having a "set.d" module containing a "Set" struct plus a "set" helper function). Is this worth warning against (with a dmd warning

Re: Python calling D

2014-02-01 Thread Russel Winder
On Sat, 2014-02-01 at 20:58 +, Ellery Newcomer wrote: > On Sunday, 26 January 2014 at 14:17:18 UTC, Russel Winder wrote: > > On Sun, 2014-01-26 at 12:11 +, Russel Winder wrote: > > […] > >> However with Python 2 the example from: > >> > >>https://bitbucket.org/ariovistus/pyd/wiki/Quick

Re: Implicit conversion from a base/array type

2014-02-01 Thread alexhairyman
On Sat, 01 Feb 2014 21:18:12 +, Martijn Pot wrote: > I tried something similar to (check first answer): > http://stackoverflow.com/questions/121162/what-does-the-explicit- keyword-in-c-mean > > but I can't get it to work. But then again... I'm just starting with D. > > It seems not to be sup

Re: Implicit conversion from a base/array type

2014-02-01 Thread alexhairyman
On Sat, 01 Feb 2014 21:23:07 +, TheFlyingFiddle wrote: > On Saturday, 1 February 2014 at 20:26:27 UTC, alexhairyman wrote: >> Is there a way to implicitly convert *FROM* a base type? I have an >> implicit conversion to a base type (float[2]) in a struct, but now I'd >> like to be able to impli

Re: Implicit conversion from a base/array type

2014-02-01 Thread TheFlyingFiddle
On Saturday, 1 February 2014 at 20:26:27 UTC, alexhairyman wrote: Is there a way to implicitly convert *FROM* a base type? I have an implicit conversion to a base type (float[2]) in a struct, but now I'd like to be able to implicitly convert from a base type (in this case a float[2]) to a struc

Re: Implicit conversion from a base/array type

2014-02-01 Thread Martijn Pot
I tried something similar to (check first answer): http://stackoverflow.com/questions/121162/what-does-the-explicit-keyword-in-c-mean but I can't get it to work. But then again... I'm just starting with D. It seems not to be supported: http://forum.dlang.org/thread/teddgvbtmrxumffrh...@forum.d

Re: Undefined identifier error with enum in the separate module

2014-02-01 Thread Philippe Sigaud
> // Reply.d > import CodeEnum; > > unittest > { > auto.e = CodeEnum.OK; // Error: undefined identifier 'OK' > } > > > What I am doing wrong? The module and your enum have the same name. When the compiler sees the `CodeEnum` symbol, it considers you're referring to the module. This module

Undefined identifier error with enum in the separate module

2014-02-01 Thread Nemanja Borić
Hello, I am having troubles to use the enum defined in the separate module. When I try to access it, I am getting "Undefined symbol" error: // CodeEnum.d enum CodeEnum { OK = 200, FAIL = 400 } unittest { auto e = CodeEnum.OK; // Works! } // Reply.d import CodeEnum;

Re: Python calling D

2014-02-01 Thread Ellery Newcomer
On Sunday, 26 January 2014 at 14:17:18 UTC, Russel Winder wrote: On Sun, 2014-01-26 at 12:11 +, Russel Winder wrote: […] However with Python 2 the example from: https://bitbucket.org/ariovistus/pyd/wiki/QuickStart leads to: This all sounds suspiciously like stuff I thought I'd alread

Re: Keywords: How to trick the compiler?

2014-02-01 Thread Marc Schütz
On Tuesday, 28 January 2014 at 22:50:27 UTC, Stanislav Blinov wrote: On Tuesday, 28 January 2014 at 22:35:31 UTC, Martin Cejp wrote: I really wonder whether the rule could be relaxed a little bit. o_O How? Not being a keyword except in places where it is used as such. Only if it's not a k

Implicit conversion from a base/array type

2014-02-01 Thread alexhairyman
Is there a way to implicitly convert *FROM* a base type? I have an implicit conversion to a base type (float[2]) in a struct, but now I'd like to be able to implicitly convert from a base type (in this case a float[2]) to a struct. Is this even allowed? Is it incorrect or unsafe? I'm still pre

Re: Parallel thread safety (fun fun)

2014-02-01 Thread Mineko
On Saturday, 1 February 2014 at 19:26:03 UTC, TheFlyingFiddle wrote: On Friday, 31 January 2014 at 21:33:50 UTC, Mineko wrote: So, I'm implementing some parallelism in my engine (maybe some concurrency where appropriate later), and I'm having some issues with thread safety, and synchronize ain'

Re: Parallel thread safety (fun fun)

2014-02-01 Thread TheFlyingFiddle
On Friday, 31 January 2014 at 21:33:50 UTC, Mineko wrote: So, I'm implementing some parallelism in my engine (maybe some concurrency where appropriate later), and I'm having some issues with thread safety, and synchronize ain't cutting it. What I figure is that if I can get the IO class workin

Re: mixin template

2014-02-01 Thread Jesse Phillips
On Tuesday, 28 January 2014 at 06:35:52 UTC, Dan Killebrew wrote: Found this: http://forum.dlang.org/thread/ntuysfcivhbphnhnn...@forum.dlang.org#post-mailman.1409.1339356130.24740.digitalmars-d-learn:40puremagic.com If what Jonathan says is true, then http://dlang.org/template-mixin.html shoul

Re: Memory leak in hello world

2014-02-01 Thread Kagamin
thread_attachThis creates an instance of Thread class for the main process thread during runtime initialization: https://github.com/D-Programming-Language/druntime/blob/master/src/core/thread.d#L1792 oops, no, there's no malloc there.

Re: Memory leak in hello world

2014-02-01 Thread Kagamin
But still it must be allocated somehow, probably GC is substituted for C heap.

Re: Memory leak in hello world

2014-02-01 Thread Kagamin
On Monday, 27 January 2014 at 09:44:50 UTC, Thejaswi Puthraya wrote: ==11356== 16 bytes in 1 blocks are definitely lost in loss record 1 of 2 ==11356==at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==11356==by 0x43E366: thread_attachThis (in /home/theju/