Re: Return const object through mutable Object

2012-04-16 Thread Jacob Carlborg
On 2012-04-16 02:33, Jonathan M Davis wrote: It definitely looks like a bug. Whether it returns Foo or Object should have no effect on constness, and since f is a member variable of Foo, and the this pointer/reference is const, bar is going to have to return a const reference to it, which the

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread Andrea Fontana
Are you on linux/windows/mac? On Saturday, 14 April 2012 at 19:05:40 UTC, ReneSac wrote: I have this simple binary arithmetic coder in C++ by Mahoney and translated to D by Maffi. I added notrow, final and pure and GC.disable where it was possible, but that didn't made much difference.

Re: A general tag

2012-04-16 Thread Denis Shelomovskij
15.04.2012 0:31, Xan написал: On Saturday, 14 April 2012 at 19:40:06 UTC, Aleksandar Ružičić wrote: On Saturday, 14 April 2012 at 19:17:52 UTC, Xan wrote: Hi, I try to translate a script I wrote in Fantom [www.fantom.org]. In my script, I have a type Tag defined as a triple of: - String (the

Re: making ntfs do faster deletes

2012-04-16 Thread Kagamin
Do you use FILE_FLAG_SEQUENTIAL_SCAN too?

Re: floats default to NaN... why?

2012-04-16 Thread Jerome BENOIT
On 16/04/12 04:38, F i L wrote: Of course FP numbers are meant for coders... they're in a programming language. They are used by coders, and not every coder that uses FP math *has* to be well trained in the finer points of mathematics simply to use a number that can represent fractions in a

Re: Thread join behaviour

2012-04-16 Thread Russel Winder
On Sun, 2012-04-15 at 23:36 +0200, Somedude wrote: [...] It works here (DMD 2.058 win32), even without function. It also works for me with 2.058 on x86_64 Linux. So the conclusion is that 2.059 is broken. I'll update the issue I set up for this. -- Russel.

Re: shared status

2012-04-16 Thread Zardoz
El Sun, 15 Apr 2012 23:05:55 +0200, Kapps escribió: On Saturday, 14 April 2012 at 10:48:16 UTC, Luis Panadero Guardeño wrote: What is the status of shared types ? I try it with gdmd v4.6.3 And I not get any warring/error when I do anything over a shared variable without using atomicOp.

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread Steven Schveighoffer
On Sat, 14 Apr 2012 22:31:40 -0400, Jonathan M Davis jmdavisp...@gmx.com wrote: On Sunday, April 15, 2012 04:21:09 Joseph Rushton Wakeling wrote: On 14/04/12 23:03, q66 wrote: He also uses a class. And -noboundscheck should be automatically induced by -release. ... but the methods are

Re: this() const

2012-04-16 Thread sclytrack
On 04/15/2012 11:04 PM, Simon wrote: On 15/04/2012 21:07, Trass3r wrote: Am 15.04.2012, 21:20 Uhr, schrieb sclytrack sclytr...@hotmail.com: this( const size_t step) const { this.step = step; } Error: cannot modify const/immutable/inout expression this.step Is this the expected behavior?

const AB c = {a,20, numbers};

2012-04-16 Thread sclytrack
struct AB { int a; int b; int [] numbers; } int main() { int a = 300; const int [] numbers = new int[2]; const AB c = {a,20, numbers}; // line 66 writeln(c); return 0; } -debug -unittest

Re: making ntfs do faster deletes

2012-04-16 Thread Jay Norwood
On Monday, 16 April 2012 at 09:16:09 UTC, Kagamin wrote: Do you use FILE_FLAG_SEQUENTIAL_SCAN too? The std.file.write does use FILE_FLAG_SEQUENTIAL_SCAN void write(in char[] name, const void[] buffer) my experimental code to create the empty file also uses it, but it doesn't write any

Re: const AB c = {a,20, numbers};

2012-04-16 Thread bearophile
sclytrack: struct AB { int a; int b; int [] numbers; } int main() { int a = 300; const int [] numbers = new int[2]; const AB c = {a,20, numbers}; // line 66 writeln(c); return 0; } -debug

Re: Win GUI Single Exe - Newbie

2012-04-16 Thread Paul
On Sunday, 8 April 2012 at 10:26:10 UTC, Jacob Carlborg wrote: On 2012-04-07 23:34, vmars316 wrote: On Saturday, 7 April 2012 at 12:25:27 UTC, Jacob Carlborg wrote: On 2012-04-06 17:37, Jesse Phillips wrote: Building stand alone executables with DWT works great. DWT doesn't depend on any

Re: const AB c = {a,20, numbers};

2012-04-16 Thread sclytrack
const numbers = new int[2]; const c = const(AB)(a, 20, numbers); writeln(c); } Bye, bearophile That's exactly what I needed, thanks.

Re: Contracts inheritance

2012-04-16 Thread Eyyub
On Friday, 13 April 2012 at 22:23:25 UTC, Ali Çehreli wrote: On 04/13/2012 03:07 PM, Eyyub wrote: Hai, After watching Walter's video at Lang.NEXT, I have wanted to know how contracts inheritance works. In the following code, I don't understand why foo.bar(2) works...but with the sames

Re: Win GUI Single Exe - Newbie

2012-04-16 Thread Jacob Carlborg
On 2012-04-16 19:04, Paul wrote: Is installing and using DWT really this involved? I spent hours figuring out github, cloning the repository (I think). The git submodule commands never ran w/o errors. I was quite frustrated. Thanks for any additional comments. Do you know of a tutorial that

Re: Templates in classes = what is wrong?

2012-04-16 Thread Xan
On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote: On 04/15/2012 11:39 AM, Xan wrote: On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman wrote: On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg = Algorisme!(int,int); Should be: auto

Re: A general tag

2012-04-16 Thread Xan
Uf!, it's more than I can process It's really a **complicated** thing to do that in D. On Monday, 16 April 2012 at 07:50:28 UTC, Denis Shelomovskij wrote: 15.04.2012 0:31, Xan написал: On Saturday, 14 April 2012 at 19:40:06 UTC, Aleksandar Ružičić wrote: On Saturday, 14 April 2012 at

Re: Templates in classes = what is wrong?

2012-04-16 Thread Ali Çehreli
On 04/16/2012 11:48 AM, Xan wrote: On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote: On 04/15/2012 11:39 AM, Xan wrote: On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman wrote: On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg =

Re: Thread join behaviour

2012-04-16 Thread Somedude
Le 15/04/2012 20:40, Russel Winder a écrit : On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...] (my old GDC needs the explicit function, no idea if newer frontends still require that) OK, works for me with GDC as well, DMD is broken! I'll file a bug report. Did you file a bug

No stack address

2012-04-16 Thread Somedude
I'm trying to compile a D source on win32 with DMD 2.059, and I get this: PS E:\DigitalMars\dmd2\samples rdmd xinoksort.d OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 23: No Stack

Re: const AB c = {a,20, numbers};

2012-04-16 Thread sclytrack
On 04/16/2012 08:15 PM, sclytrack wrote: const numbers = new int[2]; const c = const(AB)(a, 20, numbers); writeln(c); } Bye, bearophile That's exactly what I needed, thanks. Seems to be forwarded to the constructor if there is one. (untested code) struct B { int [] _list;

Re: No stack address

2012-04-16 Thread Andrej Mitrovic
On 4/16/12, Somedude lovelyd...@mailmetrash.com wrote: OPTLINK : Warning 134: No Start Address This means you're missing a void main or int main function. You can pass --main to rdmd to add it automatically (useful when e.g. unittesting).

Re: Contracts inheritance

2012-04-16 Thread Mike Wey
On 04/16/2012 08:15 PM, Eyyub wrote: On Friday, 13 April 2012 at 22:23:25 UTC, Ali Çehreli wrote: On 04/13/2012 03:07 PM, Eyyub wrote: Hai, After watching Walter's video at Lang.NEXT, I have wanted to know how contracts inheritance works. In the following code, I don't understand why

Re: const AB c = {a,20, numbers};

2012-04-16 Thread Timon Gehr
On 04/16/2012 06:49 PM, bearophile wrote: sclytrack: ... Shouldn't the code above accept the const(int []) ? I think it is a bug that it does not. I think you are asking too much to the poor type system. You are giving a const dynamic array (that's not a value) to assign it to a

Aquivalent References as in C++?

2012-04-16 Thread Namespace
Hi, I have a few questions about D and could use some help. For instance, how can i rebuild such a behavior? class Foo { public: Foo(const Bar b) { At C++ you can ensure that a reference is requested and must not null. Nevertheless lvalues are functional, which means Foo(Bar(42)) would operate

Re: Aquivalent References as in C++?

2012-04-16 Thread Kevin Cox
On Apr 16, 2012 5:29 PM, Namespace rswhi...@googlemail.com wrote: That case I would like to prevent, but at the same time allow Ivalues. How does that work in D classes? As far as I know this operates with structs, but shouldn't it be possible with classes and objects too? I would recommend

Re: Aquivalent References as in C++?

2012-04-16 Thread Timon Gehr
On 04/16/2012 11:25 PM, Namespace wrote: Hi, I have a few questions about D and could use some help. For instance, how can i rebuild such a behavior? class Foo { public: Foo(const Bar b) { At C++ you can ensure that a reference is requested and must not null. Nevertheless lvalues are

Re: Aquivalent References as in C++?

2012-04-16 Thread bearophile
Namespace: how can i rebuild such a behavior? class Foo { public: Foo(const Bar b) { In D struct instances are values, and you can manage them as values, or as a pointer to value (or pointer to pointer to value, etc). In D class instances are always managed by reference, and such

Re: const AB c = {a,20, numbers};

2012-04-16 Thread bearophile
Timon Gehr: auto c = AB(a, 20, numbers) = AB c = {a, 20, numbers}; auto c = const(AB)(a, 20, numbers) = const AB c = {a, 20, numbers}; I think your second equivalence is wrong: const c = AB(a, 20, numbers) = const AB c = {a, 20, numbers}; Bye, bearophile

Re: Aquivalent References as in C++?

2012-04-16 Thread Namespace
This is what I am actually doing at the moment, but I thougth that in a modern language like D, it is possible to have non-null references to avoid such constructs with assert. My last hope was that an explicit ref would allow me both: non-null references _and_ lvalues, at least for objects.

Re: const AB c = {a,20, numbers};

2012-04-16 Thread Timon Gehr
On 04/16/2012 11:43 PM, bearophile wrote: Timon Gehr: auto c = AB(a, 20, numbers)=AB c = {a, 20, numbers}; auto c = const(AB)(a, 20, numbers)=const AB c = {a, 20, numbers}; I think your second equivalence is wrong: const c = AB(a, 20, numbers)=const AB c = {a, 20, numbers};

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread ReneSac
On Monday, 16 April 2012 at 07:28:25 UTC, Andrea Fontana wrote: Are you on linux/windows/mac? Windows. My main question is now *WHY* D is slower than C++ in this program? The code is identical (even the same C functions) in the performance-critical parts, I'm using the same compiler backend

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread Timon Gehr
On 04/17/2012 12:24 AM, ReneSac wrote: On Monday, 16 April 2012 at 07:28:25 UTC, Andrea Fontana wrote: Are you on linux/windows/mac? Windows. DMC runtime ! My main question is now *WHY* D is slower than C++ in this program? The code is identical (even the same C functions) No. They are

Re: No stack address

2012-04-16 Thread Somedude
Le 16/04/2012 21:51, Andrej Mitrovic a écrit : On 4/16/12, Somedude lovelyd...@mailmetrash.com wrote: OPTLINK : Warning 134: No Start Address This means you're missing a void main or int main function. You can pass --main to rdmd to add it automatically (useful when e.g. unittesting). All

Re: No stack address

2012-04-16 Thread Andrej Mitrovic
On 4/17/12, Somedude lovelyd...@mailmetrash.com wrote: But running the exe crashes immediately at execution with unauthorized instruction. Why ? That's the old exectuable leftover from the previous compile. RDMD generates the exe in a temporary folder with a random name and runs it immediately.

arrays and foreach

2012-04-16 Thread darkstalker
i have this example program: --- void main() { int[3] a; foreach (p; a) p = 42; writeln(a); } --- after running it, i expect to get [42, 42, 42] but instead i get [0, 0, 0] (i know that you can do a[] = 42, it's just a trivial example). So it seems that you cannot write

Re: arrays and foreach

2012-04-16 Thread Ali Çehreli
On 04/16/2012 04:56 PM, darkstalker wrote: i have this example program: --- void main() { int[3] a; foreach (p; a) p = 42; writeln(a); } --- after running it, i expect to get [42, 42, 42] but instead i get [0, 0, 0] (i know that you can do a[] = 42, it's just a trivial example). So it seems

Re: arrays and foreach

2012-04-16 Thread darkstalker
On Tuesday, 17 April 2012 at 00:00:57 UTC, Andrej Mitrovic wrote: On 4/17/12, darkstalker slayerbe...@gmail.com wrote: It possible to have 'p' passed by reference? Yes and the answer is in the question: foreach (ref p; a) p = 42; thanks, it works

Re: tupleof.length of a class in a template return 0

2012-04-16 Thread Michaël.Larouche
On Monday, 16 April 2012 at 23:58:29 UTC, Michaël Larouche wrote: I've given a second chance to D after watching D videos from Lang.NEXT 2012. As a first look, I wanted to try generate serialization code at compile time. Here's the class: class MyObject { public int m_id; public Data

Exception education

2012-04-16 Thread alexhairyman
I believe I have searched everywhere, but I can barely find any documentation on exceptions/errors/throwables and I would love a link on how to inherit from them to create my own ones. -- alexhairyman alexhairy...@gmail.com

Memoizing a templated function

2012-04-16 Thread ixid
Memoizing a templated version of a function doesn't seem to work, how would I do it properly? For example: int test(int n) { return //Do memoizable stuff } T test2(T)(T n) { return //Do memoizable stuff } void main() { n = memoize!test(n); //is fine n = test2(n); //is fine

Re: Memoizing a templated function

2012-04-16 Thread Andrej Mitrovic
On 4/17/12, ixid nuacco...@gmail.com wrote: Memoizing a templated version of a function doesn't seem to work, how would I do it properly? Instantiate the template first. Either: n = memoize!(test2!int)(n); or: alias test2!int itest; n = memoize!itest(n); Actually I'm a little surprised this

Re: Memoizing a templated function

2012-04-16 Thread bearophile
ixid: Memoizing a templated version of a function doesn't seem to work, A template isn't a function, it's just a recipe to define a function given one or more compile-time values or types. So memoize works if you instantiate in some way the template: import std.functional; int test(int

Re: const AB c = {a,20, numbers};

2012-04-16 Thread Kenji Hara
On Monday, 16 April 2012 at 14:50:43 UTC, sclytrack wrote: struct AB { int a; int b; int [] numbers; } int main() { int a = 300; const int [] numbers = new int[2]; const AB c = {a,20, numbers}; // line 66 writeln(c); return

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread ReneSac
On Monday, 16 April 2012 at 22:58:08 UTC, Timon Gehr wrote: On 04/17/2012 12:24 AM, ReneSac wrote: Windows. DMC runtime ! DMC = Digital Mars Compiler? Does Mingw/GDC uses that? I think that both, g++ and GDC compiled binaries, use the mingw runtime, but I'm not sure also. No. They are

Re: Templates in classes = what is wrong?

2012-04-16 Thread Kenji Hara
On Monday, 16 April 2012 at 18:48:52 UTC, Xan wrote: On Sunday, 15 April 2012 at 19:30:27 UTC, Ali Çehreli wrote: On 04/15/2012 11:39 AM, Xan wrote: On Sunday, 15 April 2012 at 11:23:37 UTC, John Chapman wrote: On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) {

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-16 Thread jerro
On Tuesday, 17 April 2012 at 01:30:30 UTC, ReneSac wrote: On Monday, 16 April 2012 at 22:58:08 UTC, Timon Gehr wrote: On 04/17/2012 12:24 AM, ReneSac wrote: Windows. DMC runtime ! DMC = Digital Mars Compiler? Does Mingw/GDC uses that? I think that both, g++ and GDC compiled binaries, use