Re: Arrays vs slices

2009-06-10 Thread Steve Schveighoffer
On Tue, 09 Jun 2009 16:22:39 -0400, bearophile wrote: > Once the language tells apart arrays and slices, the arrays may have a > third field that represents the capacity, and the slices may have a > third field that represents the stride (that defaults to 1). No, please no! Do I really need to c

Re: 'final' function implementations in interface definition

2009-06-07 Thread Steve Schveighoffer
On Sun, 07 Jun 2009 19:52:05 -0400, HOSOKAWA Kenchi wrote: > Steve Schveighoffer Wrote: > > >> f_twice can be a template: >> >> void f_twice()(int i) { f(i); f(i); } >> >> It's pretty much exactly what you want. It should even work without >>

Re: 'final' function implementations in interface definition

2009-06-07 Thread Steve Schveighoffer
On Sun, 07 Jun 2009 17:58:30 -0400, HOSOKAWA Kenchi wrote: > Hello, > > > Interface member functions do not have implementations. This > specification prevents to implement macro-like small functions which > won't be overridden. It seems that interfaces are possible to have > function implementa

Re: Pop quiz [memory usage]

2009-06-07 Thread Steve Schveighoffer
On Mon, 08 Jun 2009 00:34:10 +0400, Denis Koroskin wrote: > On Sun, 07 Jun 2009 15:47:52 +0400, Steve Schveighoffer > wrote: > >> On Sat, 06 Jun 2009 21:59:39 -0700, Sean Kelly wrote: >> >>> Steve Schveighoffer wrote: >>>> On Sat, 06

Re: Pop quiz [memory usage]

2009-06-07 Thread Steve Schveighoffer
On Sat, 06 Jun 2009 21:59:39 -0700, Sean Kelly wrote: > Steve Schveighoffer wrote: >> On Sat, 06 Jun 2009 12:03:03 -0700, Sean Kelly wrote: >> >>> bearophile wrote: >>>> Sean Kelly: >>>>> Particularly in D2 where append >>>>> o

Re: Pop quiz [memory usage]

2009-06-06 Thread Steve Schveighoffer
On Sat, 06 Jun 2009 12:03:03 -0700, Sean Kelly wrote: > bearophile wrote: >> Sean Kelly: >>> Particularly in D2 where append >>> operations on arrays are probably less common as a result of string >>> being invariant. >> >> They aren't much common maybe because they are currently dead-slow. >> Ap

Re: D2's feature set?

2009-06-06 Thread Steve Schveighoffer
On Sat, 06 Jun 2009 10:57:08 -0700, Brad Roberts wrote: > Steven Schveighoffer wrote: >> On Sat, 06 Jun 2009 09:35:15 -0400, Christopher Wright >> wrote: >> >>> Kristian Kilpi wrote: I think I shouldn't post this because I could very well start one of those mega-threads... :D Of

Re: D2's feature set?

2009-06-06 Thread Steve Schveighoffer
On Sat, 06 Jun 2009 11:26:37 -0400, Jarrett Billingsley wrote: > On Sat, Jun 6, 2009 at 11:17 AM, Steven > Schveighoffer wrote: >>> >>> You need to do escape analysis and whole program analysis to determine >>> whether there are aliases to a scope member. Failing that, it's pretty >>> easy to intr

Re: If T[new] is the container for T[], then what is the container for T[U]?

2009-04-25 Thread Steve Schveighoffer
On Sat, 25 Apr 2009 08:07:52 -0500, Andrei Alexandrescu wrote: > It looks we can't make it with only T[]. We need a genuine container > type, and T[new] was suggested. It would probably have value semantics. > > T[U] seems to have the same problem. If T[U] is the range, then how do > you call the

Re: const?? When and why? This is ugly!

2009-03-08 Thread Steve Schveighoffer
On Sun, 08 Mar 2009 17:24:09 -0700, Walter Bright wrote: > Derek Parnell wrote: >> I know that a better way to code this example would have been to use >> the .idup functionality, but that is not the point. I relied on the >> compiler ensuring that everything declared as immutable would not be >>

Re: Returning const? -- A potential solution

2009-03-08 Thread Steve Schveighoffer
On Sat, 07 Mar 2009 22:44:48 -0500, Jason House wrote: > The ugly const thread got me thinking about the old problem of returning > an input while preserving const safety. I have an idea that seems > reasonable... I agree, it's very reasonable. That's why I created an enhancement bugzilla for

Re: input validation

2009-03-04 Thread Steve Schveighoffer
On Wed, 04 Mar 2009 13:55:10 -0800, Andrei Alexandrescu wrote: > bearophile wrote: >> Andrei Alexandrescu: >>> Binary search is rather common. >> >> Oh, yes, sorry, I meant among the ones you have listed there... > > Of five, three are frequent (linear, binary, Boyer-Moore), one is a form > of s

Re: OT -- Re: random cover of a range

2009-02-18 Thread Steve Schveighoffer
On Wed, 18 Feb 2009 05:43:06 +, John Reimer wrote: > Hello Steve, > >> On Sun, 15 Feb 2009 17:01:49 +, John Reimer wrote: >> >>> Hello Steve, >>> This is the same kind of attitude, John, that brought about the death of Alan Turing. >>> That's a strong accusation, Steve,

Re: std.file.read implementation contest

2009-02-16 Thread Steve Schveighoffer
On Mon, 16 Feb 2009 16:36:52 -0800, Sean Kelly wrote: > Andrei Alexandrescu wrote: >> >> I totally agree. The useful spec of std.file.read should be "reads the >> file to exhaustion in a buffer and returns it" > > Okay, that's a fair definition. So the correct behavior for reading an > unbounde

Re: default random object?

2009-02-15 Thread Steve Schveighoffer
On Sun, 15 Feb 2009 20:30:06 -0800, Andrei Alexandrescu wrote: > Steve Schveighoffer wrote: >> On Mon, 16 Feb 2009 12:20:34 +0900, Bill Baxter wrote: >> >>> On Mon, Feb 16, 2009 at 12:07 PM, Steve Schveighoffer >>> wrote: >>>> On Sun, 15 Feb 2

Re: default random object?

2009-02-15 Thread Steve Schveighoffer
On Mon, 16 Feb 2009 12:20:34 +0900, Bill Baxter wrote: > On Mon, Feb 16, 2009 at 12:07 PM, Steve Schveighoffer > wrote: >> On Sun, 15 Feb 2009 17:27:38 -0800, Andrei Alexandrescu wrote: >> >>> Ok. Let me just note that rand()%max is a lousy method of generating >&

Re: default random object?

2009-02-15 Thread Steve Schveighoffer
On Sun, 15 Feb 2009 17:27:38 -0800, Andrei Alexandrescu wrote: > Ok. Let me just note that rand()%max is a lousy method of generating > random numbers between 0 and max-1 and everybody should put that in the > bin with Popular Examples That Should Never Be Used, together with > exponential Fibonac

Re: OT -- Re: random cover of a range

2009-02-15 Thread Steve Schveighoffer
On Sun, 15 Feb 2009 17:01:49 +, John Reimer wrote: > Hello Steve, > >> This is the same kind of attitude, John, that brought about the death >> of Alan Turing. > > > That's a strong accusation, Steve, without knowing me; it's a very hasty > reduction for circumstances, personalities, and fa

Re: OT -- Re: random cover of a range

2009-02-15 Thread Steve Schveighoffer
On Sun, 15 Feb 2009 15:42:17 -0800, Andrei Alexandrescu wrote: > BCS wrote: >> Hello Andrei, >> >>> Let me add one too: there/their. >>> >>> Andrei >>> >>> >> Oops :( >> I don't /think/ I'm dyslexic :b >> >> >> > That lysdexia is a killer isn't it :o). > > Andrei dyslexics of the world untie

Re: OT -- Re: random cover of a range

2009-02-15 Thread Steve Schveighoffer
On Sat, 14 Feb 2009 19:10:05 +, John Reimer wrote: > Hello bearophile, > >> (And my name is bearophile, thank you). >> >> Bye, >> bearophile > > > For those that see this as flamebait, I request that you do not respond. > I just felt somebody had to say something about this. If this is >

Re: default random object?

2009-02-14 Thread Steve Schveighoffer
On Sat, 14 Feb 2009 14:11:10 +0300, Denis Koroskin wrote: > On Sat, 14 Feb 2009 14:04:36 +0300, Walter Bright > wrote: > >> Andrei Alexandrescu wrote: >>> auto big = uniform(rng, uint.max / 2, uint.max); >>> If the interval is open I can't generate uint.max. >> >> >> auto big = uniform(rng, uin

Re: default random object?

2009-02-13 Thread Steve Schveighoffer
On Fri, 13 Feb 2009 17:10:29 -0800, Andrei Alexandrescu wrote: > 2. The global random generator will be allocated per thread. Are you > cool with this too? Good idea. Random number generators should not require locking in the most common case. > > 3. How should the global rng be initialized?

Re: random cover of a range

2009-02-13 Thread Steve Schveighoffer
On Fri, 13 Feb 2009 16:45:21 -0800, Andrei Alexandrescu wrote: > Steven Schveighoffer wrote: >> Average runtime is still going to be O(n^2), because the average >> element chosen should be k / 2 elements into the range. > > So at some point there are k slots for grabs out of n. The number of > st

Re: Templates at runtime

2009-02-12 Thread Steve Schveighoffer
On Thu, 12 Feb 2009 21:51:01 -0500, Justin wrote: > Is there a way to "find" a classinfo for such a class at runtime? I can't see anything incorrect about what you are doing. Certainly the source for druntime seems to indicate it should work. This is probably a compiler bug. -Steve

Re: std.string and ranges

2009-02-12 Thread Steve Schveighoffer
On Thu, 12 Feb 2009 14:41:26 +0300, Denis Koroskin wrote: > On Thu, 12 Feb 2009 07:46:31 +0300, Andrei Alexandrescu > wrote: >> Wait, I take that back. I don't know of solid ways to sort into a copy >> or shuffle into a copy. For shuffling I'd need auxiliary memory (in >> addition to the copy its

Re: Version declaration proposal

2009-02-11 Thread Steve Schveighoffer
On Wed, 11 Feb 2009 16:58:38 -0500, Nick Sabalausky wrote: > > // Ok, Windows is a built-in version declared by the language or > compiler. // Note that on non-Windows platforms, // the "Windows" > version would still exist, // but it would just be set to false. > version(Windows)... > This won'

Re: Version declaration proposal

2009-02-11 Thread Steve Schveighoffer
On Wed, 11 Feb 2009 09:01:29 +0100, Don wrote: > I think I have a solution to the versioning problems. My belief is that > version statements are fine, and Walter's 'rats nest' argument is valid. > Instead, I believe that version declarations limited to "version = XXX;" > are too weak. They also h

Re: Why version() ?

2009-02-10 Thread Steve Schveighoffer
On Wed, 11 Feb 2009 05:43:48 +, Steve Schveighoffer wrote: > What I mean by > expanded if statements is that you are making me expand: > > if(a || b) > statement; > > into > > bool aorb = false; > if(a) > aorb = true; > if(b) > aorb = true; &

Re: Why version() ?

2009-02-10 Thread Steve Schveighoffer
On Tue, 10 Feb 2009 19:28:46 -0800, Walter Bright wrote: > Steven Schveighoffer wrote: >> That example has nothing to do with || being allowed, and nothing to do >> with your exhibit B. Your simple example makes sense to split into >> multiple files, but you simply waved your magic "split into mu

Re: toString ugliness

2008-12-06 Thread Steve Schveighoffer
On Sat, 06 Dec 2008 11:21:11 -0500, Jerry wrote: > toString() doesn't work inside a class member function. > > import std.string; > class A { > void f() { > string s = toString(5); > } > } > > This errors with junk.d(19): function object.Object.toString () does not > match parameter type