Re: Is there a weak pointer or references in D?

2013-01-11 Thread Charles Hixson
On 01/11/2013 01:12 PM, Era Scarecrow wrote: On Friday, 11 January 2013 at 18:22:30 UTC, Charles Hixson wrote: I was looking for a way to create a weak reference to either a struct or a class. I need to be able to use it to automatically generate an active reference on access. (I intend to do th

Re: Is there a weak pointer or references in D?

2013-01-11 Thread Jonathan M Davis
On Saturday, January 12, 2013 00:51:02 Nekroze wrote: > On Friday, 11 January 2013 at 22:07:45 UTC, monarch_dodra wrote: > > Honest question: How can you have a weak pointer in a language > > that is garbage collected? > > I beleive the OP means something like pythons weakref > (http://docs.python

Re: Is there a weak pointer or references in D?

2013-01-11 Thread Era Scarecrow
I had the impression in the original text you wanted to auto allocate memory when accessing the field, not as described here. Might be time to re-watch the remainder of the computer science lectures. On Friday, 11 January 2013 at 23:51:04 UTC, Nekroze wrote: A weak reference to an object is n

Re: Is there a weak pointer or references in D?

2013-01-11 Thread Nekroze
On Friday, 11 January 2013 at 22:07:45 UTC, monarch_dodra wrote: Honest question: How can you have a weak pointer in a language that is garbage collected? I beleive the OP means something like pythons weakref (http://docs.python.org/2/library/weakref.html) that is qoute: A weak reference to

Re: Passing shared delegates

2013-01-11 Thread mist
Do not have time to test code right now but first guess it is related to parsing differences for delegates and usual functions. Delegates can have shared/const applied to both delegate type itself and context of underlying function. Those are different beasts and no wonder type system complains

Re: Is there a weak pointer or references in D?

2013-01-11 Thread monarch_dodra
On Friday, 11 January 2013 at 21:12:40 UTC, Era Scarecrow wrote: I've tried making a weakPtr template function, however it complains about a nested function call (perhaps cause it was within a unittest); Shows the problem(s) on that side. Honest question: How can you have a weak pointer in a

Re: Is there a weak pointer or references in D?

2013-01-11 Thread Era Scarecrow
On Friday, 11 January 2013 at 18:22:30 UTC, Charles Hixson wrote: I was looking for a way to create a weak reference to either a struct or a class. I need to be able to use it to automatically generate an active reference on access. (I intend to do this by rolling in data from a file.) Any

Is there a weak pointer or references in D?

2013-01-11 Thread Charles Hixson
I was looking for a way to create a weak reference to either a struct or a class. I need to be able to use it to automatically generate an active reference on access. (I intend to do this by rolling in data from a file.) Any guidance as to where I should look?

Passing shared delegates

2013-01-11 Thread Martin Drasar
Hi, when trying to compile this code: > module main; > > class A > { > shared void foo() {} > } > > class B > { > void bar(shared void delegate() f) {} > } > > void main() > { > auto a = new A(); > auto b = new B(); > > b.bar(&a.foo); > } I get this error: > main.d(18): Error: can

Re: Reading array of numbers from file

2013-01-11 Thread monarch_dodra
On Friday, 11 January 2013 at 12:17:32 UTC, evilrat wrote: On Friday, 11 January 2013 at 09:44:31 UTC, Lubos Pintes wrote: Hi, Do I correctly suppose this is not possible? Because I don't understand fully the compiler error. import std.stdio; void main() { int[] a; stdin.readf(" %s",&a); w

Re: Reading array of numbers from file

2013-01-11 Thread evilrat
oops, for reading by line it is not std.file.byLine but std.stdio.File.byLine http://dlang.org/phobos/std_stdio.html#.File.byLine well, use docs, there are lot of info for starters

Re: Reading array of numbers from file

2013-01-11 Thread evilrat
On Friday, 11 January 2013 at 09:44:31 UTC, Lubos Pintes wrote: Hi, Do I correctly suppose this is not possible? Because I don't understand fully the compiler error. import std.stdio; void main() { int[] a; stdin.readf(" %s",&a); writeln(a); } what is the definition of format of "array

Re: Unicode symbols in the identifiers

2013-01-11 Thread Regan Heath
On Fri, 11 Jan 2013 02:09:29 -, Andrey wrote: Should these variants serve as identifiers? See: http://dlang.org/lex.html#Identifier "Identifiers start with a letter, _, or universal alpha, and are followed by any number of letters, _, digits, or universal alphas. Universal alphas are

Re: Unicode symbols in the identifiers

2013-01-11 Thread Andrey
According to the specification D doesn't necessarly support unicode identifiers: "Identifiers start with a letter, _, or universal alpha, and are followed by any number of letters, _, digits, or universal alphas. Universal alphas are as defined in ISO/IEC 9899:1999(E) Appendix D. (This is the

Re: Unicode symbols in the identifiers

2013-01-11 Thread Jacob Carlborg
On 2013-01-11 03:09, Andrey wrote: Should these variants serve as identifiers? auto x²; //fails to compile: char 0x00b2 not allowed in identifier, unsupported char 0xb2 (why? is it not a digit?) Same for ⅀, ∫ and etc. Official documentations says: « D source text can be in one of the following

Re: Unicode symbols in the identifiers

2013-01-11 Thread evilrat
On Friday, 11 January 2013 at 07:47:03 UTC, Andrey wrote: Apart from that, try this code: int в_квадрате(int num) { return num*num; } writeln(2.в_квадрате); You get: Error: found 'в_квадрате' when expecting ',' don't have any errors with this code(dmd 2.061, win8) but x² as identifier is r

Reading array of numbers from file

2013-01-11 Thread Lubos Pintes
Hi, Do I correctly suppose this is not possible? Because I don't understand fully the compiler error. import std.stdio; void main() { int[] a; stdin.readf(" %s",&a); writeln(a); }

Re: this(this) / opAssign

2013-01-11 Thread Namespace
On Thursday, 10 January 2013 at 23:49:40 UTC, monarch_dodra wrote: On Thursday, 10 January 2013 at 23:37:14 UTC, Namespace wrote: Without a declared opAssign, this S s3; s3 = s1; also calls the postblit. That is strange. If there is no user declared opAssign, then opAssign is implemented

Re: Unicode symbols in the identifiers

2013-01-11 Thread Andrey
Forgot to mention. Linux 64 bit, D version 2.060