Re: template - aliasing a member function

2012-08-08 Thread Philippe Sigaud
On Thu, Aug 9, 2012 at 2:00 AM, Ellery Newcomer wrote: > Awesome, thanks. > > And to make this work with property functions (which is my real target > case): > > pragma(msg, FunctionTypeOf!(Overloads[0])); // prints @property int() > pragma(msg, FunctionTypeOf!(Overloads[1])); // prints

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Thu, Aug 9, 2012 at 1:26 AM, Kenji Hara wrote: > You can also use slice operator instead of expand property. > > import std.stdio, std.typecons; > > void f(T ...)(T t) { > writeln(t.length); > } > > void main(){ > > auto v = tuple(1, 2, 3); > f(v[]); // prints 3 I didn't know tha

Re: Features of D to Emphasize for Academic Journal

2012-08-08 Thread Jonathan M Davis
On Thursday, August 09, 2012 03:35:38 TJB wrote: > Hello D Users, > > The Software Editor for the Journal of Applied Econometrics has > agreed to let me write a review of the D programming language for > econometricians. I will have only about 6 pages. I have an idea > of what I am going to say, b

Features of D to Emphasize for Academic Journal

2012-08-08 Thread TJB
Hello D Users, The Software Editor for the Journal of Applied Econometrics has agreed to let me write a review of the D programming language for econometricians. I will have only about 6 pages. I have an idea of what I am going to say, but I thought I would ask here what features are most r

Re: template - aliasing a member function

2012-08-08 Thread Ellery Newcomer
On 08/08/2012 04:37 PM, Kenji Hara wrote: import std.typetuple : TypeTuple; template Id(alias a) { alias a Id; } template T(alias fn) { alias Id!(__traits(parent, fn)) Parent; // use Id template so we cannot alias __traits result directly static assert(is(Parent == Foo)); e

Re: enum string

2012-08-08 Thread Jonathan M Davis
On Thursday, August 09, 2012 01:21:29 Namespace wrote: > And why ends my compilation with this error? You're going to need to build both druntime and Phobos if you want to build Phobos. I don't know what's in the zip file, since I haven't used it in ages, so I don't know if you can build them fr

Re: template - aliasing a member function

2012-08-08 Thread Ellery Newcomer
On 08/08/2012 04:21 PM, Ellery Newcomer wrote: mangleof looks promising.. .. or maybe not. wtf? template Z(string s) { pragma(msg, "fn.mangleof 2: " ~ s); } struct S(alias fn, string prop) { pragma(msg, "fn.mangleof 1: " ~ fn.mangleof); alias Z!(fn.mangleof) F; } class Foo{ @p

Re: template - aliasing a member function

2012-08-08 Thread Kenji Hara
On Wednesday, 8 August 2012 at 23:21:32 UTC, Ellery Newcomer wrote: say I have template T(alias fn) { } class Foo { int i(); void i(int); } alias T!(Foo.i) Biz; Is there a way to get a handle to both of the overloads of Foo.i inside T? Actually, all I really need for that is to get 'Fo

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Kenji Hara
On Tuesday, 7 August 2012 at 16:11:05 UTC, Andrej Mitrovic wrote: On 8/7/12, "Øivind" wrote: How can I call this function with an already-constructed tuple but pass the pule as an expressiontuple? auto v = tuple(1, 2, 3); f(v); Use the .expand property: f(v.expand) You can also use slice o

template - aliasing a member function

2012-08-08 Thread Ellery Newcomer
say I have template T(alias fn) { } class Foo { int i(); void i(int); } alias T!(Foo.i) Biz; Is there a way to get a handle to both of the overloads of Foo.i inside T? Actually, all I really need for that is to get 'Foo.i' out of fn. mangleof looks promising..

Re: enum string

2012-08-08 Thread Namespace
And why ends my compilation with this error? To cast any Token is _very_ annoying. -.-

Re: DWiki tables

2012-08-08 Thread Andrej Mitrovic
On 8/8/12, Justin C Calvarese wrote: > Try editing this page: > http://prowiki.org/wiki4d/wiki.cgi?dTemplate > > (I think it's determined by the "TemplateFile" setting at > http://prowiki.org/wiki4d/wiki.cgi?Context.) Thanks, that did it.

Re: enum string

2012-08-08 Thread Jonathan M Davis
On Wednesday, August 08, 2012 21:21:38 Namespace wrote: > Quick question: I've asked that for some time: why is it > std.stdio and not std.io? I don't remember. Probably because it's stdio.h in C/C++. But Steven Schveighoffer is working on a replacement for it which will probably be named std.io

Re: Daemon Threads

2012-08-08 Thread David
Am 08.08.2012 20:26, schrieb Sean Kelly: On Aug 8, 2012, at 8:33 AM, David wrote: Yes, but remember that the main thread doesn't die the moment the app's main() function returns. There's some runtime shutdown code that's run first. See druntime/rt/dmain2.d. So in my case, the main thread

Re: overloading a function taking a void[][]

2012-08-08 Thread Timon Gehr
On 08/08/2012 09:11 PM, Johannes Pfau wrote: Am Wed, 08 Aug 2012 18:53:05 +0200 schrieb Timon Gehr: Try this: template digest(Hash) if(isDigest!Hash){ digestType!Hash digest(Range)(Range data) if(!is(Range:void[][])&& isInputRange!Range&& __traits(compiles,digest!Hash(ElementType!(Ran

Re: thread exceptions

2012-08-08 Thread Ali Çehreli
On 08/08/2012 12:44 PM, Martin Krejcirik wrote: > Easy, just catch Throwable :-) The problem is, Error (and Throwable) should not be caught. There is no guarantee of program behavior when an Error is thrown. At the least, an AssertError is by definition pointing at bad program state so no furt

Re: thread exceptions

2012-08-08 Thread Martin Krejcirik
On 8.8.2012 18:15, Ali Çehreli wrote: > } catch (shared(Exception) exc) { > owner.send(exc); Ahh shared, I've been trying immutable and such. Thanks a lot. > > Although, I've been bitten by the fact that AssertError is not an > Exception, so exceptions thrown

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Wed, Aug 8, 2012 at 7:45 PM, Andrej Mitrovic wrote: > On 8/8/12, Philippe Sigaud wrote: >> Hey, every time I do something like that, you ask me to put it in my >> template tutorial ;) > > Well yeah, we don't want a future Banana(tm) company patenting our > codez, we need prior art! :p > > So m

Re: enum string

2012-08-08 Thread Namespace
I really wouldn't advise grabbing single files like that. The release was recent enough that it may be okay, but in general, that's just asking for trouble - especially with something as integral as std.traits. But if you really want to, this is the relevant pull request: https://github.com/D-

Re: overloading a function taking a void[][]

2012-08-08 Thread Johannes Pfau
Am Wed, 08 Aug 2012 18:53:05 +0200 schrieb Timon Gehr : > Try this: > > template digest(Hash) if(isDigest!Hash){ > digestType!Hash digest(Range)(Range data) > if(!is(Range:void[][]) && isInputRange!Range && > __traits(compiles,digest!Hash(ElementType!(Range).init))){ > //impl

Re: DWiki tables

2012-08-08 Thread Justin C Calvarese
On Wednesday, 8 August 2012 at 18:50:52 UTC, Jesse Phillips wrote: On Wednesday, 8 August 2012 at 17:50:42 UTC, Andrej Mitrovic wrote: I've asked this before about editing the front-page but I can't find the topic anymore. I think this page: http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/Starti

Re: DWiki tables

2012-08-08 Thread Jesse Phillips
On Wednesday, 8 August 2012 at 17:50:42 UTC, Andrej Mitrovic wrote: I've asked this before about editing the front-page but I can't find the topic anymore. I think this page: http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/StartingWithD/Compiler should be added under the "Development" section, na

Re: Daemon Threads

2012-08-08 Thread Sean Kelly
On Aug 8, 2012, at 8:33 AM, David wrote: >> Yes, but remember that the main thread doesn't die the moment the app's >> main() function returns. There's some runtime shutdown code that's run >> first. See druntime/rt/dmain2.d. > > So in my case, the main thread hangs up in the runtime? great

Re: enum string

2012-08-08 Thread Jonathan M Davis
On Wednesday, August 08, 2012 17:58:17 Namespace wrote: > On Tuesday, 7 August 2012 at 18:31:41 UTC, Jonathan M Davis wrote: > > On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote: > >> isSomeString!T regression? See enum & std.traits topic in d.D. > >> Seems like it will work again in 2.0

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Andrej Mitrovic
On 8/8/12, Philippe Sigaud wrote: > Hey, every time I do something like that, you ask me to put it in my > template tutorial ;) Well yeah, we don't want a future Banana(tm) company patenting our codez, we need prior art! :p So maybe it's not book-worthy. Perhaps there should be a github repo wit

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Philippe Sigaud
On Wed, Aug 8, 2012 at 7:19 PM, Andrej Mitrovic wrote: > On 8/8/12, Philippe Sigaud wrote: >> Like this.. > > That's really cool. Could you put this in the DT book, along with your > previous sample? Good job btw! Thanks. Hey, every time I do something like that, you ask me to put it in my templ

Re: How to create TypeTuple/ExpressionTuple from tuple/tuples

2012-08-08 Thread Andrej Mitrovic
On 8/8/12, Philippe Sigaud wrote: > Like this.. That's really cool. Could you put this in the DT book, along with your previous sample? Good job btw!

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 22:21, Ali Çehreli пишет: I looked at its online documentation: count is also an array that tells the lengths of individual rows of indices, right? So in reality the data is a dynamic ragged array? (I've never used that function before.) Yes, it is. > If I declare indices like

Re: ctRegex - named submatch

2012-08-08 Thread Dmitry Olshansky
On 08-Aug-12 02:05, Daniel wrote: On Tuesday, 7 August 2012 at 20:51:28 UTC, Dmitry Olshansky wrote: That all being said experimental tag on ctRegex in DDoc is here for a reason, and that is: ctRegex can't compile nor match full regex testsuite. Understood, thanks for your quick response never

Re: overloading a function taking a void[][]

2012-08-08 Thread Timon Gehr
Try this: template digest(Hash) if(isDigest!Hash){ digestType!Hash digest(Range)(Range data) if(!is(Range:void[][]) && isInputRange!Range && __traits(compiles,digest!Hash(ElementType!(Range).init))){ //implementation detail } digestType!Hash digest()(scope const(void[

Re: Is this a std.regex bug?

2012-08-08 Thread Dmitry Olshansky
On 08-Aug-12 11:28, Andrea Fontana wrote: import std.regex; void main() { auto r = ctRegex!(r"/a/b/(c|d|e|f)", "g"); } This simple app fails at compile time. ( it's not that simple ;) ) But it's "been there, seen that". In short: assert(this.ir[cast(ulong)orStart].code() == cast(IR)129

overloading a function taking a void[][]

2012-08-08 Thread Johannes Pfau
I wanted to add a new overload to digest for the std.hash module (see review in main newsgroup). This is the code written as two functions which should be combined in one overloaded function digestType!Hash digest(Hash)(scope const(void[])[] data...) if(isDigest!Hash) { //

Re: Error: SIMD vector types not supported on this platform

2012-08-08 Thread ixid
That'll be it, yes I am using Windows.

Re: thread exceptions

2012-08-08 Thread Ali Çehreli
On 08/08/2012 01:52 AM, Martin Krejcirik wrote: > I meant how can I print the actual exception from the thread, including > it's error message, stack trace etc. Catching the exception explicitly and rethrowing would help a little: // ... at the worker ... try {

Re: Why __traits(compile,...) fails here?

2012-08-08 Thread Simen Kjaeraas
On Wed, 08 Aug 2012 11:13:30 +0200, Timon Gehr wrote: Yes, but note that this distinction does not make any sense. alias int Int; // works isType!Int // 'Int' is clearly a symbol, yet the instantiation fails. I'm not sure it is 'clearly' a symbol. To the compiler, there is no difference bet

Re: Error: SIMD vector types not supported on this platform

2012-08-08 Thread Simen Kjaeraas
On Wed, 08 Aug 2012 15:46:23 +0200, ixid wrote: I'm using the recently released DMD2 version 2.060. SIMD operations are not supported for Windows at the moment, I think. Of course, if you're running Linux, ignore this answer. -- Simen

Re: enum string

2012-08-08 Thread Namespace
On Tuesday, 7 August 2012 at 18:31:41 UTC, Jonathan M Davis wrote: On Tuesday, August 07, 2012 21:14:00 Dmitry Olshansky wrote: isSomeString!T regression? See enum & std.traits topic in d.D. Seems like it will work again in 2.061... Yeah. In 2.060, std.traits doesn't treat enums as their base

Re: Why __traits(compile,...) fails here?

2012-08-08 Thread Philippe Sigaud
On Wed, Aug 8, 2012 at 11:13 AM, Timon Gehr wrote: > Yes, but note that this distinction does not make any sense. > > alias int Int; // works > > isType!Int // 'Int' is clearly a symbol, yet the instantiation fails. > > alias declarations should just accept built-in types. If someone for > some o

Re: Daemon Threads

2012-08-08 Thread David
Yes, but remember that the main thread doesn't die the moment the app's main() function returns. There's some runtime shutdown code that's run first. See druntime/rt/dmain2.d. So in my case, the main thread hangs up in the runtime? great …

Re: thread exceptions

2012-08-08 Thread Sean Kelly
Oh, I should mention that if you use core.thread explicitly, any unhandled exception will be re-thrown in the context of whoever joins that thread. On Aug 8, 2012, at 1:52 AM, Martin Krejcirik wrote: > Hi Ali, > > On 8.8.2012 5:36, Ali Çehreli wrote: >> The OwnerTerminated and LinkTerminated

Re: thread exceptions

2012-08-08 Thread Sean Kelly
I'll have to think about it. The current approach in std.concurrency is intended to be forwards-compatible with interprocess messaging, and serializing/deserializing an arbitrary exception would be tricky. See the exception thrown by receiveOnly as an example of how I addressed the issue there.

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Ali Çehreli
On 08/08/2012 07:12 AM, Alexandr Druzhinin wrote: > 08.08.2012 16:29, bearophile пишет: >>> That C code doesn't look correct, because the given data contains no >>> pointers. >> >> But this C code compiles: >> >> >> void foo(const void** data) {} >> int data[2][3]; >> int main() { >> foo(data); >>

Re: two-dimensional C array and its analog in D

2012-08-08 Thread BLM768
I mean that I call C function from D code. And C function takes void** pointer as its argument. In C this means array of array, but if I pass D two-dimensional array it doesn't work (but compiles). I'm pretty sure that the issue is D's internal implementation of 2-dimensional arrays. From w

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 12:13, Ali Çehreli пишет: This seems to work: import std.stdio; void main() { enum M = 3; enum N = 4; int[M][N] data; data[0][0] = 42; writeln(data); } The output: [[42, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] Ali I mean that I call C function from D

Re: two-dimensional C array and its analog in D

2012-08-08 Thread Alexandr Druzhinin
08.08.2012 16:29, bearophile пишет: That C code doesn't look correct, because the given data contains no pointers. But this C code compiles: void foo(const void** data) {} int data[2][3]; int main() { foo(data); return 0; } Bye, bearophile As I know in C an array is equal to pointer,

Error: SIMD vector types not supported on this platform

2012-08-08 Thread ixid
Which SSE version is required? My processor is a Core2Duo with SSE2 and is apparently not supported. Surely a mainstream version with an older version of SSE should be able to use the sub-set of SSE instructions it supports?

Re: Error: SIMD vector types not supported on this platform

2012-08-08 Thread ixid
I'm using the recently released DMD2 version 2.060.

Re: Function that calculates in compile time when it can

2012-08-08 Thread Artur Skawina
On 08/07/12 19:43, Marco Leise wrote: > Am Mon, 06 Aug 2012 14:21:37 +0200 > schrieb "Minas Mina" : > >> I want to write a fibonacci(n) function that calculates the >> result. >> a) if n is known at compile time, use a template >> b) if not, use a normal function >> >> I know how to write a templ

Re: two-dimensional C array and its analog in D

2012-08-08 Thread bearophile
That C code doesn't look correct, because the given data contains no pointers. But this C code compiles: void foo(const void** data) {} int data[2][3]; int main() { foo(data); return 0; } Bye, bearophile

Re: Why __traits(compile,...) fails here?

2012-08-08 Thread Timon Gehr
On 08/07/2012 03:52 PM, Philippe Sigaud wrote: On Tue, Aug 7, 2012 at 12:42 PM, Zhenya wrote: Template alias parameters do not accept built-in types. The trick is: - A template type parameter (like (T)) recognizes types - A template alias parameter(like (alias a)) recognizes names, symbols.

Re: thread exceptions

2012-08-08 Thread Martin Krejcirik
Hi Ali, On 8.8.2012 5:36, Ali Çehreli wrote: > The OwnerTerminated and LinkTerminated exceptions can be received as > messages as well. The following code demonstrates this for the > OwnerTerminated exception: I meant how can I print the actual exception from the thread, including it's error mess

Re: two-dimensional C array and its analog in D

2012-08-08 Thread bearophile
Alexandr Druzhinin: there is the following C function: void foo(const void** data); in C I can do: int data[N][M]; data[0][0] = ..; data[0][1] = ..; data[1][0] = ..; data[1][1] = ..; foo(data); // for C code it works and in D code it doesn't (compile, but do nothing) That C code doesn't

Re: Is this a std.regex bug?

2012-08-08 Thread Andrea Fontana
import std.regex; void main() { auto r = ctRegex!(r"/a/b/(c|d|e|f)", "g"); } This simple app fails at compile time. Online compiler says: /usr/local/include/dmd2/std/regex.d(1150): Error: assert(this.ir[cast(ulong)orStart].code() == cast(IR)129u) failed /usr/local/include/dmd2/std/regex.d(8