Re: Getting only the data members of a type

2012-04-01 Thread Ali Çehreli
On 03/31/2012 09:09 PM, Artur Skawina wrote: On 03/31/12 21:09, Ali Çehreli wrote: How can I determine just the data members of a struct or class, excluding the member functions? isCallable() comes short as member variable that have opCall() defined are also callable: [...] Wait! I found a

Re: ref const parameters in functions

2012-04-01 Thread L-MAN
On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double type for example public @property double X() const { return _x; }

Re: ref const parameters in functions

2012-04-01 Thread L-MAN
On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double type for example public @property double X() const { return _x; }

Re: ref const parameters in functions

2012-04-01 Thread Jonathan M Davis
On Sunday, April 01, 2012 09:10:58 L-MAN wrote: On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double

Re: Getting only the data members of a type

2012-04-01 Thread Artur Skawina
On 04/01/12 08:18, Ali Çehreli wrote: On 03/31/2012 09:09 PM, Artur Skawina wrote: On 03/31/12 21:09, Ali Çehreli wrote: How can I determine just the data members of a struct or class, excluding the member functions? isCallable() comes short as member variable that have opCall() defined are

Re: Getting only the data members of a type

2012-04-01 Thread Artur Skawina
On 04/01/12 11:27, Artur Skawina wrote: On 04/01/12 08:18, Ali Çehreli wrote: On 03/31/2012 09:09 PM, Artur Skawina wrote: This will print all fields of struct/class S: enum s = cast(S*)null; foreach (i, m; s.tupleof) { enum name = S.tupleof[i].stringof[4..$]; alias

Re: Problem with receiveOnly and classes

2012-04-01 Thread Ghislain
Either way, I once tried to pass over ownership of trees of objects to other threads but gave up on that. I don't think std.concurrency and D really can work like that. (?) Concurrency seems to work much better when you pass messages and data, structs are fine, and then build object trees

Re: Simulating multiple inheritance

2012-04-01 Thread Jacob Carlborg
On 2012-03-31 19:05, Andrej Mitrovic wrote: This is related to wrapping wxWidgets. One issue with the new wxWidgets 2.9.x series is that there seem to be more multiply-inherited classes than before. In particular some of the main classes have become MI classes (e.g. wxApp derives from

Re: Read a unicode character from the terminal

2012-04-01 Thread Jacob Carlborg
On 2012-03-31 20:53, Ali Çehreli wrote: I recommend using stdin. The destiny of std.cstream is uncertain and stdin is sufficient. (I know that it lacks support for BOM but I don't need them.) I thought std.cstream was a stream wrapper around stdin. The word 'character' used to mean

Re: Read a unicode character from the terminal

2012-04-01 Thread Jacob Carlborg
On 2012-04-01 01:17, Ali Çehreli wrote: On 03/31/2012 11:53 AM, Ali Çehreli wrote: The solution is to use ranges when pulling Unicode characters out of strings. std.stdin does not provide this yet, but it will eventually happen (so I've heard :)). Here is a Unicode character range, which

Re: Read a unicode character from the terminal

2012-04-01 Thread Jacob Carlborg
On 2012-04-01 00:14, Stewart Gordon wrote: On 31/03/2012 16:56, Jacob Carlborg wrote: How would I read a unicode character from the terminal? I've tried using std.cstream.din.getc but it seems to only work for ascii characters. If I try to read and print something that isn't ascii, it just

Re: Getting only the data members of a type

2012-04-01 Thread Jacob Carlborg
On 2012-04-01 08:18, Ali Çehreli wrote: On 03/31/2012 09:09 PM, Artur Skawina wrote: enum s = cast(S*)null; foreach (i, m; s.tupleof) { enum name = S.tupleof[i].stringof[4..$]; alias typeof(m) type; writef((%s) %s\n, type.stringof, name); } Real Programmers don't use

Re: Getting only the data members of a type

2012-04-01 Thread Jacob Carlborg
On 2012-04-01 11:27, Artur Skawina wrote: That's because the compiler won't accept foreach (i, t; S.tupleof) and *.tupleof[i].stringof is necessary to get the original name. This would have worked too: enum name = *s.tupleof[i].stringof[4..$]; but obfuscates the code more and looks

Re: Simulating multiple inheritance

2012-04-01 Thread bls
On 03/31/2012 10:05 AM, Andrej Mitrovic wrote: This is related to wrapping wxWidgets. One issue with the new wxWidgets 2.9.x series is that there seem to be more multiply-inherited classes than before As Jacob already said mixin templates and Interfaces are the way to go. I think you have to

Re: Getting only the data members of a type

2012-04-01 Thread Artur Skawina
On 04/01/12 14:10, Jacob Carlborg wrote: On 2012-04-01 11:27, Artur Skawina wrote: That's because the compiler won't accept foreach (i, t; S.tupleof) and But it accepts foreach (i, t; typeof(S.tupleof)). It does - thank you. This means that that ugly null-to-pointer cast from my example

Re: std.json dynamic initialization of JSONValue

2012-04-01 Thread Nicolas Silva
On Sat, Mar 31, 2012 at 12:25 PM, Piotr Szturmaj bncr...@jadamspam.pl wrote: Andrej Mitrovic wrote: On 12/1/11, Kai Meyerk...@unixlords.com  wrote: I'm finding std.json extremely well written, with one glaring exception. I'm finding it to be crap. The last time I used it I just kept

Re: Read a unicode character from the terminal

2012-04-01 Thread Ali Çehreli
On 04/01/2012 05:00 AM, Jacob Carlborg wrote: On 2012-04-01 01:17, Ali Çehreli wrote: On 03/31/2012 11:53 AM, Ali Çehreli wrote: The solution is to use ranges when pulling Unicode characters out of strings. std.stdin does not provide this yet, but it will eventually happen (so I've heard

Re: Simulating multiple inheritance

2012-04-01 Thread bls
On 03/31/2012 10:05 AM, Andrej Mitrovic wrote: One issue with the new wxWidgets 2.9.x series is that there seem to be more multiply-inherited classes than before A bit more complete snippet. interface Foo { void doFoo(); } // Foo implementation mixin template FooMixin() { alias

Nested interface

2012-04-01 Thread Read Bixby
I was working on a small personal project, and ran across something I think might (or might not) be a bug. I'm posting in this particular group just in case it's a restriction somewhere that I just don't know about, or maybe just the way that covariance gets resolved. The obvious workaround

Re: Nested interface

2012-04-01 Thread Read Bixby
Hm, I guess it's much simpler than that. I must not be understanding something about covariance. The following code produces the same error message (it has nothing to do with nestedness or shared classes): interface Interface { Interface getNext(); const(Interface)

Re: Read a unicode character from the terminal

2012-04-01 Thread Jacob Carlborg
On 2012-04-01 16:02, Ali Çehreli wrote: No difference in that example because it consumes the entire input as dchars. But in general, with that inefficient range, it is possible to pull just one dchar from the input and leave the rest of the stream untouched. For example, it would be possible

Re: Nested interface

2012-04-01 Thread Timon Gehr
On 04/01/2012 08:13 PM, Read Bixby wrote: Hm, I guess it's much simpler than that. I must not be understanding something about covariance. The following code produces the same error message (it has nothing to do with nestedness or shared classes): interface Interface { Interface

Re: Nested interface

2012-04-01 Thread Read Bixby
Thanks; entered as issue 7807. On Sunday, 1 April 2012 at 20:17:09 UTC, Timon Gehr wrote: On 04/01/2012 08:13 PM, Read Bixby wrote: Hm, I guess it's much simpler than that. I must not be understanding something about covariance. The following code produces the same error message (it has

Re: Where does U in Rebindable.Rebindable come from?

2012-04-01 Thread Simen Kjærås
On Fri, 30 Mar 2012 19:52:50 +0200, simendsjo simend...@gmail.com wrote: On Fri, 30 Mar 2012 17:13:25 +0200, Simen Kjærås simen.kja...@gmail.com wrote: Indeed. The thing is - U is basically *set* by the isExpression. It says 'yes, there is such a U, so I'll add it to the local scope.'. This

Re: Whats the best way to get a struct/class member type?

2012-04-01 Thread Simen Kjærås
On Sat, 31 Mar 2012 15:20:42 +0200, simendsjo simend...@gmail.com wrote: Seems __traits doesn't have a __traits(getMemberType, T, name). Now I'm doing the following: T t; // instance to use in getMember alias typeof( __traits(getMember, t, name) ) MemberType; Is this the only way to get the

Re: std.json dynamic initialization of JSONValue

2012-04-01 Thread Piotr Szturmaj
Nicolas Silva wrote: On Sat, Mar 31, 2012 at 12:25 PM, Piotr Szturmajbncr...@jadamspam.pl wrote: I have written streaming json parser using ranges. It returns slices when possible. Benchmarked it and it's about 2.05x the speed of std.json. It gives possibility to dig into the structure and

Re: UFCS for types?

2012-04-01 Thread James Miller
On 31 March 2012 21:37, simendsjo simend...@gmail.com wrote: Is is possible to use UFCS for types to simulate static members? struct S {    static void f(); } void ext(S)() {    S.f(); } void main() {    ext!S(); // ok    S.ext(); // Error: no property 'ext' for type 'S' } As far as

Re: Getting only the data members of a type

2012-04-01 Thread Ary Manzana
On 4/1/12 8:09 PM, Jacob Carlborg wrote: On 2012-04-01 08:18, Ali Çehreli wrote: On 03/31/2012 09:09 PM, Artur Skawina wrote: enum s = cast(S*)null; foreach (i, m; s.tupleof) { enum name = S.tupleof[i].stringof[4..$]; alias typeof(m) type; writef((%s) %s\n, type.stringof, name); }

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread James Miller
On 31 March 2012 06:28, Jonathan M Davis jmdavisp...@gmx.com wrote: it also has opDot, which is being removed from the language. Out of curiosity, what was opDot? -- James Miller

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread Alex Rønne Petersen
On 30-03-2012 19:28, Jonathan M Davis wrote: On Friday, March 30, 2012 16:27:44 simendsjo wrote: Is opImplicitCastTo a planned feature? It's only used in this type as I can see, and it doesn't add implicit casting. It's been discussed, but I don't think that it's ever been agreed upon. In

Re: ref const parameters in functions

2012-04-01 Thread L-MAN
On Sunday, 1 April 2012 at 08:22:08 UTC, Jonathan M Davis wrote: On Sunday, April 01, 2012 09:10:58 L-MAN wrote: On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like

Re: ref const parameters in functions

2012-04-01 Thread Jonathan M Davis
On Monday, April 02, 2012 05:46:24 L-MAN wrote: About temporaries in operators +-/*.. you're right, it is not a secret. references in other functions (not in operators) too. I can't understand one thing: ABC abc; // ABC is a struct that consists of some 4x4 matrix for example ABC

DDoc with cross-references

2012-04-01 Thread Ary Manzana
I'm planning to add cross-references to the default ddoc output. At least that's the simplest thing I could do right now that might improve ddoc somehow. I see the documentation generated for phobos, for example: http://dlang.org/phobos/std_array.html#Appender has anchors to the many symbols

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread Jonathan M Davis
On Monday, April 02, 2012 05:41:00 Alex Rønne Petersen wrote: On 30-03-2012 19:28, Jonathan M Davis wrote: On Friday, March 30, 2012 16:27:44 simendsjo wrote: Is opImplicitCastTo a planned feature? It's only used in this type as I can see, and it doesn't add implicit casting. It's

Re: DDoc with cross-references

2012-04-01 Thread Ary Manzana
On 4/2/12 12:20 PM, Ary Manzana wrote: I'm planning to add cross-references to the default ddoc output. At least that's the simplest thing I could do right now that might improve ddoc somehow. I see the documentation generated for phobos, for example:

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread Jonathan M Davis
On Monday, April 02, 2012 15:36:01 James Miller wrote: On 31 March 2012 06:28, Jonathan M Davis jmdavisp...@gmx.com wrote: it also has opDot, which is being removed from the language. Out of curiosity, what was opDot? An overload of the dot operator. So, if you had A a = foo(); a.func();

Re: ref const parameters in functions

2012-04-01 Thread Jonathan M Davis
On Sunday, April 01, 2012 21:23:50 Jonathan M Davis wrote: On Monday, April 02, 2012 05:46:24 L-MAN wrote: Sure, if you have large structs, making a lot of copies of them can be expensive. But to avoid that, you're going to have to avoid coding in a way which creates temporaries, and

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread Alex Rønne Petersen
On 02-04-2012 06:25, Jonathan M Davis wrote: On Monday, April 02, 2012 05:41:00 Alex Rønne Petersen wrote: On 30-03-2012 19:28, Jonathan M Davis wrote: On Friday, March 30, 2012 16:27:44 simendsjo wrote: Is opImplicitCastTo a planned feature? It's only used in this type as I can see, and it

Re: std.typecons.Ref(T).opImplicitCastTo()

2012-04-01 Thread Jonathan M Davis
On Monday, April 02, 2012 07:23:23 Alex Rønne Petersen wrote: On 02-04-2012 06:25, Jonathan M Davis wrote: alias this is not supposed to be restricted such that you can only have one per type. That's a temporary, implementation problem. TDPL specifically talks about having multiple alias

Add Element to list not Working

2012-04-01 Thread Chris Pons
I'm trying to add an element to a list with insert but that doesn't seem to do anything at all. If I try using ~= it says that Error: cannot append type Node to type SList!(Node). I'm pretty confused about using ~= because it works fine for arrays but apperantly not for lists. How do I add

Re: DDoc with cross-references

2012-04-01 Thread Ary Manzana
On 4/2/12 12:39 PM, Jonathan M Davis wrote: On Monday, April 02, 2012 12:20:31 Ary Manzana wrote: I'm planning to add cross-references to the default ddoc output. At least that's the simplest thing I could do right now that might improve ddoc somehow. I see the documentation generated for