Re: From D struct to C struct

2013-11-18 Thread Namespace
I found another approach. It avoids the GC and the Heap: A Circular Buffer: http://dpaste.dzfl.pl/cf1e7afb That should work.

Re: pure-ifying my code

2013-11-18 Thread Dmitry Olshansky
18-Nov-2013 11:37, Jonathan M Davis пишет: On Monday, November 18, 2013 08:22:37 qznc wrote: On Sunday, 17 November 2013 at 21:00:16 UTC, Jonathan M Davis wrote: will definitely result in multiple calls to pure_func. It's not that it's impossible for the compiler to do it - it's perfectly

Re: From D struct to C struct

2013-11-18 Thread qznc
On Monday, 18 November 2013 at 08:32:11 UTC, Namespace wrote: I found another approach. It avoids the GC and the Heap: A Circular Buffer: http://dpaste.dzfl.pl/cf1e7afb That should work. It is unsafe, but might work in your specific case. The problem is that future changes might exhibit

Re: pure-ifying my code

2013-11-18 Thread qznc
On Monday, 18 November 2013 at 07:37:27 UTC, Jonathan M Davis wrote: This is middleend optimization stuff, though. I'm not quite sure what you mean by this. There is no middle-end. We have the front-end, which is shared by dmd, gdc, and ldc, and then each compiler has its own backend.

Re: D on learnxinyminutes.com

2013-11-18 Thread qznc
On Sunday, 17 November 2013 at 20:56:47 UTC, John J wrote: Can you please add the D language to the http://learnxinyminutes.com/ That's an interesting way of quickly introducing a language through a long and well commented code example. Writing this is probably a good learning experience

Re: Compiling an app to a single binary - possible?

2013-11-18 Thread Dicebot
On Sunday, 17 November 2013 at 18:40:34 UTC, Jacek Furmankiewicz wrote: It is possible to import an entire folder and subfolders of assets? (e.g. static HTML with all of its pieces, i.e. CSS, JSS. etc) Theoretically possible but not really expected to and generally does not give you much

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Per Nordlöw
Is JSONSerialization somehow related to the upcoming std.serialization? I feel that there is a big need for standardizing serialization in D. There are too many alternatives: dproto, msgpack, JSON, xml, etc should be made backends to the same frontend named std.serialization right? /Per On

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Jacob Carlborg
On 2013-11-18 12:25, Per Nordlöw per.nord...@gmail.com wrote: Is JSONSerialization somehow related to the upcoming std.serialization? No. I feel that there is a big need for standardizing serialization in D. There are too many alternatives: dproto, msgpack, JSON, xml, etc should be made

Re: D on learnxinyminutes.com

2013-11-18 Thread anonymous
On Sunday, 17 November 2013 at 20:56:47 UTC, John J wrote: Can you please add the D language to the http://learnxinyminutes.com/ That's an interesting way of quickly introducing a language through a long and well commented code example. There are several other languages on that site already

Enum with base type string and switch

2013-11-18 Thread seany
Hi, I am experiencing the same issue as here: http://forum.dlang.org/thread/bug-1011...@http.d.puremagic.com/issues/ I have the DMD 2.061 for Linux 64 bit In this thread. their is a mention of one -g switch. I am sorry but can'T figure out how to implement the said -g switch. Please help.

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Per Nordlöw
Ok. That is great. Thx. On Monday, 18 November 2013 at 12:26:19 UTC, Jacob Carlborg wrote: On 2013-11-18 12:25, Per Nordlöw per.nord...@gmail.com wrote: Is JSONSerialization somehow related to the upcoming std.serialization? No. I feel that there is a big need for standardizing

Re: Enum with base type string and switch

2013-11-18 Thread Jacob Carlborg
On 2013-11-18 13:48, seany wrote: Hi, I am experiencing the same issue as here: http://forum.dlang.org/thread/bug-1011...@http.d.puremagic.com/issues/ I have the DMD 2.061 for Linux 64 bit In this thread. their is a mention of one -g switch. I am sorry but can'T figure out how to implement the

Re: Enum with base type string and switch

2013-11-18 Thread seany
On Monday, 18 November 2013 at 13:29:38 UTC, Jacob Carlborg wrote: Just pass -g on the command line, example: dmd main.d -g Uh, that does not work, (same error message) but a switch(cast(string)(enum_var)) seem to work

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Orvid King
On 11/18/13, Per Nordlöw\ per.nord...@gmail.com@puremagic.com Per Nordlöw\ per.nord...@gmail.com@puremagic.com wrote: Is JSONSerialization somehow related to the upcoming std.serialization? I feel that there is a big need for standardizing serialization in D. There are too many alternatives:

Re: From D struct to C struct

2013-11-18 Thread Namespace
On Monday, 18 November 2013 at 10:09:12 UTC, qznc wrote: On Monday, 18 November 2013 at 08:32:11 UTC, Namespace wrote: I found another approach. It avoids the GC and the Heap: A Circular Buffer: http://dpaste.dzfl.pl/cf1e7afb That should work. It is unsafe, but might work in your specific

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Atila Neves
I would suspect that the biggest reason is the limitations that that imposes on the underlying serialization implementation, as it would require that the underlying format support a minimum set of types. I'm not sure that's actually true. I've been working on my own serialisation library in

A small difference between cdouble and std.complex

2013-11-18 Thread bearophile
This shows a difference between the deprecated built-in complex numbers and std.complex: void main() { import std.complex: complex; const cdouble cd; pragma(msg, typeof(cd.re)); const acc = complex(1, 2); pragma(msg, typeof(acc.re)); } It prints: double const(double) Is

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Jacek Furmankiewicz
The reason I like Thrift is that it is backwards and forwards compatible. Assuming in your schema you keep defining new fields as optional, old clients can read data from new producers as well as new clients can read data from old producers. Not too many binary serialization formats offer

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Orvid King
On 11/18/13, Atila Neves atila.ne...@gmail.com wrote: I would suspect that the biggest reason is the limitations that that imposes on the underlying serialization implementation, as it would require that the underlying format support a minimum set of types. I'm not sure that's actually

Re: From D struct to C struct

2013-11-18 Thread Maxim Fomin
On Monday, 18 November 2013 at 14:15:02 UTC, Namespace wrote: On Monday, 18 November 2013 at 10:09:12 UTC, qznc wrote: On Monday, 18 November 2013 at 08:32:11 UTC, Namespace wrote: I found another approach. It avoids the GC and the Heap: A Circular Buffer: http://dpaste.dzfl.pl/cf1e7afb That

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Jacob Carlborg
On 2013-11-18 16:11, Atila Neves wrote: I'm not sure that's actually true. I've been working on my own serialisation library in D that I plan to unleash on the announce forum soon and it does it in a manner described by the original poster. Even with custom serialisations, client code need only

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Atila Neves
On Monday, 18 November 2013 at 15:26:28 UTC, Jacob Carlborg wrote: On 2013-11-18 16:11, Atila Neves wrote: I'm not sure that's actually true. I've been working on my own serialisation library in D that I plan to unleash on the announce forum soon and it does it in a manner described by the

Re: how to check if an element is in array

2013-11-18 Thread Jacob Carlborg
On 2013-11-18 16:33, seany wrote: Is there a built in function in D to check if an element is a member of a (possibly multidimensional array? say function(array, element). that returns to, if the element is in the array, (or even better, if the elements of the array are arrays themselves, then

how to check if an element is in array

2013-11-18 Thread seany
Is there a built in function in D to check if an element is a member of a (possibly multidimensional array? say function(array, element). that returns to, if the element is in the array, (or even better, if the elements of the array are arrays themselves, then recursively checks if element is

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Atila Neves
I am curious as to how exactly that would work, does it determine the output format at compile-time or runtime? Does it specify the way it's serialized, or it's serialized representation? I'd also be curious about the performance impact it brings, if any. Depending on it's exact function it's

Re: From D struct to C struct

2013-11-18 Thread Namespace
On Monday, 18 November 2013 at 15:27:46 UTC, Maxim Fomin wrote: On Monday, 18 November 2013 at 14:15:02 UTC, Namespace wrote: On Monday, 18 November 2013 at 10:09:12 UTC, qznc wrote: On Monday, 18 November 2013 at 08:32:11 UTC, Namespace wrote: I found another approach. It avoids the GC and

Re: how to check if an element is in array

2013-11-18 Thread Andrea Fontana
On Monday, 18 November 2013 at 15:33:22 UTC, seany wrote: Is there a built in function in D to check if an element is a member of a (possibly multidimensional array? say function(array, element). that returns to, if the element is in the array, (or even better, if the elements of the array

implicit indirection

2013-11-18 Thread Carl Sturtivant
struct Blah { int val; Blah* next; } Blah x, y; Blah* p; p = x; p.next = y; //don't need (*p).next --- very nice Can someone point me to where this feature of D is documented please.

Re: implicit indirection

2013-11-18 Thread Ali Çehreli
On 11/18/2013 08:18 AM, Carl Sturtivant wrote: struct Blah { int val; Blah* next; } Blah x, y; Blah* p; p = x; p.next = y; //don't need (*p).next --- very nice Can someone point me to where this feature of D is documented please. Other than being well known, I don't know where it is

Re: From D struct to C struct

2013-11-18 Thread Maxim Fomin
On Monday, 18 November 2013 at 16:03:33 UTC, Namespace wrote: On Monday, 18 November 2013 at 15:27:46 UTC, Maxim Fomin wrote: I think there is bigger problem (and bigger memory error) here. When you inside struct method load pointer to some field you cannot rely that after leaving the

Re: Reflections on Serialization APIs in D

2013-11-18 Thread Atila Neves
http://forum.dlang.org/thread/sctofkitoaxftosxt...@forum.dlang.org#post-sctofkitoaxftosxtspw:40forum.dlang.org On Monday, 18 November 2013 at 15:32:30 UTC, Atila Neves wrote: I am curious as to how exactly that would work, does it determine the output format at compile-time or runtime? Does it

Re: Cannot pass by reference

2013-11-18 Thread Jeroen Bollen
On Saturday, 16 November 2013 at 16:34:31 UTC, Ali Çehreli wrote: The problem with your example is that unlike main.c in my example, what you pass is an rvalue, which may not be bound to the ref parameter. Thanks, this is what I needed!

Re: pure-ifying my code

2013-11-18 Thread Daniel Davidson
On Sunday, 17 November 2013 at 10:56:16 UTC, Jonathan M Davis wrote: I think that the typical approach at this point is to just drop purity for the moment, but if you want you really want it, you are indeed going to have to implement it yourself. But we'll get there with Phobos eventually.

Re: Class References

2013-11-18 Thread Jeroen Bollen
Is it possible to do something like: TestInterface testi = new classReferenceList[integer];

Re: Class References

2013-11-18 Thread Ali Çehreli
On 11/18/2013 10:28 AM, Jeroen Bollen wrote: Is it possible to do something like: TestInterface testi = new classReferenceList[integer]; We still don't know what the use case is :) but it is possible to store types in a TypeTuple: import std.stdio; import std.typetuple; interface I {}

Re: Calling Base Class Overriden Methods

2013-11-18 Thread Adam D. Ruppe
On Monday, 18 November 2013 at 19:32:39 UTC, Jeroen Bollen wrote: How do I call a parent class's overidden method? super.method so abstract class SuperClass { public pure void methodA() { } } class SubClass : SuperClass { public override pure void methodA() { // calls

Calling Base Class Overriden Methods

2013-11-18 Thread Jeroen Bollen
How do I call a parent class's overidden method? module test; abstract class SuperClass { public pure void methodA() { } } class SubClass { public override pure void methodB() { // How do I call the parent methodA() from here? } }

Re: Calling Base Class Overriden Methods

2013-11-18 Thread Jeroen Bollen
On Monday, 18 November 2013 at 19:34:56 UTC, Adam D. Ruppe wrote: On Monday, 18 November 2013 at 19:32:39 UTC, Jeroen Bollen wrote: How do I call a parent class's overidden method? super.method so abstract class SuperClass { public pure void methodA() { } } class SubClass :

T[] (array of generic type)

2013-11-18 Thread seany
perhaps I sohould have myself played around, but I would love to ask this : I want to make a function, that takes ay array (whose elements can be int, string, struct, etc) and a variable of the same type, of which the array in an array. Like function(int[] arr, int var) or function(string[]

Re: pure-ifying my code

2013-11-18 Thread Jonathan M Davis
On Monday, November 18, 2013 19:16:11 Daniel Davidson wrote: On Sunday, 17 November 2013 at 10:56:16 UTC, Jonathan M Davis wrote: I think that the typical approach at this point is to just drop purity for the moment, but if you want you really want it, you are indeed going to have to

Re: Calling Base Class Overriden Methods

2013-11-18 Thread Adam D. Ruppe
On Monday, 18 November 2013 at 19:36:07 UTC, Jeroen Bollen wrote: Why aren't these things in the documentation? :/ blargh, i thought it was, but can't find it either

Re: T[] (array of generic type)

2013-11-18 Thread JR
On Monday, 18 November 2013 at 19:47:47 UTC, seany wrote: A natural choice is fuction(T)(T[] array, T var) but i dont find much info on this type on construction, is there any material introducing me to this type of construction? Ali's book has a good introduction to templates:

Re: T[] (array of generic type)

2013-11-18 Thread seany
I read that book, but dont find this constructtion, that is why the question.

Re: T[] (array of generic type)

2013-11-18 Thread Jon
On Monday, 18 November 2013 at 20:20:38 UTC, seany wrote: I read that book, but dont find this constructtion, that is why the question. Seany, you are on the right track for the function declaration, I think the following code does what you are looking for: import std.stdio; void main() {

Re: T[] (array of generic type)

2013-11-18 Thread seany
On Monday, 18 November 2013 at 20:42:36 UTC, Jon wrote: On Monday, 18 November 2013 at 20:20:38 UTC, seany wrote: I read that book, but dont find this constructtion, that is why the question. Seany, you are on the right track for the function declaration, I think the following code does what

Re: T[] (array of generic type)

2013-11-18 Thread seany
On Monday, 18 November 2013 at 20:32:25 UTC, Philippe Sigaud wrote: On Mon, Nov 18, 2013 at 9:20 PM, seany se...@uni-bonn.de wrote: I read that book, but dont find this constructtion, that is why the question. IIRC I talk a bit about function templates in my tutorial. JR gave the link

Re: T[] (array of generic type)

2013-11-18 Thread Jon
On Monday, 18 November 2013 at 20:45:54 UTC, seany wrote: On Monday, 18 November 2013 at 20:42:36 UTC, Jon wrote: On Monday, 18 November 2013 at 20:20:38 UTC, seany wrote: I read that book, but dont find this constructtion, that is why the question. Seany, you are on the right track for the

Re: T[] (array of generic type)

2013-11-18 Thread Ali Çehreli
On 11/18/2013 12:20 PM, seany wrote: I read that book, but dont find this constructtion, that is why the question. I will make such an addition. Thanks. Ali

Newbie Question: SOAP Module

2013-11-18 Thread Rick Catano
Hello all, I'm new here ( first post ), and looking to get into D Development. I currently use Python as my language of choice, but am looking to transition. My first question of the D language is, is there a SOAP module that I can consume web services with?

Re: about std.string.representation

2013-11-18 Thread bioinfornatics
On Thursday, 14 November 2013 at 12:01:04 UTC, Ali Çehreli wrote: On 11/13/2013 04:32 PM, bioinfornatics wrote: Hi, I try to understand which type char, dchar, wchar will give ubyte,ushort,uint… And for templates, there is std.range.ElementEncodingType: import std.stdio; import std.range;

Re: about std.string.representation

2013-11-18 Thread Ali Çehreli
On 11/18/2013 07:48 PM, bioinfornatics wrote: On Thursday, 14 November 2013 at 12:01:04 UTC, Ali Çehreli wrote: On 11/13/2013 04:32 PM, bioinfornatics wrote: Hi, I try to understand which type char, dchar, wchar will give ubyte,ushort,uint… And for templates, there is

Re: Calling Base Class Overriden Methods

2013-11-18 Thread Kenji Hara
On Monday, 18 November 2013 at 19:36:07 UTC, Jeroen Bollen wrote: On Monday, 18 November 2013 at 19:34:56 UTC, Adam D. Ruppe wrote: To do it from outside the class, you write the class name: void main() { auto obj = new SubClass(); obj.SuperClass.methodA(); // calls the specific