Re: module std.regex

2013-12-31 Thread Dmitry Olshansky
31-Dec-2013 00:03, Benji пишет: On Monday, 30 December 2013 at 19:27:43 UTC, Dmitry Olshansky wrote: 30-Dec-2013 22:08, Benji пишет: Hello, when I try to run following code: [snip] This is part of core developers discussion and isn't something easily tweaked (else it would've been already fi

Re: A better way to write this function? (style question)

2013-12-31 Thread Jacob Carlborg
On 2013-12-30 23:51, John Colvin wrote: Anyway, the big problem I've hit is that AFAICT std.algorithm makes a complete mess of unicode and i can't find a byCodeUnit range anywhere in order to make it correct. There's a "byGrapheme" and a "byCodePoint" function in std.uni. It was recently adde

Re: How to organize using modules?

2013-12-31 Thread Jacob Carlborg
On 2013-12-31 07:01, Afshin wrote: Is it possible to describe modules in terms of packages (as found in Java)? The features that Java packages have that I can't seem to get in D are: 1) You can have classes that are in the same package, but kept in separate files. See below. 2) You can impor

Re: How to organize using modules?

2013-12-31 Thread bearophile
Afshin: in ClassA: module Module1.ClassA; in ClassB: module Module1.ClassB; In D module names usually start with a lowercase letter (usually they are all lowercase, because different file systems manage upper case letters in different ways). Bye, bearophile

Re: Slices, appending to arbitrary position

2013-12-31 Thread Regan Heath
On Mon, 30 Dec 2013 18:40:24 -, Dfr wrote: Thank you for replies, i think here i can use assoc array, but sometimes it is not suitable because it is not preserve order. What order do you want it in? The index order? If so, iterating over aa.keys.sort() will give you the keys in tha

Arrays of an interface

2013-12-31 Thread Abdulhaq
Hi all, hoping someone can help, I'm used to coding to interfaces and I'm using them very lightly in an application I'm writing (a CPP wrapper like SWIG, except in D). Every now and then I touch a piece of code which seems almost unrelated and then get a bunch of compile errors such as the fo

Re: Arrays of an interface

2013-12-31 Thread bearophile
Abdulhaq: I have a feeling that D doesn't fully support arrays of interfaces, e.g. Method[], particularly as a return type. If that's true, than it seems a D bug worth fixing. Are you able and willing to create a minimized example (later useful for Bugzilla)? Bye, bearophile

Re: Slices, appending to arbitrary position

2013-12-31 Thread bearophile
Regan Heath: What order do you want it in? The index order? If so, iterating over aa.keys.sort() will give you the keys in that order, and you can use that key to get the value aa[key] etc. I also suggested this: http://d.puremagic.com/issues/show_bug.cgi?id=10733 Bye, bearophile

Re: Arrays of an interface

2013-12-31 Thread Abdulhaq
On Tuesday, 31 December 2013 at 14:26:33 UTC, bearophile wrote: Abdulhaq: I have a feeling that D doesn't fully support arrays of interfaces, e.g. Method[], particularly as a return type. If that's true, than it seems a D bug worth fixing. Are you able and willing to create a minimized examp

Re: Arrays of an interface

2013-12-31 Thread Abdulhaq
On Tuesday, 31 December 2013 at 14:41:39 UTC, Adam D. Ruppe wrote: Can you post more of the code? Maybe MethodImpl forgot to inherit from Method or there's a const mismatch or something like that. Here you are: /** * The MethodImpl class is the main implementation of Method */ class MethodImp

Re: Arrays of an interface

2013-12-31 Thread Adam D. Ruppe
Can you post more of the code? Maybe MethodImpl forgot to inherit from Method or there's a const mismatch or something like that.

Re: Arrays of an interface

2013-12-31 Thread Abdulhaq
Sorry to reply to me own post so quickly, a clue (it seems to me) is this part of the error: smidgen/ast/klass.d(15): Error: size of type Method is not known Line 15 is where I import the interface: import smidgen.ast.method: Method, MethodImpl, Visibility, SMID; and in the relevant file, int

Re: Arrays of an interface

2013-12-31 Thread Adam D. Ruppe
On Tuesday, 31 December 2013 at 14:43:25 UTC, Abdulhaq wrote: Well, interfaces don't have sizes, do they? They have fixed size, interfaces are always implemented as pointers. Could be a forward reference problem, make sure you import the module with the interface above any use of it, and do

Re: Arrays of an interface

2013-12-31 Thread Abdulhaq
On Tuesday, 31 December 2013 at 14:54:31 UTC, Adam D. Ruppe wrote: On Tuesday, 31 December 2013 at 14:43:25 UTC, Abdulhaq wrote: Well, interfaces don't have sizes, do they? They have fixed size, interfaces are always implemented as pointers. Could be a forward reference problem, make sure y

Re: Arrays of an interface

2013-12-31 Thread bearophile
Abdulhaq: Ah! Great, doing the full import fixed it. The interface precedes the implementation in the same file, so it seems to me it's possibly a subtle glitch in the compiler with selective imports (the change I was making was in another module where I was subclassing Klass, which was the c

Re: A little DUB question

2013-12-31 Thread thedeemon
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.

DDOC- how to customize

2013-12-31 Thread Charles Hixson
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 possibly enums; I'd also like to make functions be, say, green. (FWIW, I don't want to change the documentation text, only the titles.

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

2013-12-31 Thread Dfr
Hello, i have string like "this.is.a.string" and want to throw away some parts separated by dots, here is first attempt: name = "this.is.a.string"; // <-- want to make "this.is.a" from this auto nameparts = splitter(name, '.'); auto name1 = joiner(nameparts[0 .. $-1], '.'); And got this error

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

2013-12-31 Thread Chris Cain
On Tuesday, 31 December 2013 at 20:49:55 UTC, Dfr wrote: Hello, i have string like "this.is.a.string" and want to throw away some parts separated by dots, here is first attempt: name = "this.is.a.string"; // <-- want to make "this.is.a" from this auto nameparts = splitter(name, '.'); auto nam

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

2013-12-31 Thread Rémy Mouëza
As Chris wrote, using double quotes to use strings instead of char solves the typing issse. I'd also suggest the following alternative, if you're going to discard a lot of last elements in your code: import std.stdio; import std.algorithm; import std.array; import std.range;

Re: DDOC- how to customize

2013-12-31 Thread Jonathan M Davis
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 possibly enums; I'd also like to make functions be, > say, green. > (FW

Re: DDOC- how to customize

2013-12-31 Thread Charles Hixson
On 12/31/2013 02:57 PM, 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 possibly enums; I'd also l

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

2013-12-31 Thread bearophile
Chris Cain: From your error message: isForwardRange!Separator Your separator is a character, which isn't a forward range. Try this: `auto name1 = joiner(nameparts[0 .. $-1], ".");` But splitting on a char is a common operation, and isn't it more efficient than splitting on a string? Bye,

Interface abstraction

2013-12-31 Thread Frustrated
If I use interfaces instead of classes is there a way to have new return the underlying interface that I want it to? interface A { } class B : A {} auto a = new B; // should return cast(A)(new B); Maybe it's not such a big deal though? (I can't think of any case where a being of type B will

Re: Interface abstraction

2013-12-31 Thread Adam D. Ruppe
On Wednesday, 1 January 2014 at 00:31:03 UTC, Frustrated wrote: auto a = new B; // should return cast(A)(new B); A a = new B; case where a being of type B will hurt since it is always implicitly castable to type A. Right, it'll always be usable anyway.

Easy way to implement interface properties?

2013-12-31 Thread Frustrated
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() { return m_data; } // read property @property int data(int value) { return m_data = value; } //

Easy way to implement interface properties?

2013-12-31 Thread Frustrated
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 { @property int data() { return m_data; } /

Re: Interface abstraction

2013-12-31 Thread Frustrated
On Wednesday, 1 January 2014 at 00:31:58 UTC, Adam D. Ruppe wrote: On Wednesday, 1 January 2014 at 00:31:03 UTC, Frustrated wrote: auto a = new B; // should return cast(A)(new B); A a = new B; case where a being of type B will hurt since it is always implicitly castable to type A. Right, i

Re: Easy way to implement interface properties?

2013-12-31 Thread Namespace
On Wednesday, 1 January 2014 at 00:48:13 UTC, 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() { return m_data; } // read prope

Re: Easy way to implement interface properties?

2013-12-31 Thread Frustrated
On Wednesday, 1 January 2014 at 00:53:53 UTC, Namespace wrote: On Wednesday, 1 January 2014 at 00:48:13 UTC, 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? interfa

Re: Interface abstraction

2013-12-31 Thread Adam D. Ruppe
On Wednesday, 1 January 2014 at 00:54:35 UTC, Frustrated wrote: not a big deal though. In setting up little test units I'll end up using the classes and auto but probably not in the full project where I'll use factories and such. Yeah, if you use your own factory methods, you can always just

Re: Easy way to implement interface properties?

2013-12-31 Thread Adam D. Ruppe
On Wednesday, 1 January 2014 at 00:52:24 UTC, Frustrated wrote: @property int data() { return m_data; } // read property @property int data(int value) { return m_data = value; } // write property Put that stuff in a mixin template. interface A { @property int data(); @property int

Re: A little DUB question

2013-12-31 Thread Casper Færgemand
On Tuesday, 31 December 2013 at 10:42:35 UTC, ponce wrote: Looks like a bug. In the meantime you can compile combined. $ dub --build=release --combined Error executing command run: Failed to find a package named '--combined'.

Re: Easy way to implement interface properties?

2013-12-31 Thread Adam D. Ruppe
On Wednesday, 1 January 2014 at 01:33:04 UTC, Frustrated wrote: But your template mixin is still duplicating generic code that should be easily handled automatically. (Generic properties are just wrappers around private fields that always have the same code (just return or set the field)) Oh

How do I choose the correct primative?

2013-12-31 Thread Jake Thomas
First, let me say that I am extremely enthused about D. I did research on it last year for a project and absolutely fell in love with it. But praise should go in another thread... My question comes down to: "Does dmd pack non-array primative variables in memory such that they are touching, or

Re: How do I choose the correct primative?

2013-12-31 Thread Rikki Cattermole
On Wednesday, 1 January 2014 at 04:17:30 UTC, Jake Thomas wrote: First, let me say that I am extremely enthused about D. I did research on it last year for a project and absolutely fell in love with it. But praise should go in another thread... My question comes down to: "Does dmd pack non-ar

Converting char to int

2013-12-31 Thread Caeadas
I hope you'll forgive my asking an overly easy question: I've been searching for an answer and having trouble finding one, and am getting frustrated. My issue is this: I'm trying to convert character types to integers using to!int from std.conv, and I'm getting, for example, '0'->48, '1'->49, etc

Re: Converting char to int

2013-12-31 Thread thedeemon
On Wednesday, 1 January 2014 at 06:21:05 UTC, Caeadas wrote: My issue is this: I'm trying to convert character types to integers using to!int from std.conv, and I'm getting, for example, '0'->48, '1'->49, etc. It seems like there should be a simple way around this, but it's eluding me. Well, in

Re: Converting char to int

2013-12-31 Thread Meta
On Wednesday, 1 January 2014 at 06:21:05 UTC, Caeadas wrote: I hope you'll forgive my asking an overly easy question: I've been searching for an answer and having trouble finding one, and am getting frustrated. My issue is this: I'm trying to convert character types to integers using to!int from

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

2013-12-31 Thread Dfr
This is interesting, why i can't just do it simpler way ? "this.is.a.string" .splitter (".") .popBack .joiner (".") .array .writeln; Because creating an extra function is not desired. As Chris wrote, using double quotes to use st

Determine if a member is a method

2013-12-31 Thread Frustrated
How does one determine if a member is a method and not anything else? 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)?

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

2013-12-31 Thread Dfr
And one more problem here: string name = "test"; auto nameparts = splitter(name, '.'); writeln(typeof(joiner(nameparts, ".").array).stringof); This prints "dchar[]", but i need char[] or string, how to get my 'string' back ? On Tuesday, 31 December 2013 at 20:49:55 UTC, Dfr wrote

Re: Easy way to implement interface properties?

2013-12-31 Thread Frustrated
On Wednesday, 1 January 2014 at 01:55:19 UTC, Adam D. Ruppe wrote: On Wednesday, 1 January 2014 at 01:33:04 UTC, Frustrated wrote: But your template mixin is still duplicating generic code that should be easily handled automatically. (Generic properties are just wrappers around private fields t

Re: Determine if a member is a method

2013-12-31 Thread Orvid King
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 `function` to any of class, interface, struct,