Re: Code review: JSON unmarshaller

2012-10-16 Thread Jacob Carlborg
On 2012-10-15 22:35, 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. There are a few things

Re: Code review: JSON unmarshaller

2012-10-16 Thread Ali Çehreli
On 10/15/2012 12:03 PM, Tyler Jameson Little wrote: I did my best in grokking std.traits, but I may have missed some subtleties about what the templates are actually testing. You have mentioned needing an allMembers that excluded functions in one of your other posts. The following thread was

Returning reference to integer from property setter function

2012-10-16 Thread m0rph
Hi! How I can return from function a reference to int? Here is a simple code, to demonstrate my problem: struct Foo { public: @property int foo() const { return x_; } @property ref int foo(int value) { x_ = value;

Re: Returning reference to integer from property setter function

2012-10-16 Thread Adam D. Ruppe
On Tuesday, 16 October 2012 at 14:43:09 UTC, m0rph wrote: Hi! How I can return from function a reference to int? The problem here isn't about the ref but rather the way properties are implemented with +=. I believe this is one of the older still-standing D bugs. It rewrites your

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Maxim Fomin
On Tuesday, 16 October 2012 at 00:50:54 UTC, Artur Skawina wrote: Actually, I'm not really in any camp. UFCS has several obvious problems plus likely quite a few more subtle ones. Ignoring the issues does not make them go away and the

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Tommi
On Monday, 15 October 2012 at 09:33:23 UTC, Maxim Fomin wrote: ---foo.d--- struct A { int i; alias i this; } ---bar.d--- int opUnary(string T)(A a) { ... } ... { ++a; } --- I. i is incremented, opUnary is not called. However opUnary matches better to the actual type and if it

Re: Problem with UFCS

2012-10-16 Thread Adam D. Ruppe
On Tuesday, 16 October 2012 at 16:12:06 UTC, Michael wrote: void main() { import std.range, std.stdio; The problem is that UFCS only works on functions in the global scope. The import inside a function makes them local, so it doesn't consider them in it. This is apparently by

Re: Operator overloading through UFCS doesn't work

2012-10-16 Thread Maxim Fomin
On Tuesday, 16 October 2012 at 16:10:31 UTC, Tommi wrote: On Monday, 15 October 2012 at 09:33:23 UTC, Maxim Fomin wrote: ---foo.d--- struct A { int i; alias i this; } ---bar.d--- int opUnary(string T)(A a) { ... } ... { ++a; } --- I. i is incremented, opUnary is not called. However

Re: Problem with UFCS

2012-10-16 Thread Jonathan M Davis
On Tuesday, October 16, 2012 18:28:14 Adam D. Ruppe wrote: On Tuesday, 16 October 2012 at 16:12:06 UTC, Michael wrote: void main() { import std.range, std.stdio; The problem is that UFCS only works on functions in the global scope. The import inside a function makes them local, so it

Re: std.stream, BOM, and deprecation

2012-10-16 Thread Charles Hixson
On 10/15/2012 10:29 AM, Steven Schveighoffer wrote: On Sat, 13 Oct 2012 21:53:48 -0400, Charles Hixson charleshi...@earthlink.net wrote: If std.stream is being deprecated, what is the correct way to deal with file BOMs. This is particularly concerning utf8 files, which I understand to be a bit

Re: std.stream, BOM, and deprecation

2012-10-16 Thread Charles Hixson
On 10/14/2012 10:28 PM, Nick Sabalausky wrote: On Sat, 13 Oct 2012 18:53:48 -0700 Charles Hixsoncharleshi...@earthlink.net wrote: If std.stream is being deprecated, what is the correct way to deal with file BOMs. This is particularly concerning utf8 files, which I understand to be a bit

Re: toStringz note about keeping references

2012-10-16 Thread Charles Hixson
On 10/14/2012 04:54 PM, Ali Çehreli wrote: On 10/14/2012 04:36 PM, Andrej Mitrovic wrote: On 10/15/12, Jonathan M Davisjmdavisp...@gmx.com wrote: I'd have to see exactly what TDPL says to comment on that accurately Maybe I've misread it. On Page 288 it says: An immutable value is

Re: Returning reference to integer from property setter function

2012-10-16 Thread m0rph
Thanks for reply, hopefully this issue will be fixed sometime..

Re: Do we have GC-free hash map implementation sitting somewhere?

2012-10-16 Thread Benjamin Thaut
Am 15.10.2012 08:49, schrieb Alex Rønne Petersen: Hi, Is there a GC-free hash map implementation for D somewhere on the intertubes? (Preferably in a Git repository and under a liberal/non-viral license.) https://github.com/Ingrater/druntime/blob/master/src/core/hashmap.d Kind Regards

private module members

2012-10-16 Thread Dan
According to the spec, private module members are equivalent to static declarations in C programs. Why does this work (i.e. print 5)? Both imported.d and sample.d are in same directory (.../attributes). Thanks Dan -- import

Re: private module members

2012-10-16 Thread bearophile
Dan: Why does this work (i.e. print 5)? It looks like a compiler bug/hole. DMD is not yet aligned to its specs... Is it in Bugzilla? Bye, bearophile

Re: private module members

2012-10-16 Thread Dan
On Tuesday, 16 October 2012 at 19:31:45 UTC, bearophile wrote: Dan: Why does this work (i.e. print 5)? It looks like a compiler bug/hole. DMD is not yet aligned to its specs... Is it in Bugzilla? Bye, bearophile Thanks. I had assumed my interpretation was incorrect and was just

Re: Sorting algorithms

2012-10-16 Thread Era Scarecrow
On Monday, 15 October 2012 at 20:58:36 UTC, Dmitry Olshansky wrote: A hybrid. I'm currently trying to get into Phobos: https://github.com/D-Programming-Language/phobos/pull/787 I'll have to look it over in more detail another time. Although another question comes to mind. How many

How to define an interator to provide array like behaviour in a class?

2012-10-16 Thread Gary Willoughby
I want to do something like this (Collection is a custom type): Collection x = new Collection(); x.add(something); x.add(somethingElse); foreach(type value; x) { writeln(value); } Collection is a class with a private array member variable which actually holds the collection data entered

Re: How to define an interator to provide array like behaviour in a class?

2012-10-16 Thread Jonathan M Davis
On Wednesday, October 17, 2012 00:03:46 Gary Willoughby wrote: I want to do something like this (Collection is a custom type): Collection x = new Collection(); x.add(something); x.add(somethingElse); foreach(type value; x) { writeln(value); } Collection is a class with a private

with(a,b,c, ...) blocks..

2012-10-16 Thread Era Scarecrow
I haven't found this specific topic anywhere in the archives so I'll throw it out there for feedback. [quote] TDPL pg. 81 There is no ambiguity-related danger in using nested 'with's because the language disallows shadowing of a symbol introduced by an outer with by a symbol introduced by

optlink and weak symbols

2012-10-16 Thread Ellery Newcomer
I am interfacing with some C code [python.dll], which has some structs declared like so: PyTypeObject PyType_Type; I wish to be able to link to PyType_Type like so: extern(C) __gshared PyTypeObject PyType_Type; in linux, I can do exactly that, but optlink is generating a new memory location