Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread tsalm
Le Wed, 10 Dec 2008 03:16:49 +0100, Denis Koroskin <[EMAIL PROTECTED]> a écrit: On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley <[EMAIL PROTECTED]> wrote: On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote: class C { final void add(T...)(T t) { foreach(int i,_

Re: changing array lengths

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 11:54 PM, Ellery Newcomer <[EMAIL PROTECTED]> wrote: > Does the following totally not make sense? I think it should work. > > int[] a = new int[10]; > > a.length += 30; > It's a weird limitation that's been around forever. Ugh. Here, have this. T[] resize(T)(ref T[] arr,

changing array lengths

2008-12-09 Thread Ellery Newcomer
Does the following totally not make sense? I think it should work. int[] a = new int[10]; a.length += 30;

Re: isExist in associate array

2008-12-09 Thread Ellery Newcomer
raymond wrote: how to check if array key exist in array or not? for example char[] [char[]] t; t["tes1"]="val1"; t["tes2"]="val2"; t["tes3"]="val3"; if (t["test1"]) writefln("NONE"); if("test1" in t) writefln("exists");

isExist in associate array

2008-12-09 Thread raymond
how to check if array key exist in array or not? for example char[] [char[]] t; t["tes1"]="val1"; t["tes2"]="val2"; t["tes3"]="val3"; if (t["test1"]) writefln("NONE");

Re: Freeing of memory (garbage collection)

2008-12-09 Thread bearophile
Steven Schveighoffer: > One thing you can do, that nobody has mentioned yet, is delete memory that > you have allocated using the GC. Leaving the GC manage and free your memory is usually OK. Managing manually your memory allocated from the C heap is doable. But freeing manually and forcefully

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread Denis Koroskin
On Wed, 10 Dec 2008 03:24:48 +0300, Jarrett Billingsley <[EMAIL PROTECTED]> wrote: On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote: class C { final void add(T...)(T t) { foreach(int i,_;T) _add(t[i]); } //. } (new C).add(something, otherthings, thisT

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 7:00 PM, BCS <[EMAIL PROTECTED]> wrote: > class C > { > final void add(T...)(T t) > { > foreach(int i,_;T) > _add(t[i]); > } > //. > } > > > (new C).add(something, otherthings, thisToo); If all the params are the same type, typesafe variadics are

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread BCS
Reply to TSalm, Hello, How to implement an object that can do this : myClass.add(something)(otherthings)(thisToo); Is it possible ? TIA, TSalm if you don't mind dropping the )( class C { final void add(T...)(T t) { foreach(int i,_;T) _add(t[i]); } //. }

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread Denis Koroskin
On Wed, 10 Dec 2008 02:40:47 +0300, tsalm <[EMAIL PROTECTED]> wrote: Hello, How to implement an object that can do this : myClass.add(something)(otherthings)(thisToo); Is it possible ? TIA, TSalm Yes: import std.stdio; class MyClass { class MyClassAdder { MyClassAdder opCall(

Re: myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread Ellery Newcomer
tsalm wrote: Hello, How to implement an object that can do this : myClass.add(something)(otherthings)(thisToo); Is it possible ? TIA, TSalm Something like this might work: class MyClass{ int[] stuff; alias add opCall; MyClass add(int k){ stuff ~= k; return this; } }

myClass.add(something)(otherthings)(thisToo);

2008-12-09 Thread tsalm
Hello, How to implement an object that can do this : myClass.add(something)(otherthings)(thisToo); Is it possible ? TIA, TSalm

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Christopher Wright
Daniel White wrote: That would be a bad idea. Then how would you do manual memory management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. If you have a reference to the mem

Re: Nested Base classes

2008-12-09 Thread BCS
Reply to llee, I'm trying derive a class from a nested base class. The programs' structure is as follows: class A { class B { } } class C : A { class D : B { } } I'm using version 2.014 of the dmd compiler, and the above fails. The compiler error reports that B is nested in class A and not C. D

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 2:53 PM, Daniel White <[EMAIL PROTECTED]> wrote: > Jarrett Billingsley Wrote: > >> On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> >> That would be a bad idea. Then how would you do manual memory >> >> management in the few cases that absolutely r

Re: Nested Base classes

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 2:08 PM, llee <[EMAIL PROTECTED]> wrote: > I'm trying derive a class from a nested base class. The programs' structure > is as follows: > > class A > { > class B > { > } > } > > class C : A > { > class D : B > { > } > } > > I'm using version 2.014 of

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
Jarrett Billingsley Wrote: > On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: > >> That would be a bad idea. Then how would you do manual memory > >> management in the few cases that absolutely require it? > > > > Two ways. Either: > > > > a: being able to lock the variabl

Nested Base classes

2008-12-09 Thread llee
I'm trying derive a class from a nested base class. The programs' structure is as follows: class A { class B { } } class C : A { class D : B { } } I'm using version 2.014 of the dmd compiler, and the above fails. The compiler error reports that B is nested in clas

Re: Cyclic Dependencies

2008-12-09 Thread Steven Schveighoffer
"Jarrett Billingsley" wrote > It can obviously be argued that since the operands of ?: are constant, > the compiler _could_ figure out that they should be of type wchar[], > but that would make the semantic analysis more complicated, and since > appending 'w' to the strings is far easier, it probab

Re: Cyclic Dependencies

2008-12-09 Thread Ary Borenszweig
Jarrett Billingsley wrote: On Tue, Dec 9, 2008 at 12:00 PM, Ellery Newcomer <[EMAIL PROTECTED]> wrote: Derek Parnell wrote: > It is not a bug. A string literal such as "true" is a char[] type (UTF8), and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). Which would then beg th

Re: Cyclic Dependencies

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 12:00 PM, Ellery Newcomer <[EMAIL PROTECTED]> wrote: > Derek Parnell wrote: > > It is not a bug. A string literal such as "true" is a char[] type (UTF8), >> >> and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). > > Which would then beg the obvious > > wcha

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 11:08 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> That would be a bad idea. Then how would you do manual memory >> management in the few cases that absolutely require it? > > Two ways. Either: > > a: being able to lock the variable so that the garbage collector > can't to

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
Lars Ivar Igesund wrote: Tango 0.99.7 doesn't support DMD 1.037 - either use DMD 1.033 or check out Tango trunk. Say what you will, I got it to work :) I also experienced the crash on 1.030, 1.033, and 1.035 variously on linux and windows, so 1.037 was just to see if it had been fixed by

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
Derek Parnell wrote: > It is not a bug. A string literal such as "true" is a char[] type (UTF8), and the compiler will not implicitly convert UTF8 to UTF16 (wchar[]). Which would then beg the obvious wchar[] w = "true";

Re: Cyclic Dependencies

2008-12-09 Thread Ellery Newcomer
torhu wrote: You can't use module constructors (static this) in modules that import each other. So THAT'S why I couldn't replicate it :)

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
> That would be a bad idea. Then how would you do manual memory > management in the few cases that absolutely require it? Two ways. Either: a: being able to lock the variable so that the garbage collector can't touch it until you unlock it. b: Using a slightly different version of malloc (say '

Re: Cyclic Dependencies

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:52 AM, Steven Schveighoffer <[EMAIL PROTECTED]> wrote: > I'm not sure about this problem. I've not encountered it, but it sounds > weird that it would cause a runtime error... It is weird. [a.d] module a; import b; static this(){} void main(){} [b.d] mod

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:42 AM, Jarrett Billingsley <[EMAIL PROTECTED]> wrote: > On Tue, Dec 9, 2008 at 9:16 AM, Daniel White <[EMAIL PROTECTED]> wrote: >> Thanks for that reply. I wonder if extending automatic garbage >> collection for malloced memory would be a good idea... > > That would be a ba

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Jarrett Billingsley
On Tue, Dec 9, 2008 at 9:16 AM, Daniel White <[EMAIL PROTECTED]> wrote: > Thanks for that reply. I wonder if extending automatic garbage > collection for malloced memory would be a good idea... That would be a bad idea. Then how would you do manual memory management in the few cases that absolute

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Steven Schveighoffer
"Daniel White" wrote > Thanks for that reply. I wonder if extending automatic garbage > collection for malloced memory would be a good idea... > >> Only stuff like dynamic >> arrays, AAs and new'ed stuff gets cleaned up by the GC. > > For the above types of allocating memory, is there a way to 'loc

Re: Cyclic Dependencies

2008-12-09 Thread Steven Schveighoffer
"Ellery Newcomer" wrote > Hello all, > > I began learning D a few months ago, and now I have a question about > cyclic dependencies (and some random whining). > > I come from a java background and have had no serious exposure to C++. In > java, cyclic dependencies are legit to the best of my know

Re: Freeing of memory (garbage collection)

2008-12-09 Thread Daniel White
Thanks for that reply. I wonder if extending automatic garbage collection for malloced memory would be a good idea... > Only stuff like dynamic > arrays, AAs and new'ed stuff gets cleaned up by the GC. For the above types of allocating memory, is there a way to 'lock' a variable and say to D, "d

Re: Freeing of memory (garbage collection)

2008-12-09 Thread bearophile
Dan W: > 1: Even though D has an automatic garbage collector, is one still > allowed to free the memory of a malloced array manually (using free > () ), to avoid pauses in the program? Other people here will just answer your question. But remember that in D manual memory management is done only i

Re: Print a PDF

2008-12-09 Thread John
BLS Wrote: > John schrieb: > > BCS Wrote: > > > >> Reply to John, > >> > >>> Hello! > >>> > >>> I'm wanting to use D to send a PDF to a printer. Is there an easy way > >>> to do this? Also, I may need to set which tray to go to and whether it > >>> should duplex or not. > >>> > >>> Could someone

Re: Cyclic Dependencies

2008-12-09 Thread Denis Koroskin
On Tue, 09 Dec 2008 10:26:29 +0300, Ellery Newcomer <[EMAIL PROTECTED]> wrote: Also, I would be trying to compile with DMD, but I have evidently managed to crash the compiler, and I don't know if it's DMD's fault or mine. It reports an Internal Error in e2ir.c at line 3904. (not being a C++

Re: CTFE - filling an array

2008-12-09 Thread Christopher Wright
The Anh Tran wrote: static double[N] dd = void; dd is not a compile-time constant. static auto tmp = f!(N).fn(dd); The initializer of tmp must be a compile-time constant, but since dd is not a compile-time constant, you can't use CTFE on fn.

Re: Inline Assembler: Getting the offset of a label. How?

2008-12-09 Thread Kagamin
poly Wrote: > asm > { > call Label1; > Label1: pop ECX; > mov EAX, Label1; //error reported on this line > } I tried several tricks, seems like compiler doesn't support this.

Re: Cyclic Dependencies

2008-12-09 Thread Lars Ivar Igesund
Ellery Newcomer wrote: > Hello all, > > I began learning D a few months ago, and now I have a question about > cyclic dependencies (and some random whining). > > I come from a java background and have had no serious exposure to C++. > In java, cyclic dependencies are legit to the best of my know

Re: Cyclic Dependencies

2008-12-09 Thread torhu
Ellery Newcomer wrote: When I first started learning D I decided that a good way to learn it would be by porting a popular java api (mind, I didn't say intelligent), which came complete with a few cyclic dependencies. At the moment, I'm using GDC, and it refuses to swallow cyclic dependencies.

Re: Cyclic Dependencies

2008-12-09 Thread Derek Parnell
On Tue, 09 Dec 2008 01:26:29 -0600, Ellery Newcomer wrote: > > wchar[] w = (true)? "true":"false"; > > --> Error: cannot implicitly convert expression ("true") of type char[] > to wchar[] > > or should it be reported as a bug? It is not a bug. A string literal such as "true" is a char[] type

CTFE - filling an array

2008-12-09 Thread The Anh Tran
Hi, I would like to pre-create a double array, each element is calculated by a function. //- import std.stdio; import std.conv; import std.string; template f(int N) { bool fn(double[] tb) { for (int i = 1; i <

Re: Print a PDF

2008-12-09 Thread BLS
John schrieb: BCS Wrote: Reply to John, Hello! I'm wanting to use D to send a PDF to a printer. Is there an easy way to do this? Also, I may need to set which tray to go to and whether it should duplex or not. Could someone help me out? THANKS! You would do it the same way that it would b