Re: Garbage collection in D

2009-06-04 Thread Frits van Bommel
bearophile wrote: Frits van Bommel: LDC actually still does a dynamic allocation there because it doesn't eliminate dynamic allocations in loops. I have compiled the loop in foo() with LDC: [snip] scope auto item = new AllocationItem(i); [snip] The asm of the core of the

Re: Garbage collection in D

2009-06-04 Thread Frits van Bommel
bearophile wrote: Rainer Deyke: D's performance is unexpectedly bad, so much that I expect that it might be using dynamic memory allocation anyway despite the 'scope' keyword. Java is clever in that it eliminates unnecessary dynamic memory allocations automatically.< I think Java here is doi

Re: expression

2009-05-30 Thread Frits van Bommel
Ellery Newcomer wrote: what is the purpose of the expression grammar Expression: AssignExpression AssignExpression , Expression ? (emphasis on the comma) To allow two expressions separated by a comma to be another expression. This is only useful if the expression before the

Re: Theory question

2009-05-21 Thread Frits van Bommel
BCS wrote: Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); and A a; B b; a = b; b.Foo(); struct A { int i; void Foo() { i = 42; } } alias A B; The first case will set a.i to 42, the second will set b.i. And with op

Re: -run with import gives OPTLINK Error 42

2009-05-16 Thread Frits van Bommel
MikeWh wrote: I have 2 files: 1. a main file called caller.d, 2. a file to import called sub.d. They are: // caller.d import sub; import std.stdio; void main(){ sub mySub= new sub; writefln( mySub.one() ); } // sub.d class sub{ int one(){ return 1; } } Ev

Re: struct opCmp?

2009-05-15 Thread Frits van Bommel
Nick Sabalausky wrote: Can anyone think of a reasonable case where it would actually make sense to override opCmp, but not opEquals? (that is, without bastardizing them like in a "C++ streams" kind of way) How about a struct you want to be opCmp()-comparable (which, according to the spec, t

Re: dmd on ubuntu installation

2009-05-10 Thread Frits van Bommel
Michael P. wrote: But when I type dmd in the terminal, I get this: mich...@ubuntu:~$ dmd bash: /usr/local/bin/dmd: Permission denied mich...@ubuntu:~$ Do you know why? Looks like you didn't "chmod +x" it. Zip files don't store *nix permissions...

Re: No segfault -> null == ""

2009-03-31 Thread Frits van Bommel
Unknown W. Brackets wrote: In the case of arrays, "test == null" and "test is null" should be the same operation. They're not the same operation. (Though there was quite a large debate on these newsgroups a while back because a lot of people thought they *should* be, as you said) The differ

Re: return *(cast(T*)vPtr) and OutOfMemoryException

2009-02-14 Thread Frits van Bommel
TSalm wrote: Hello, In the code below, why the first Stdout throws a Exception when the second doesn't ? /* CODE */ import tango.io.Stdout; struct VoidPtr(T) { void* vPtr; void value(T val) { vPtr = &val; Here you're storing a pointer to a non-ref parameter

Re: Example Attached

2009-02-13 Thread Frits van Bommel
Mike Parker wrote: Heinz wrote: torhu Wrote: On 10.02.2009 19:51, Heinz wrote: Heinz Wrote: I attached a rar file with the sources just to see what i'm talking about. The example is from the DMD site. Included is the extern D (ok) and the extern C (fails). To compile open "compile.bat" and

Re: ASM

2009-02-13 Thread Frits van Bommel
Zarathustra wrote: I need to make some calculations with asm in D. Could somebody write how to do this, micro tutorial ;p x86 Especially inc, dec, add, sub, mul, imul, div, idiv instructions. Also ja, jb, jg, jl, jo; jc ... and, or, not, xor, sal, shl, sar, shr First of all: unless you really n

Re: how to initialize an array of struct

2009-02-12 Thread Frits van Bommel
bearophile wrote: westcity Wrote: But, the compiler report "Error: array initializers as expressions are not allowed". Then, how do I initialize an array of struct ? Move the definition out of main (note that ; after the struct isn't required): struct Point { float x, y, z; } Point[3]

Re: how to initialize an array of struct

2009-02-12 Thread Frits van Bommel
westcity wrote: My code is as following: struct Point { float x, y, z ; }; int main () { Point[3] pts = [ {1.0, 0.0, 0.0} , {0.0, 1.0, 0.0} , {0.0, 0.0, 1.0} ]; return 0 ; } But, the compiler report "Error: array

Re: Compare two objects

2009-02-10 Thread Frits van Bommel
Qian Xu wrote: Hi All, I want to test, if two objects are equal. The rules are as follows: 1. When both are null, it should return true. 2. When one of them is null, it should return false. 3. When both not null, then compare their values (as two strings) ((a is b) || (a && a == b)) Note

Re: How to get the implementer of an interface?

2009-01-22 Thread Frits van Bommel
Denis Koroskin wrote: On Thu, 22 Jan 2009 11:17:20 +0300, Qian Xu wrote: how to get the implementer of an interface? [snip] Try the following: writefln(cast(Object)i); Or writefln((cast(Object)i).classinfo.name); if you want the class name, not the result of toString (which is only

Re: query interface

2009-01-21 Thread Frits van Bommel
Qian Xu wrote: Hi All, can D check, whether a class A an Interface B supports? like: if (supports(class_A, intf_B)) if (is(class_A : intf_B)) tests if 'class_A' is implicitly convertible to 'intf_B'. If the first is a class and the second an interface, that's equivalent to the class

Re: distinguish between classes and structures

2008-12-15 Thread Frits van Bommel
Weed wrote: In C++, we had the problem - "slicing" objects. In D this problem is solved inability to inherit from structs. Without inheritance of structs many things are not possible, compared with C++. Why, instead of the complete inability to inherit, just do not make impossible to up casting

Re: confusing (buggy?) closure behaviour

2008-12-12 Thread Frits van Bommel
Zoran Isailovski wrote: I'm an experienced C#, Java and Python programmer, and have employed closures (and C# delegates) upon numerous occasions. While experimenting with D closures and delegates, I was stroke by a phenomenon I cannot explain. Here's the code: [snip] Handler incBy(int n) {

Re: including a file

2008-11-10 Thread Frits van Bommel
Christopher Wright wrote: Jarrett Billingsley wrote: On Sun, Nov 9, 2008 at 10:18 PM, James <[EMAIL PROTECTED]> wrote: i created to include file, 1 with 'module xxx' declaration and the other without it. but i still can import both files. what is the diff here? Not a lot. The module decla

Re: including a file

2008-11-10 Thread Frits van Bommel
Jarrett Billingsley wrote: On Sun, Nov 9, 2008 at 10:18 PM, James <[EMAIL PROTECTED]> wrote: i created to include file, 1 with 'module xxx' declaration and the other without it. but i still can import both files. what is the diff here? Not a lot. The module declaration doesn't serve much pu