Re: optlink and weak symbols

2012-10-16 Thread Jacob Carlborg
On 2012-10-17 07:07, Ellery Newcomer wrote: 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 o

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 08:14:45 Jacob Carlborg wrote: > On 2012-10-17 00:23, Jonathan M Davis wrote: > > 2. Or make it a range (see > > http://dlang.org/statement.html#foreach_with_ranges and > > http://ddili.org/ders/d.en/ranges.html ), which would probably be a bad > > idea, since contain

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

2012-10-16 Thread Jacob Carlborg
On 2012-10-17 00:23, Jonathan M Davis wrote: 2. Or make it a range (see http://dlang.org/statement.html#foreach_with_ranges and http://ddili.org/ders/d.en/ranges.html ), which would probably be a bad idea, since containers really shouldn't be ranges. Why is that a bad idea? -- /Jacob Carlborg

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

2012-10-16 Thread ixid
Theoretically legal... void func() //in/out contracts body with (E) { //with replaces normal block } This seems sensible. Multiple with seems like a recipe for confusion and member name clashes.

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

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 a

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

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 algorith

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 vi

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 looking

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

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 s

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 Benjami

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 Davis 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 cast in stone:

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 Hixson 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 problematic, as there isn't, ac

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 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 problematic, as there isn'

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

Re: Stack trace output on windows

2012-10-16 Thread Benjamin Thaut
Am 16.10.2012 18:38, schrieb Regan Heath:> I have some C/C++ code which handles windows SEH exceptions and can > output (in debug mode) a stack trace, for example: > > But, it doesn't output symbol names for the D functions. Does anyone > know why not? Is there some reason it cannot? Perhaps t

Stack trace output on windows

2012-10-16 Thread Regan Heath
I have some C/C++ code which handles windows SEH exceptions and can output (in debug mode) a stack trace, for example: This process has performed an illegal operation and has to close. Exception code: 0xC005 Exception flags: 0x Exception address:0x00401CEF Number of p

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 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 design

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 wer

Problem with UFCS

2012-10-16 Thread Michael
Hello! I have been using D for a while, but only recently paid attention to UFCS. For some reason, I can't convince my code to compile properly: void main() { import std.range, std.stdio; auto sqrs = sequence!((a,n) => n*n)(0); auto fibs = recurrence!((a,n) =

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 some-compiler-happens-to-implement-it-like-that-today-theref

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 expresssion

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: 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 w