Re: Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Jacob Carlborg
On 2013-09-03 23:32, Adam D. Ruppe wrote: How do I keep missing these new std.traits things? Very nice. Because they just magically shows up :) -- /Jacob Carlborg

Re: TDPL, std.concurrency and OwnerFailed

2013-09-03 Thread Alexandr Druzhinin
04.09.2013 0:58, Ali Çehreli пишет: One way is, the child can send a special message (even the exception itself) when it terminates: // ... at the worker ... try { // ... } catch (shared(Exception) exc) { owner.send(exc

Defining inout returned values for ranges

2013-09-03 Thread Jonathan Crapuchettes
If a range struct (Range) is defined inside another struct (Test), how can the constness or mutability of Test be attributed to the return type of Range.front? I'm running into this problem because I need the range to be iterated, but I need the pointer in T to be marked const when appropriate.

Re: schwartzSort with a const key

2013-09-03 Thread bearophile
H. S. Teoh: I filed a new issue just in case: http://d.puremagic.com/issues/show_bug.cgi?id=10960 Thank you. But the idea of stripping away the const from copied values misses my main point, so I have added a note there. Bye, bearophile

Re: schwartzSort with a const key

2013-09-03 Thread Ali Çehreli
On 09/03/2013 03:22 PM, bearophile wrote: > Currently this code doesn't work, because the B array is const, so B[i] > is const: > > > import std.algorithm: schwartzSort; > void main() { > auto A = [0, 1, 2]; > const B = [10, -20, 30]; > schwartzSort!(i => B[i])(A); The return type

Re: schwartzSort with a const key

2013-09-03 Thread H. S. Teoh
On Tue, Sep 03, 2013 at 03:57:09PM -0700, Ali Çehreli wrote: > On 09/03/2013 03:22 PM, bearophile wrote: > > > Currently this code doesn't work, because the B array is const, so B[i] > > is const: > > > > > > import std.algorithm: schwartzSort; > > void main() { > > auto A = [0, 1, 2]; > >

schwartzSort with a const key

2013-09-03 Thread bearophile
Currently this code doesn't work, because the B array is const, so B[i] is const: import std.algorithm: schwartzSort; void main() { auto A = [0, 1, 2]; const B = [10, -20, 30]; schwartzSort!(i => B[i])(A); } dmd gives: ...\dmd2\src\phobos\std\conv.d(3734): Error: static assert

Re: Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Adam D. Ruppe
On Tuesday, 3 September 2013 at 21:20:04 UTC, Andrej Mitrovic wrote: foreach (id; ParameterIdentifierTuple!func) How do I keep missing these new std.traits things? Very nice.

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: > is supposed to transform one delegate into another Then please declare the template parameters to be delegates: U muddle( T, U)( T f) { uint g( int fp){ return cast(uint)( 5* f( fp)); } auto gP= &g; return gP; } unittest {

Re: Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Andrej Mitrovic
On 9/3/13, Gary Willoughby wrote: > Using traits how do i get a methods's parameters as a string? Say > i have the following method: Here's a first attempt: - import std.range; import std.string; import std.stdio; import std.traits; class C { void setAge(int age, int) { } } tem

Re: Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Adam D. Ruppe
On Tuesday, 3 September 2013 at 21:01:27 UTC, Gary Willoughby wrote: Using traits how do i get a methods's parameters as a string? Say i have the following method: Use typeof(setAge).stringof to get something you can then parse to fet the names. My web.d has a function to do it: https://git

Using traits how do i get a function's parameters as a string?

2013-09-03 Thread Gary Willoughby
Using traits how do i get a methods's parameters as a string? Say i have the following method: ... public void setAge(int age) { this._age = age; } ... I want a string that is: "(int age)" or how ever many params there are. The nearest i got was using this code: ParameterTypeTuple!(__tra

Re: TDPL, std.concurrency and OwnerFailed

2013-09-03 Thread Ali Çehreli
On 09/03/2013 09:26 AM, Alexandr Druzhinin wrote: > OwnerFailed exception catching like TDPL says, but std.concurrency has > no such symbol. These are the ones that I am aware of at this time: MessageMismatch OwnerTerminated LinkTerminated MailboxFull PriorityMessageException > So, s

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: > Writing muddle!(int,int) [...] > gives the same error message. Not entirely true: template muddle( T, U...){ alias T delegate( U) Dptr; auto muddle1( T, U...)( Dptr f) { return f; //or make another delegate in real code } alias muddle1!( T, U) muddle; }

TDPL, std.concurrency and OwnerFailed

2013-09-03 Thread Alexandr Druzhinin
Hello I try to get known if daughter thread finished its work using OwnerFailed exception catching like TDPL says, but std.concurrency has no such symbol. So, something changed. Can somebody help me with this case - finding if a child thread finished/terminated? I know about spawnLinked, but I

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Carl Sturtivant
On Tuesday, 3 September 2013 at 13:42:44 UTC, Manfred Nowak wrote: Carl Sturtivant wrote: No it isn't according to dmd. dmd does not express this. according to p1.d(15): Error: [...] dmd "cannot deduce" that `Dptr!(T, U)' might be equal to `int delegate(int)' -manfred I understood that.

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: > How do I fix this? maybe it is currently not fixable because of restrictions in the deduction algorithm. Obviously the deduction works if the instantion of the template is replaced by a symbol by `alias T delegate( U) Dptr;' or similar. -manfred

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Manfred Nowak
Carl Sturtivant wrote: > No it isn't according to dmd. dmd does not express this. according to > p1.d(15): Error: [...] dmd "cannot deduce" that `Dptr!(T, U)' might be equal to `int delegate(int)' -manfred

Re: template instantiation --- having trouble therewith

2013-09-03 Thread Carl Sturtivant
I'm confused as to what you're trying to do... your example code is equivalent to import std.stdio; int x = 3; int scale( int s) { return x * s; } auto f = &scale; writeln( f(7) ); No it isn't according to dmd. My code is a minimal piece that produces the same error as some real

Re: template instantiation --- having trouble therewith

2013-09-03 Thread John Colvin
On Tuesday, 3 September 2013 at 03:49:52 UTC, Carl Sturtivant wrote: template Dptr( T, U...) { alias T delegate( U args) Dptr; } Dptr!(T,U) muddle( T, U...)( Dptr!(T,U) f) { return f; //or make another delegate in real code } unittest { import std.stdio; int x

Re: Pitfalls of delegates inside ranges

2013-09-03 Thread Sönke Ludwig
Am 02.09.2013 15:39, schrieb Artur Skawina: this(this) { jump.ptr = &this; } Just a warning: This can still easily crash due to D's struct move semantics. Structs are moved around sometimes without any postblit constructor or destructor being called, so fixing self-references like thi

Re: Relative imports and separate compilation

2013-09-03 Thread Atila Neves
I wouldn't mind so much if just "regularly" compiling, just do each file in turn. The problem is this how rdmd calls dmd and then things don't work as they should. On Saturday, 31 August 2013 at 12:06:00 UTC, Dicebot wrote: On Saturday, 31 August 2013 at 09:29:16 UTC, Atila Neves wrote: How

Re: Non-covariance and overrides

2013-09-03 Thread Jacob Carlborg
On 2013-09-02 17:00, Joseph Rushton Wakeling wrote: P.S. If I don't find a handy inheritance-based way to do this, what I'll probably do is something along the lines of, class MyFakeSubclass { MyBaseClass base; // ... extra data ... // ... manually-written