Re: Easy way to implement interface properties?

2014-01-01 Thread Frustrated
By modifying the code I was able to achieve exactly what I wanted(I have very complex interfaces but the classes using them consist of just one line. The code basically fixes your code to handle the setter and getters better and to work with functions. It is not very robust so I won't post it

Re: DDOC- how to customize

2014-01-01 Thread Mineko
On Tuesday, 31 December 2013 at 22:58:04 UTC, Jonathan M Davis wrote: On Tuesday, December 31, 2013 12:33:06 Charles Hixson wrote: In ddoc, if there is a way, how could I make, say, class names in the generated documentation be blue? Here I only want to change class and struct titles, and poss

Re: Easy way to implement interface properties?

2014-01-01 Thread Jacob Carlborg
On 2014-01-01 01:52, Frustrated wrote: Is there an easy way to implement properties of an interface within a class instead of having to duplicate almost the exact same code with generic properties? interface A { @property int data(); @property int data(int value); } class B : A {

Re: Determine if a member is a method

2014-01-01 Thread Jacob Carlborg
On 2014-01-01 08:55, Orvid King wrote: Well, unashamedly copying from my own code, I have a template defined thusly: enum isMemberFunction(T, string member) = is(typeof(__traits(getMember, T.init, member)) == function); Where `T` is the type that `member` is a part of. You can also change `func

Re: Determine if a member is a method

2014-01-01 Thread Jacob Carlborg
On 2014-01-01 08:43, Frustrated wrote: Also, how does one get the exact code string of a member instead of having to piece it together from info from std.traits? (which requires a lot of work)? You mean the to get the full signature of a method? I don't think that's possible, unless you can u

Re: Determine if a member is a method

2014-01-01 Thread Gary Willoughby
On Wednesday, 1 January 2014 at 12:19:29 UTC, Jacob Carlborg wrote: On 2014-01-01 08:43, Frustrated wrote: Also, how does one get the exact code string of a member instead of having to piece it together from info from std.traits? (which requires a lot of work)? You mean the to get the full

Re: Easy way to implement interface properties?

2014-01-01 Thread Gary Willoughby
On Wednesday, 1 January 2014 at 12:09:40 UTC, Jacob Carlborg wrote: On 2014-01-01 01:52, Frustrated wrote: Is there an easy way to implement properties of an interface within a class instead of having to duplicate almost the exact same code with generic properties? interface A { @property

Re: DDOC- how to customize

2014-01-01 Thread Gary Willoughby
On Wednesday, 1 January 2014 at 10:10:23 UTC, Mineko wrote: On Tuesday, 31 December 2013 at 22:58:04 UTC, Jonathan M Davis wrote: On Tuesday, December 31, 2013 12:33:06 Charles Hixson wrote: In ddoc, if there is a way, how could I make, say, class names in the generated documentation be blue?

Re: DDOC- how to customize

2014-01-01 Thread Gary Willoughby
On Wednesday, 1 January 2014 at 14:47:33 UTC, Gary Willoughby wrote: I've added an answer to the SO question. The answers here: http://stackoverflow.com/a/20869751/13227

Re: Determine if a member is a method

2014-01-01 Thread Dicebot
On 2014-01-01 08:43, Frustrated wrote: Also, how does one get the exact code string of a member instead of having to piece it together from info from std.traits? (which requires a lot of work)? Have a look at https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/internal/meta/c

Re: A little DUB question

2014-01-01 Thread ponce
On Tuesday, 31 December 2013 at 16:32:19 UTC, thedeemon wrote: On Tuesday, 31 December 2013 at 10:42:35 UTC, ponce wrote: $ dub --build=release --combined I guess this is something very recent, latest binary version from http://code.dlang.org/download doesn't know this word yet. Erm. Ye

Re: A little DUB question

2014-01-01 Thread ponce
On Wednesday, 1 January 2014 at 15:47:47 UTC, ponce wrote: On Tuesday, 31 December 2013 at 16:32:19 UTC, thedeemon wrote: On Tuesday, 31 December 2013 at 10:42:35 UTC, ponce wrote: $ dub --build=release --combined I guess this is something very recent, latest binary version from http://co

Re: Task to throw away string parts, use joiner and splitter not very successful

2014-01-01 Thread Rémy Mouëza
The popBack function returns the element you are removing from the array, not the array itself, thus "breaking" the chaining of function. On 01/01/2014 08:36 AM, Dfr wrote: This is interesting, why i can't just do it simpler way ? "this.is.a.string" .splitter (".")

Re: Task to throw away string parts, use joiner and splitter not very successful

2014-01-01 Thread Rémy Mouëza
You can use `std.conv.to` to convert the dchar[] back to a string, adding `.to!string` at the end of the dchar[] array you want to convert. Also not that there exists two similar functions to the lazy evaluated splitter() and joiner() in std.array: the eagerly evaluated split() and join(); bei

Re: Do assertions provide a mechanism for subtyping? If not are they composable?

2014-01-01 Thread Jonathan
, but it's not powerful enough for your use case. Bye, bearophile Is there a link available, so that I could see what is in the making?

Re: Easy way to implement interface properties?

2014-01-01 Thread Frustrated
On Wednesday, 1 January 2014 at 14:30:46 UTC, Gary Willoughby wrote: On Wednesday, 1 January 2014 at 12:09:40 UTC, Jacob Carlborg wrote: On 2014-01-01 01:52, Frustrated wrote: Is there an easy way to implement properties of an interface within a class instead of having to duplicate almost the e

Re: Determine if a member is a method

2014-01-01 Thread Frustrated
On Wednesday, 1 January 2014 at 15:10:56 UTC, Dicebot wrote: On 2014-01-01 08:43, Frustrated wrote: Also, how does one get the exact code string of a member instead of having to piece it together from info from std.traits? (which requires a lot of work)? Have a look at https://github.com/r

Re: Determine if a member is a method

2014-01-01 Thread Dicebot
On Wednesday, 1 January 2014 at 17:19:01 UTC, Frustrated wrote: There seems to be a bug. When I run it on a standard member it works fine. When I run it on a property it throws an error src\phobos\std\traits.d(344): Error: forward reference of variable parentPrefix src\phobos\std\traits.d(505)

Are modules analogous to namespaces in C# or packages in Java?

2014-01-01 Thread Afshin
Modules confuse me as a way to organize code. If a module is composed of multiple classes, it seems that the module semantics in D encourages putting all those classes in one file. Can someone explain how to organize a set of classes into a module (or namespace, or package) so that each clas

Re: Task to throw away string parts, use joiner and splitter not very successful

2014-01-01 Thread Dfr
Thank you, very clear explained. On Wednesday, 1 January 2014 at 16:31:43 UTC, Rémy Mouëza wrote: You can use `std.conv.to` to convert the dchar[] back to a string, adding `.to!string` at the end of the dchar[] array you want to convert. Also not that there exists two similar functions to the

Re: Do assertions provide a mechanism for subtyping? If not are they composable?

2014-01-01 Thread bearophile
Jonathan: Is there a link available, so that I could see what is in the making? Yes, this is two thirds of my proposal: http://www.digitalmars.com/d/archives/digitalmars/D/enum_pre-conditions_217595.html Bye, bearophile

Re: Are modules analogous to namespaces in C# or packages in Java?

2014-01-01 Thread Justin Whear
On Wed, 01 Jan 2014 17:43:53 +, Afshin wrote: > Modules confuse me as a way to organize code. > > If a module is composed of multiple classes, it seems that the module > semantics in D encourages putting all those classes in one file. > > Can someone explain how to organize a set of classes

Re: Are modules analogous to namespaces in C# or packages in Java?

2014-01-01 Thread bearophile
Afshin: Can someone explain how to organize a set of classes into a module (or namespace, or package) so that each class can have their own file? Lot of D code is not made of classes :-) There are also lot of free functions, some templates, some type definitions, some interfaces, some globa

Re: DDOC- how to customize

2014-01-01 Thread Charles Hixson
On 01/01/2014 06:58 AM, Gary Willoughby wrote: On Wednesday, 1 January 2014 at 14:47:33 UTC, Gary Willoughby wrote: I've added an answer to the SO question. The answers here: http://stackoverflow.com/a/20869751/13227 That's richer coloring, alright. It looks quite nice. But the example doe

Re: How do I choose the correct primative?

2014-01-01 Thread Marco Leise
C compilers like D compilers will pack a struct of two 16-bit words into a 32-bit type if you don't force an alignment: http://dlang.org/attribute.html#align What you should avoid is having a data type start at an address that is not a multiple of its size, especially when it comes to SIMD. Working

Re: Converting char to int

2014-01-01 Thread Caeadas
Thanks much for the help, both of you :). I thought there might be a very simple way to do this, since it's so intuitive to change '4' to 4. I've basically just been subtracting 48 from everything, but I suppose aesthetically it's a bit nicer to convert from string instead.

Re: Converting char to int

2014-01-01 Thread Marco Leise
Am Wed, 01 Jan 2014 07:27:54 + schrieb "Meta" : > Your code is working correctly. D's chars, for all values up to > 255, are the same as the ASCII character set. UTF-8 reuses the ASCII mapping which is only defined from 0 to 127. Everything above is not ASCII and 255 is in fact not even defi

Re: Converting char to int

2014-01-01 Thread Meta
On Wednesday, 1 January 2014 at 20:08:24 UTC, Marco Leise wrote: Am Wed, 01 Jan 2014 07:27:54 + schrieb "Meta" : Your code is working correctly. D's chars, for all values up to 255, are the same as the ASCII character set. UTF-8 reuses the ASCII mapping which is only defined from 0 to 127

How to handle char* to string from C functions?

2014-01-01 Thread Gary Willoughby
I'm calling an external C function which returns a string delivered via a char*. When i print this string out, like this: char* result = func(); writefln("String: %s", *result); I only get one character printed. I guess this is expected because i'm only returned a pointer to the first char. I

Re: How to handle char* to string from C functions?

2014-01-01 Thread Adam D. Ruppe
On Wednesday, 1 January 2014 at 23:03:06 UTC, Gary Willoughby wrote: I'm calling an external C function which returns a string delivered via a char*. When i print this string out, like this: char* result = func();' you can then do string r = to!string(result); or char[] r = result[0 .. str

Re: How to handle char* to string from C functions?

2014-01-01 Thread John Colvin
On Wednesday, 1 January 2014 at 23:03:06 UTC, Gary Willoughby wrote: I'm calling an external C function which returns a string delivered via a char*. When i print this string out, like this: char* result = func(); writefln("String: %s", *result); I only get one character printed. You're not

Re: How do I choose the correct primative?

2014-01-01 Thread TheFlyingFiddle
I'm a little OCD - who cares about memory to that degree anymore when we have gigabytes of RAM? This might not even come into play on the Raspberry Pi. Memory is very important when it comes to performance, the moving of memory is the single most energy demanding task the CPU (and the GPU for

Struct field reordering

2014-01-01 Thread bearophile
Seen this on Reddit: http://www.catb.org/esr/structure-packing/ It could be useful to have in Phobos some template that given pair-name pairs (or a struct type) returns those fields in a better packed order (without using align()). See also: https://d.puremagic.com/issues/show_bug.cgi?id=887

Documenting contracts in Ddoc

2014-01-01 Thread Ross Hays
Given that D has contracts built into the language (which is one of my favorite features of D by far) it seems to me that it should be possible to document the pre and post conditions of a contract using a contract section in Ddoc. I have been reading through the documentation on Ddoc to see if

Re: Documenting contracts in Ddoc

2014-01-01 Thread bearophile
Ross Hays: I am putting this topic in the learn forum because I may be wrong and it may be possible. If, however, it is not possible, that maybe it is worth a official suggestion? Currently contracts don't go in DDoc, but they could. Bye, bearophile

Re: Documenting contracts in Ddoc

2014-01-01 Thread H. S. Teoh
On Thu, Jan 02, 2014 at 03:42:53AM +, bearophile wrote: > Ross Hays: > > >I am putting this topic in the learn forum because I may be wrong > >and it may be possible. If, however, it is not possible, that > >maybe it is worth a official suggestion? > > Currently contracts don't go in DDoc, bu