Re: opAssign() still accepted for classes???

2011-04-30 Thread KennyTM~
On Apr 30, 11 01:19, Steven Schveighoffer wrote: I think he was referring to the line: X x = 0; Where x could not possibly be anything other than null. -Steve That's definitely a bug. Why should a declaration call opAssign?

Re: opAssign() still accepted for classes???

2011-04-30 Thread Steven Schveighoffer
On Fri, 29 Apr 2011 13:36:20 -0400, Steven Schveighoffer wrote: I wouldn't mind if it was a bug, because clearly you never want to call opAssign on an uninitialized class. But it definitely would be a special case. Meant to say, I wouldn't mind if it was an error. I don't think it's a

Re: opAssign() still accepted for classes???

2011-04-30 Thread Steven Schveighoffer
On Fri, 29 Apr 2011 13:29:56 -0400, KennyTM~ wrote: On Apr 30, 11 01:19, Steven Schveighoffer wrote: I think he was referring to the line: X x = 0; Where x could not possibly be anything other than null. -Steve That's definitely a bug. Why should a declaration call opAssign? X x = new X

Re: opAssign() still accepted for classes???

2011-04-30 Thread Steven Schveighoffer
On Fri, 29 Apr 2011 13:49:19 -0400, KennyTM~ wrote: Though this isn't valid with a 'struct'. import std.stdio; struct K { K opAssign(int x) { writeln(x); return this; } } void main() { // K k = 8; // Error: cannot implicitly convert e

Re: opAssign() still accepted for classes???

2011-04-30 Thread KennyTM~
On Apr 30, 11 01:36, Steven Schveighoffer wrote: On Fri, 29 Apr 2011 13:29:56 -0400, KennyTM~ wrote: On Apr 30, 11 01:19, Steven Schveighoffer wrote: I think he was referring to the line: X x = 0; Where x could not possibly be anything other than null. -Steve That's definitely a bug. Why

Re: opAssign() still accepted for classes???

2011-04-30 Thread Steven Schveighoffer
On Fri, 29 Apr 2011 13:03:05 -0400, KennyTM~ wrote: On Apr 30, 11 00:14, Alexander wrote: On 29.04.2011 17:05, Steven Schveighoffer wrote: x = y is equivalent to x.opAssign(y). So x is null, you are dereferencing a null pointer. Second thought... Since compiler *knows* that the pointe

Re: A few general thoughts

2011-04-30 Thread Jonathan M Davis
> This post is in fact mainly about removing delete, but I didn't wont make > everyone angry just with title.:) I am sure not expert to language design, > so I should probably be quiet, but I have question. > My question is: Didn't break it (i.e. removing delete) compatibility? > > In my opinion e

Re: opAssign() still accepted for classes???

2011-04-30 Thread KennyTM~
On Apr 30, 11 01:54, Steven Schveighoffer wrote: On Fri, 29 Apr 2011 13:49:19 -0400, KennyTM~ wrote: Though this isn't valid with a 'struct'. import std.stdio; struct K { K opAssign(int x) { writeln(x); return this; } } void main() { // K k = 8; // Error: cannot impli

Re: opAssign() still accepted for classes???

2011-04-30 Thread KennyTM~
On Apr 30, 11 01:54, Steven Schveighoffer wrote: On Fri, 29 Apr 2011 13:49:19 -0400, KennyTM~ wrote: Though this isn't valid with a 'struct'. import std.stdio; struct K { K opAssign(int x) { writeln(x); return this; } } void main() { // K k = 8; // Error: cannot impli

Re: Deterministic resource freeing - delete deprecation (again)

2011-04-30 Thread Francisco Almeida
On 28-04-2011 17:09, Steven Schveighoffer wrote: On Wed, 27 Apr 2011 17:30:54 -0400, Alexander wrote: On 27.04.2011 19:13, Steven Schveighoffer wrote: clear is not a keyword, it is possible to name a member clear, and also have a clear global function. Sure it is, though it is counter-intu

Re: How about a Hash template?

2011-04-30 Thread Andrei Alexandrescu
On 4/29/11 8:50 AM, Denis Koroskin wrote: On Thu, 28 Apr 2011 03:10:15 +0400, Andrej Mitrovic wrote: I often see code written like this: if (value == somevalue || value == someothervalue || value == yetanothervalue); You could use the switch statement. But that introduces indentation, and is

Re: Deterministic resource freeing - delete deprecation (again)

2011-04-30 Thread Steven Schveighoffer
On Fri, 29 Apr 2011 15:18:23 -0400, Francisco Almeida wrote: On 28-04-2011 17:09, Steven Schveighoffer wrote: On Wed, 27 Apr 2011 17:30:54 -0400, Alexander wrote: On 27.04.2011 19:13, Steven Schveighoffer wrote: clear is not a keyword, it is possible to name a member clear, and also h

Re: How about a Hash template?

2011-04-30 Thread KennyTM~
On Apr 30, 11 03:12, Andrei Alexandrescu wrote: On 4/29/11 8:50 AM, Denis Koroskin wrote: On Thu, 28 Apr 2011 03:10:15 +0400, Andrej Mitrovic wrote: I often see code written like this: if (value == somevalue || value == someothervalue || value == yetanothervalue); You could use the switch s

Re: How about a Hash template?

2011-04-30 Thread Andrei Alexandrescu
On 4/29/11 2:44 PM, KennyTM~ wrote: [snip] You need to replace the assert and compile with -O -release -inline. My results: find in array: 163 compile-time 1: 10 either: 17 straight comparison: 8 compile-time 2: 11 Code: import std.datetime, std.algorithm, std.typecons, std.stdio; auto eith

Re: deprecated delete and manual memory management

2011-04-30 Thread Timon Gehr
Steven Schveighoffer wrote: > I'll point out a couple of issues here: > > 1. you are never removing elements from the array when version(calldel) is > not enabled. That is, the GC might run, but does not clean any objects > when you just do top--. Although this might not make a huge difference, >

Re: opAssign() still accepted for classes???

2011-04-30 Thread Alexander
On 29.04.2011 19:19, Steven Schveighoffer wrote: > I think he was referring to the line: > > X x = 0; > > Where x could not possibly be anything other than null. Exactly. And, BTW, code X x; x = 0; is correctly detected as a null dereference at compile time. /Alexander

Re: How about a Hash template?

2011-04-30 Thread Alexander
On 29.04.2011 21:58, Andrei Alexandrescu wrote: > You need to replace the assert and compile with -O -release -inline. My > results: [snip] Still, straight comparison wins - 2x faster ;) /Alexander

Re: How about a Hash template?

2011-04-30 Thread Denis Koroskin
On Sat, 30 Apr 2011 03:19:37 +0400, Alexander wrote: On 29.04.2011 21:58, Andrei Alexandrescu wrote: You need to replace the assert and compile with -O -release -inline. My results: [snip] Still, straight comparison wins - 2x faster ;) /Alexander That's just an optimizer issue. Even if

Re: How about a Hash template?

2011-04-30 Thread Andrei Alexandrescu
On 4/29/11 6:21 PM, Denis Koroskin wrote: On Sat, 30 Apr 2011 03:19:37 +0400, Alexander wrote: On 29.04.2011 21:58, Andrei Alexandrescu wrote: You need to replace the assert and compile with -O -release -inline. My results: [snip] Still, straight comparison wins - 2x faster ;) /Alexander

_aApply.../opApply() return type: int or size_t?

2011-04-30 Thread David Nadlinger
[repost from dmd-internals] What should the _aApply... runtime functions, or in general, opApply() return? According to the current runtime implementation and http://www.digitalmars.com/d/2.0/statement.html, the return type should be int, but DMD expects Type::tindex (i.e. size_t) in ForeachS

Re: How about a Hash template?

2011-04-30 Thread Alexander
On 30.04.2011 01:23, Andrei Alexandrescu wrote: > Yah. I think the difference is immaterial outside inner loops. If it were > like 20x slower that would've been a problem. Outside of inner loops even 20x is not a real problem ;) /Alexander

Re: How about a Hash template?

2011-04-30 Thread Alexander
On 30.04.2011 01:21, Denis Koroskin wrote: > That's just an optimizer issue. Even if you replace the code body with > "return false;" (i.e. not found) it's STILL slower than straight comparison. 2x? Hardly, IMHO. /Alexander

Re: Is D cool or what?

2011-04-30 Thread Andrej Mitrovic
Actually my implementation is rather silly now that I've looked at it again. :) I should have taken advantage of ranges. E.g. I could use stride() to skip every Nth element and I could use cycle() to create a circular buffer. I'll give this a shot soon.

Re: link from a dll to another function in another dll?

2011-04-30 Thread maarten van damme
I've changed this, I think I'm still kinda confused with lib files. They've told me you can't do something with them without a .di file So I went ahead and made a kernel33.di file. I now import it in kernel32.d and my declaration is System(C){ export void * exportedfunctionblablabal(){ return ex

Re: Public variables inside interfaces

2011-04-30 Thread Olivier Pisano
Hi, You can "disguise" method calls into variables by using the @property tag. interface Sizeable { // Getter @property int size(); // Setter @property int size(int s); } class A : Sizeable { int m_size; public: this() { } @property int size() { return m_s

Public variables inside interfaces

2011-04-30 Thread Mariusz Gliwiński
I like the possibility of abandoning () in function calls in D, so we can firstly make attribute public and then if implementation changes, smoothly change it into function: call: auto a = new A(); writeln("Size is " +a.size); auto b = new B(); writeln("Size is " +b.size); class A { publi

Re: link from a dll to another function in another dll?

2011-04-30 Thread Rainer Schuetze
I'm not sure your wrapping will work with kernel32.dll, but in general here are a few tips: - most functions in the windows API use the __stdcall calling convention in C/C++, which translates to D as "extern(Windows)" - this will usually add the number of bytes passed on the stack as a "@NN"

Re: Public variables inside interfaces

2011-04-30 Thread Peter Alexander
On 30/04/11 1:22 PM, Mariusz Gliwiński wrote: I like the possibility of abandoning () in function calls in D, so we can firstly make attribute public and then if implementation changes, smoothly change it into function: Although, if I'd like to make interface Sizeable, it's impossible to treat

Re: link from a dll to another function in another dll?

2011-04-30 Thread Denis Koroskin
On Sat, 30 Apr 2011 13:47:53 +0400, maarten van damme wrote: I've changed this, I think I'm still kinda confused with lib files. They've told me you can't do something with them without a .di file So I went ahead and made a kernel33.di file. I now import it in kernel32.d and my declarati

Re: _aApply.../opApply() return type: int or size_t?

2011-04-30 Thread Walter Bright
On 4/29/2011 5:02 PM, David Nadlinger wrote: What should the _aApply... runtime functions, or in general, opApply() return? According to the current runtime implementation and http://www.digitalmars.com/d/2.0/statement.html, the return type should be int, but DMD expects Type::tindex (i.e. size_t

Re: _aApply.../opApply() return type: int or size_t?

2011-04-30 Thread Andrei Alexandrescu
On 4/30/11 12:51 PM, Walter Bright wrote: On 4/29/2011 5:02 PM, David Nadlinger wrote: What should the _aApply... runtime functions, or in general, opApply() return? According to the current runtime implementation and http://www.digitalmars.com/d/2.0/statement.html, the return type should be int

Re: Old comments about Java

2011-04-30 Thread Walter Bright
On 4/23/2011 4:43 PM, bearophile wrote: First, they impose a full word of overhead on each and every object, just in case someone somewhere sometime wants to grab a lock on that object. What, you say that you know that nobody outside of your code will ever get a pointer to this object, and that y

NG posts not showing up?

2011-04-30 Thread Andrej Mitrovic
I'm not getting any new NG posts show up in Gmail for me since April 29th. The same thing seems to be happening with gmane's NG reader: http://news.gmane.org/gmane.comp.lang.d.general/cutoff=55877 But new posts are showing up here: http://www.digitalmars.com/pnews/indexing.php?server=news.digitalm

Re: Old comments about Java

2011-04-30 Thread Peter Alexander
On 30/04/11 8:29 PM, Walter Bright wrote: On 4/23/2011 4:43 PM, bearophile wrote: First, they impose a full word of overhead on each and every object, just in case someone somewhere sometime wants to grab a lock on that object. What, you say that you know that nobody outside of your code will ev

Re: NG posts not showing up?

2011-04-30 Thread Andrej Mitrovic
Now they've showed up again, all at once. Did someone fix the problem? Or maybe it was just local..

Re: NG posts not showing up?

2011-04-30 Thread Brad Roberts
On 4/30/2011 2:21 PM, Andrej Mitrovic wrote: > Now they've showed up again, all at once. Did someone fix the problem? > Or maybe it was just local.. mailman (the list serve software) had gotten pissed off for some reason. I restarted it and the backlog cleared.

Re: How about a Hash template?

2011-04-30 Thread Sean Cavanaugh
On 4/29/2011 6:19 PM, Alexander wrote: On 29.04.2011 21:58, Andrei Alexandrescu wrote: You need to replace the assert and compile with -O -release -inline. My results: [snip] Still, straight comparison wins - 2x faster ;) /Alexander When understanding the CPU platform you are on, one of

htmlget.d example and unicode parsing

2011-04-30 Thread Tyro[a.c.edwards]
Hello all, I am trying to learn how to parse, modify, and redisplay a Japanese webpage passed to me in a form and am wondering if anyone has an example of how to do this. I looked at htmlget and found that it has a couple problems: namely, it is not conform to current D2 practices. I am not

Re: Old comments about Java

2011-04-30 Thread Sean Kelly
They kinda already do. Look into how core.mutex works. Sent from my iPhone On Apr 30, 2011, at 1:43 PM, Peter Alexander wrote: > On 30/04/11 8:29 PM, Walter Bright wrote: >> On 4/23/2011 4:43 PM, bearophile wrote: >>> First, they impose a full word of overhead on each and every object, >>> ju