Re: Friends?

2012-10-18 Thread Jacob Carlborg
On 2012-10-18 20:51, Philippe Sigaud wrote: I mean, the 'package' access modifier. So did I. class Foo { package void foo () {} } Would, according to the spec, imply a virtual method. But as Jonathan said, this is a bug in the spec. -- /Jacob Carlborg

Re: optlink and weak symbols

2012-10-18 Thread Jacob Carlborg
On 2012-10-19 02:30, Ellery Newcomer wrote: extern(C) extern export PyTypeObject PyType_Type; seems to do the trick (I'm using a boiled down case just now)! High five to the [non-me] non-windows dev! Hehe, high five :) -- /Jacob Carlborg

Re: opCast using in template struct

2012-10-18 Thread Era Scarecrow
On Thursday, 18 October 2012 at 23:51:44 UTC, Timon Gehr wrote: If the issue _is_ with the signature, then the compiler should tell you. That is the (secondary) job of the compiler. But not everything is parsed/compiled if it doesn't match the constraints, especially template functions. Somet

Re: Implicit Conversions in Struct Construction

2012-10-18 Thread Jonathan M Davis
On Thursday, October 18, 2012 20:55:12 Ali Çehreli wrote: > Explicit conversion works: > > return Fib(T(0), T(1)); Except that that won't work for int or other built-in types, because they lack constructors. What you need is std.conv.to. - Jonathan M Davis

Re: Implicit Conversions in Struct Construction

2012-10-18 Thread Jonathan M Davis
On Friday, October 19, 2012 05:44:10 Michael wrote: > Hello, >I have been playing around with templated range. I am not quite > sure why the following code does not work: > > template isIntLike(T) { > enum isIntLike = is(typeof({ > T t = 0; > t = t+t; >

Implicit Conversions in Struct Construction

2012-10-18 Thread Michael
Hello, I have been playing around with templated range. I am not quite sure why the following code does not work: template isIntLike(T) { enum isIntLike = is(typeof({ T t = 0; t = t+t; // More if needed })); } auto fib(T = int)(

Re: Problem with UFCS

2012-10-18 Thread Michael
Thank you guys. I can't believe that haven't thought of that. I still feel that this is rather odd though. I would expect to be able to use UFCS in the scope that imports those libraries. Though I can definitely see how that might lead to obscure bugs. On Tuesday, 16 October 2012 at 17:07:36 U

Re: Friends?

2012-10-18 Thread Jeremy DeHaan
On Thursday, 18 October 2012 at 20:44:42 UTC, Jonathan M Davis wrote: Does it work? I thought it was not implemented. Hmm. I don't know what it's current state is. There _is_ a long-standing bug on it in bugzilla ( http://d.puremagic.com/issues/show_bug.cgi?id=143 ) which is still open. I had

Re: independent or parallel process

2012-10-18 Thread Ali Çehreli
On 10/18/2012 06:34 PM, drpepper wrote: > Thank you Ali, > > Indeed, I originally had the function outside of main. > > I have found another strange result with std.concurrency: > > spawn(&function, array[0].length, array.length); > // generates compiling error: "cannot deduce template function >

Re: independent or parallel process

2012-10-18 Thread drpepper
Thank you Ali, Indeed, I originally had the function outside of main. I have found another strange result with std.concurrency: spawn(&function, array[0].length, array.length); // generates compiling error: "cannot deduce template function from arg types" //Yet, int var_one = array[0].length;

Re: optlink and weak symbols

2012-10-18 Thread Ellery Newcomer
On 10/18/2012 11:36 AM, Jacob Carlborg wrote: On 2012-10-18 13:55, Ellery Newcomer wrote: I am using python27_digitalmars.lib, which is generated from libs\python27.lib with coffimplib, and it is linking my executables with python.dll. Ok. Do you know how the corresponding C code would look l

Re: opCast using in template struct

2012-10-18 Thread Timon Gehr
On 10/19/2012 02:12 AM, bearophile wrote: Timon Gehr: What situations? This thread has already shown two possible cases worth discussing about. This report shows two more cases: http://d.puremagic.com/issues/show_bug.cgi?id=8844 How is that bug-prone? Are there keyboards where : and = are

Re: opCast using in template struct

2012-10-18 Thread bearophile
Timon Gehr: What situations? This thread has already shown two possible cases worth discussing about. This report shows two more cases: http://d.puremagic.com/issues/show_bug.cgi?id=8844 Two more cases: Foo opBinary(string op="/\")(Foo f) {} Foo opBinary(string op)(Foo f) if (op == "@") {

Re: opCast using in template struct

2012-10-18 Thread Timon Gehr
On 10/19/2012 01:23 AM, bearophile wrote: Era Scarecrow: Maybe.. A general warning when something starts with 'op(Op)?[A-Z]' but doesn't actually qualify as any of the override-able operators? That seems sensible... Regarding operator overloading there are several situations worth warning th

Re: opCast using in template struct

2012-10-18 Thread Timon Gehr
On 10/19/2012 01:05 AM, Era Scarecrow wrote: On Thursday, 18 October 2012 at 22:07:55 UTC, Timon Gehr wrote: On 10/18/2012 11:45 PM, bearophile wrote: There are other cases. Generally the D compiler should add some warnings that help against operator overloading mistakes. I don't think that o

Re: opCast using in template struct

2012-10-18 Thread bearophile
Era Scarecrow: Maybe.. A general warning when something starts with 'op(Op)?[A-Z]' but doesn't actually qualify as any of the override-able operators? That seems sensible... Regarding operator overloading there are several situations worth warning the programmer of. The D compilers should b

Re: opCast using in template struct

2012-10-18 Thread Era Scarecrow
On Thursday, 18 October 2012 at 22:07:55 UTC, Timon Gehr wrote: On 10/18/2012 11:45 PM, bearophile wrote: There are other cases. Generally the D compiler should add some warnings that help against operator overloading mistakes. I don't think that operator overloading gives rise to distinct mi

Re: opCast using in template struct

2012-10-18 Thread Timon Gehr
On 10/18/2012 11:45 PM, bearophile wrote: Era Scarecrow: It's an easy mistake to make. Maybe the compiler should issue a warning when opAssign attempts and fails and opOpBinary is defined. This would have to be implemented very carefully. There are enough hard to reproduce symbol resolution

Re: opCast using in template struct

2012-10-18 Thread bearophile
Era Scarecrow: It's an easy mistake to make. Maybe the compiler should issue a warning when opAssign attempts and fails and opOpBinary is defined. If you have strong feelings about this, then add a Bugzilla entry. There are other cases. Generally the D compiler should add some warnings that

Re: opCast using in template struct

2012-10-18 Thread Era Scarecrow
On Thursday, 18 October 2012 at 18:12:49 UTC, Simen Kjaeraas wrote: I see you have opOpBinary there - should those be opOpAssign? Probably. It's an easy mistake to make. Maybe the compiler should issue a warning when opAssign attempts and fails and opOpBinary is defined.

Re: Friends?

2012-10-18 Thread Jonathan M Davis
> Does it work? I thought it was not implemented. Hmm. I don't know what it's current state is. There _is_ a long-standing bug on it in bugzilla ( http://d.puremagic.com/issues/show_bug.cgi?id=143 ) which is still open. I had forgotten about it. But the bug is that package doesn't restrict when

Re: Friends?

2012-10-18 Thread Jonathan M Davis
On Thursday, October 18, 2012 20:42:08 Jacob Carlborg wrote: > On 2012-10-18 19:57, Philippe Sigaud wrote: > > Does it work? I thought it was not implemented. > > Define "work". They're not virtual, which this would imply: > > "All non-static non-private non-template member functions are virtual.

Re: Extending library functions

2012-10-18 Thread Jonathan M Davis
On Thursday, October 18, 2012 16:22:17 bearophile wrote: > simendsjo: > > I don't think you can overload template methods with > > > non-template methods: > But maybe this will change. It's bug (I forget the exact bug number). TDPL says that you can do it, and as I understand it, it's simply a q

Re: std.concurrency msg passing

2012-10-18 Thread Joshua Niehus
On Thursday, 18 October 2012 at 17:33:04 UTC, cal wrote: I can't see the bug? The receiver accepts a bool as an int, same way a normal function does. The timeout is long enough that foo gets a chance to send. If you want to stop the int receiver getting a bool, you could add another receiver w

Re: std.concurrency msg passing

2012-10-18 Thread Sean Kelly
On Oct 18, 2012, at 11:35 AM, cal wrote: > On Thursday, 18 October 2012 at 18:31:09 UTC, Sean Kelly wrote: >> On Oct 17, 2012, at 11:29 PM, Joshua Niehus >>> void foo(Tid tid) { >>> send(tid, true); >>> } > /* snip */ >> spawn() shouldn't allow you to spawn a delegate. Last I checked (which wa

Re: Friends?

2012-10-18 Thread Jacob Carlborg
On 2012-10-18 19:57, Philippe Sigaud wrote: Does it work? I thought it was not implemented. Define "work". They're not virtual, which this would imply: "All non-static non-private non-template member functions are virtual." http://dlang.org/function.html#virtual-functions -- /Jacob Carlborg

Re: optlink and weak symbols

2012-10-18 Thread Jacob Carlborg
On 2012-10-18 13:55, Ellery Newcomer wrote: I am using python27_digitalmars.lib, which is generated from libs\python27.lib with coffimplib, and it is linking my executables with python.dll. Ok. Do you know how the corresponding C code would look like? Maybe you need to use the "export" attrib

Re: Extending library functions

2012-10-18 Thread Jacob Carlborg
On 2012-10-18 15:35, simendsjo wrote: I don't think you can overload template methods with non-template methods You cannot. The usual workaround for this is to make the non-template method a dummy template: void foo () (int a) {} // Note the extra pair of empty parentheses But this won't w

Re: std.concurrency msg passing

2012-10-18 Thread cal
On Thursday, 18 October 2012 at 18:31:09 UTC, Sean Kelly wrote: On Oct 17, 2012, at 11:29 PM, Joshua Niehus void foo(Tid tid) { send(tid, true); } /* snip */ spawn() shouldn't allow you to spawn a delegate. Last I checked (which was admittedly a while ago), there were some compiler issues

Re: std.concurrency msg passing

2012-10-18 Thread Sean Kelly
On Oct 17, 2012, at 11:29 PM, Joshua Niehus wrote: > Is the following snippet a bug? > > --- > import core.thread; > import std.stdio, std.concurrency; > > void foo(Tid tid) { >send(tid, true); > } > > void main() { >auto fooTid = spawn(&foo, thisTid); >auto receiveInt = receiveTim

Re: opCast using in template struct

2012-10-18 Thread Simen Kjaeraas
On 2012-10-18, 17:45, Oleg wrote: Sorry. My problem more complex and my simplification is not correct. I want use mixin for math operations. mixin template vectOp( string DataName, int DataLen, T, vecType ) { mixin( "alias " ~ DataName ~ " this;" ); auto opBinary(string op,E)( E[

Re: Friends?

2012-10-18 Thread Philippe Sigaud
On Thu, Oct 18, 2012 at 11:12 AM, Jeremy DeHaan wrote: > On Thursday, 18 October 2012 at 08:12:42 UTC, Jonathan M Davis wrote: >> >> On Thursday, October 18, 2012 10:09:46 Jeremy DeHaan wrote: >>> >>> Is there any kind of work around for this functionality? >> >> >> The package access modifier. >>

Re: independent or parallel process

2012-10-18 Thread Ali Çehreli
On 10/17/2012 07:46 PM, drpepper wrote: I want the function below to run independently -- like a unix background process, without delaying subsequent code in main. I tried the following using std.parallelism: void main() { function_a(int a, int b) { ... } auto new_task = task!function_a(11, 12)

Re: std.concurrency msg passing

2012-10-18 Thread Ali Çehreli
Sorry, wrong thread. :( Ali

Re: std.concurrency msg passing

2012-10-18 Thread Ali Çehreli
On 10/17/2012 11:29 PM, Joshua Niehus wrote: Is the following snippet a bug? --- import core.thread; import std.stdio, std.concurrency; void foo(Tid tid) { send(tid, true); } void main() { auto fooTid = spawn(&foo, thisTid); auto receiveInt = receiveTimeout(dur!"seconds"(10), (int isInt) { wri

Re: std.concurrency msg passing

2012-10-18 Thread cal
On Thursday, 18 October 2012 at 06:30:08 UTC, Joshua Niehus wrote: Is the following snippet a bug? --- import core.thread; import std.stdio, std.concurrency; void foo(Tid tid) { send(tid, true); } void main() { auto fooTid = spawn(&foo, thisTid); auto receiveInt = receiveTimeout(du

Re: opCast using in template struct

2012-10-18 Thread Oleg
Sorry. My problem more complex and my simplification is not correct. I want use mixin for math operations. mixin template vectOp( string DataName, int DataLen, T, vecType ) { mixin( "alias " ~ DataName ~ " this;" ); auto opBinary(string op,E)( E[DataLen] b ) auto opBinary(s

Re: opCast using in template struct

2012-10-18 Thread Simen Kjaeraas
On 2012-10-18, 16:54, Oleg wrote: Hello. How to cast template struct to itself? struct vec(string S,T=double) { T[S.length] data; auto opCast(string K,E)() if( S.length == K.length && is( T : E ) ) { vec!(K,E) ret; foreach( i, ref m; ret.d

opCast using in template struct

2012-10-18 Thread Oleg
Hello. How to cast template struct to itself? struct vec(string S,T=double) { T[S.length] data; auto opCast(string K,E)() if( S.length == K.length && is( T : E ) ) { vec!(K,E) ret; foreach( i, ref m; ret.data ) m = data[i]; retu

Re: Extending library functions

2012-10-18 Thread bearophile
simendsjo: I don't think you can overload template methods with non-template methods: But maybe this will change. Bye, bearophile

Re: Extending library functions

2012-10-18 Thread tn
On Thursday, 18 October 2012 at 13:35:55 UTC, simendsjo wrote: On Thursday, 18 October 2012 at 12:10:17 UTC, tn wrote: On Thursday, 18 October 2012 at 11:43:40 UTC, simendsjo wrote: On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: (...) You need to manually add std.math.exp2 to the overl

Re: Extending library functions

2012-10-18 Thread simendsjo
On Thursday, 18 October 2012 at 12:10:17 UTC, tn wrote: On Thursday, 18 October 2012 at 11:43:40 UTC, simendsjo wrote: On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: (...) You need to manually add std.math.exp2 to the overload set so importing external methods doesn't hijack your metho

Re: Extending library functions

2012-10-18 Thread tn
On Thursday, 18 October 2012 at 11:43:40 UTC, simendsjo wrote: On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: Hi. I want to extend math library functions to work with my own type. However, the definition for my own type seems to prevent automated access to the original function. How

Re: optlink and weak symbols

2012-10-18 Thread Ellery Newcomer
On 10/17/2012 11:41 PM, Jacob Carlborg wrote: On 2012-10-18 05:12, Ellery Newcomer wrote: nice tip, but adding extern doesn't change link behavior at all. Hmm, are you linking with the DLL (the import library) ? In not, you need to use dlopen, or what the corresponding Windows function is.

Re: Code review: JSON unmarshaller

2012-10-18 Thread Dan
On Monday, 15 October 2012 at 20:35:34 UTC, Tyler Jameson Little wrote: I'm basically trying to reproduce other JSON marshallers, like Go's, but using compile-time reflection. Go uses runtime reflection, which D notably does not support. I like the idea of compile-time reflection better anyway.

Re: Extending library functions

2012-10-18 Thread simendsjo
On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote: Hi. I want to extend math library functions to work with my own type. However, the definition for my own type seems to prevent automated access to the original function. How can I fix this unexpected behavior? Simplified example: -

Extending library functions

2012-10-18 Thread tn
Hi. I want to extend math library functions to work with my own type. However, the definition for my own type seems to prevent automated access to the original function. How can I fix this unexpected behavior? Simplified example: import std.math; int exp2(int x) { r

Re: undefined identifier

2012-10-18 Thread Oleg
solved. its associated with access private for _data field. if I use alias compiler must replace call "a" (for my type) to "a._data" if it needs...

Re: private module members

2012-10-18 Thread Oleg Kuporosov
Is it in Bugzilla? > >> Bye, >> bearophile >> > > Thanks. I had assumed my interpretation was incorrect and was just looking > for an explanation. Honestly, until just now, I have not explored bugzilla. > There is bug 1141 which looks like what I'm asking about and references a > newer one 2830 wh

Re: optlink and weak symbols

2012-10-18 Thread Regan Heath
On Thu, 18 Oct 2012 07:41:16 +0100, Jacob Carlborg wrote: On 2012-10-18 05:12, Ellery Newcomer wrote: nice tip, but adding extern doesn't change link behavior at all. Hmm, are you linking with the DLL (the import library) ? In not, you need to use dlopen, or what the corresponding Windows

undefined identifier

2012-10-18 Thread Oleg
Hello I have struct in one module (vector.d) struct vec(string S, T=double) if( is(T:real) && onlyASCII(S) ) { private T[S.length] _data; alias vec!(S,T) ttype; alias _data this; mixin _workaround4424; auto opAssign(E)( E[] b ) if( is( E : T ) ) { if( b.lengt

Re: Friends?

2012-10-18 Thread Jeremy DeHaan
On Thursday, 18 October 2012 at 08:12:42 UTC, Jonathan M Davis wrote: On Thursday, October 18, 2012 10:09:46 Jeremy DeHaan wrote: Is there any kind of work around for this functionality? The package access modifier. - Jonathan M Davis You, good sir, are now my new best friend.

Re: Code review: JSON unmarshaller

2012-10-18 Thread Jacob Carlborg
On 2012-10-17 22:03, Kagamin wrote: Can it serialize Variant? No, but I'm working on it. Actually, it can serialize it, but not deserialize it. -- /Jacob Carlborg

Re: Friends?

2012-10-18 Thread Jonathan M Davis
On Thursday, October 18, 2012 10:09:46 Jeremy DeHaan wrote: > Is there any kind of work around for this functionality? The package access modifier. - Jonathan M Davis

Friends?

2012-10-18 Thread Jeremy DeHaan
Hey guys! I think I understand the reasoning behind the idea that classes in the same module are automatically "friends", but why isn't there any way to have this sort of relationship between classes outside of a module? I feel like there are times when it doesn't always make sense to have tw