Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Ali Çehreli via Digitalmars-d-learn
On 06/13/2014 10:29 PM, Meta wrote: I thought this was possible, but DMD 2.065 doesn't allow it, saying no constructor for int: int* p = new int(3); Is something like this planned for the future? I know we can already do: int n = int(3); Those both compile with 2.066 Ali

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Meta via Digitalmars-d-learn
On Saturday, 14 June 2014 at 06:39:56 UTC, Ali Çehreli wrote: On 06/13/2014 10:29 PM, Meta wrote: I thought this was possible, but DMD 2.065 doesn't allow it, saying no constructor for int: int* p = new int(3); Is something like this planned for the future? I know we can already do: int n

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Philippe Sigaud via Digitalmars-d-learn
Would auto i = (int*)(3); make sense? Does it work?

Re: Does __gshared have shared semantics?

2014-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 14 Jun 2014 01:24:03 + Mike Franklin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In other words, is 'shared __gshared' redundant? Redundant? Not exactly. __gshared makes it so that the variable is treated like a C variable - it's not in TLS - but its _type_ is

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread via Digitalmars-d-learn
On Saturday, 14 June 2014 at 08:09:12 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: Would auto i = (int*)(3); make sense? Does it work? No: Error: C style cast illegal, use cast(int*)3 And I don't think it should, because the heap allocation that you're probably expecting should be

Re: Why is stdin.byLine.writeln so slow?

2014-06-14 Thread via Digitalmars-d-learn
On Friday, 13 June 2014 at 22:12:01 UTC, Ali Çehreli wrote: On 06/13/2014 03:02 PM, monarch_dodra wrote: No, it just receives a range, so it does range formating. eg: [ ~ Element ~ , ~ Element ... ]. It still looks like it could send the formatting characters as well as the elements

Re: DMD Fails with fPIC error

2014-06-14 Thread Mike Wey via Digitalmars-d-learn
On 06/14/2014 03:58 AM, Reuben wrote: Hi, I'm new to D and am trying to compile a simple hello world program. I get the following error when compiling it: dmd test.d /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld:

Re: Casts and @trusted

2014-06-14 Thread Anonymous via Digitalmars-d-learn
That really is it. The other methods are just other gets to the buffer, like this: T[] get_dup(TS strat=TS.cyclic)(size_t n) const { static if (strat==TS.once) size_t numreads = fixNToFill(n); else size_t numreads = n; auto ret = new T[](numreads);

Subclass of Exception

2014-06-14 Thread Paul via Digitalmars-d-learn
One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception { this(string msg) { super(msg); } } (without constructor we get error: ...Cannot implicitly generate a

Re: DMD Fails with fPIC error

2014-06-14 Thread Reuben via Digitalmars-d-learn
On Saturday, 14 June 2014 at 10:45:25 UTC, Mike Wey wrote: On 06/14/2014 03:58 AM, Reuben wrote: Hi, I'm new to D and am trying to compile a simple hello world program. I get the following error when compiling it: dmd test.d

Re: Universal Construction Syntax for Pointers?

2014-06-14 Thread Philippe Sigaud via Digitalmars-d-learn
And I don't think it should, because the heap allocation that you're probably expecting should be explicit IMO. For me it's also unintuitive, because I would read it as constructing a pointer that points to the address 3. I agree. I'm trying to get a feel on the limits of this new

Re: Subclass of Exception

2014-06-14 Thread bearophile via Digitalmars-d-learn
Paul: class MyError : Exception { this(string msg) { super(msg); } } Don't call exceptions errors, because in D there are also errors, so they should have distinct names. Is any shorter D way? Perhaps not. Bye, bearophile

Re: Subclass of Exception

2014-06-14 Thread FreeSlave via Digitalmars-d-learn
On Saturday, 14 June 2014 at 11:59:53 UTC, Paul wrote: One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception { this(string msg) { super(msg); } } (without

Re: Subclass of Exception

2014-06-14 Thread Paul via Digitalmars-d-learn
On Saturday, 14 June 2014 at 12:17:46 UTC, FreeSlave wrote: On Saturday, 14 June 2014 at 11:59:53 UTC, Paul wrote: One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception {

Re: DMD Fails with fPIC error

2014-06-14 Thread Mike Wey via Digitalmars-d-learn
On 06/14/2014 02:01 PM, Reuben wrote: On Saturday, 14 June 2014 at 10:45:25 UTC, Mike Wey wrote: On 06/14/2014 03:58 AM, Reuben wrote: Depending on the desired behavior you'll need to remove the -shared flag from the configuration or add -defaultlib=:libphobos2.so dmd.conf contains the

Re: Returning dynamic array from the function

2014-06-14 Thread Marco Cosentino via Digitalmars-d-learn
Hi, I'm new to D and stumbled upon this very interesting discussion. My question now is: can you provide an example of how to return a collection of homogeneous elements whose size is not known at compile time (for wich you would normally use a dynamic array) from a function? Thanks, Marco

Is it normal that unittests of phobos are executed with my project build?

2014-06-14 Thread Xavier Bigand via Digitalmars-d-learn
I get a failure on a test in format.d when I build my own project with unittest. I though importing phobos header would not regenerate their unittest modules. Any idea of what can cause this issue? I already have reinstalled dmd with visualD completely.

Re: DMD Fails with fPIC error

2014-06-14 Thread Reuben via Digitalmars-d-learn
On Saturday, 14 June 2014 at 13:05:52 UTC, Mike Wey wrote: On 06/14/2014 02:01 PM, Reuben wrote: On Saturday, 14 June 2014 at 10:45:25 UTC, Mike Wey wrote: On 06/14/2014 03:58 AM, Reuben wrote: Depending on the desired behavior you'll need to remove the -shared flag from the configuration

Re: Returning dynamic array from the function

2014-06-14 Thread via Digitalmars-d-learn
On Saturday, 14 June 2014 at 14:02:52 UTC, Marco Cosentino wrote: Hi, I'm new to D and stumbled upon this very interesting discussion. My question now is: can you provide an example of how to return a collection of homogeneous elements whose size is not known at compile time (for wich you

Re: hijacking override from template mixin

2014-06-14 Thread sigod via Digitalmars-d-learn
On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote: I'd expect a multiple overrides of same function error, much like if I just paste the mixin code by hand. Is that a bug or working by design? In the latter case, please explain the reasoning. http://dlang.org/template-mixin.html

Re: Returning dynamic array from the function

2014-06-14 Thread Marco Cosentino via Digitalmars-d-learn
int[] data = [1,2,3,4];// create new array on the heap Thanks for the answer. This is the bit of information I was missing: how to create an array in the heap. Is also this a valid way to do so? int[] data = new int[0]; data ~= [4,2,3,1];

Re: Returning dynamic array from the function

2014-06-14 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 14 June 2014 at 21:37:51 UTC, Marco Cosentino wrote: int[] data = [1,2,3,4];// create new array on the heap Thanks for the answer. This is the bit of information I was missing: how to create an array in the heap. Is also this a valid way to do so? int[] data = new

Re: Subclass of Exception

2014-06-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Sat, 14 Jun 2014 11:59:52 + Paul via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: One stupid question: in Python subclassing of Exception looks like: class MyError(Exception): pass but in D, if I'm right, we should write more code: class MyError : Exception {

what is going on with cgcs.c:351?

2014-06-14 Thread Vlad Levenfeld via Digitalmars-d-learn
I've bumped up against this cryptic error from time to time. I can't really pin it down to a simple self contained example as it tends to come up when I try to have template-heavy modules interact and there is a lot to untangle. I can't see the pattern in my code that triggers the assertion

Re: what is going on with cgcs.c:351?

2014-06-14 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jun 15, 2014 at 04:44:06AM +, Vlad Levenfeld via Digitalmars-d-learn wrote: I've bumped up against this cryptic error from time to time. I can't really pin it down to a simple self contained example as it tends to come up when I try to have template-heavy modules interact and there

Re: what is going on with cgcs.c:351?

2014-06-14 Thread Vlad Levenfeld via Digitalmars-d-learn
Update and clarification: this triggers the error: flight_info.add (Plot (ts.zip (vs), gfx, txt) .color (blue*white) .title (`velocity`) , square (0.15) ); this compiles: flight_info.add (Plot (ts.zip (vs), gfx, txt), square (0.15)); this also compiles: auto plot = Plot

Re: what is going on with cgcs.c:351?

2014-06-14 Thread Vlad Levenfeld via Digitalmars-d-learn
I had not heard of this tool before. This looks like it's going to be very handy, thank you!

Re: what is going on with cgcs.c:351?

2014-06-14 Thread Vlad Levenfeld via Digitalmars-d-learn
I'd also like to note that elsewhere in my code (in a unittest to be precise), I am using the full functionality of the Plot struct with no hiccups... info.add ( Plot (ℕ!24.map!(i = 0.8*i) .map!(x = τ(x, sin (x^^2))), gfx, txt) .title (`testing`)