Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Ellery Newcomer
On 03/08/2010 08:49 PM, bearophile wrote: Admitted, the last case does not work quite as nicely with ".." as it does with Python's ":". Still, the point should be clear. I have never understood why Walter has adopted .. for slices instead of the better : I'd like to know why. Bye, bearophil

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Norbert Nemec
bearophile wrote: D won't be frozen forever, eventually few new things will be added, for example in D3. For example probably some of the limits of CTFE will be removed. Even C language and Fortran keep having changes every ten years or so. What will be hard to do are changes/removals. It's imp

Re: Web-News Reader Problems

2010-03-08 Thread sybrandy
On 03/08/2010 12:58 PM, Nick Sabalausky wrote: "Andrej Mitrovic" wrote in message news:hn3bk0$62...@digitalmars.com... Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for me, e.g.: " Fail to get the article: 19062 Bad article nu

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread bearophile
Norbert Nemec: > Just note that the slice operator "a..b" > should also allow strided slicing "a..b:c" I have asked for this ages ago :o) But at that time there was no laziness and ranges in Phobos, so that was not very useful. > Yea, seems like I missed some important decisions. May indeed be

Re: Is D a cult?

2010-03-08 Thread Michael Rynn
On Mon, 08 Mar 2010 06:57:00 -0500, Hamish McTavish wrote: > Jane Doe Wrote: > >> Is D a cult? >> >> >> > Who you calling a cult? http://en.wikipedia.org/wiki/Cult Cult pejoratively refers to a group whose beliefs or practices could be, reasonably or unreasonably, considered strange. The te

Re: Pattern matching in D

2010-03-08 Thread Walter Bright
BCS wrote: What about allowing switch on FP but only allowing CaseRangeStatements? Is there really a compelling use case for that? I really think we need to focus on what is needed to be done, not what can be done. Otherwise we wind up with a huge boatload of features yet have an unuseful la

Re: Web-News Reader Problems

2010-03-08 Thread Denis Koroskin
On Mon, 08 Mar 2010 21:25:02 +0300, Ary Borenszweig wrote: dolive wrote: Nick Sabalausky дµ½: "Andrej Mitrovic" wrote in message news:hn3bk0$62...@digitalmars.com... Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for m

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Norbert Nemec
Don wrote: Norbert Nemec wrote: The compiler would need to be aware of the data type Slice. It would therefore have to be something like a "builtin" type. If I am not mistaken, the language definition so far never makes use of "builtin" struct types. You are mistaken . object, TypeInfo, Asso

Re: Pattern matching in D

2010-03-08 Thread BCS
Hello Walter, (Note: switching on floating point values is worse than useless, as floating point computations rarely produce exact results, and supporting such a capability will give a false sense that it should work.) What about allowing switch on FP but only allowing CaseRangeStatements?

Re: Holes in structs and opEquals

2010-03-08 Thread Walter Bright
yigal chripun wrote: Trying to disable == for such structs is a losing battle, anyway, as the compiler could only detect the most obvious cases. Pass a reference to it to a function, store it in a data structure, etc., and all that goes away. Ok, that sound's reasonable if you want to keep the

Re: Is D a cult?

2010-03-08 Thread Walter Bright
Steven Schveighoffer wrote: That is, as long as it doesn't conflict with what the book says, it can be changed. This is why a complete documentation of phobos is not in the book (parts are referenced, and those parts must remain frozen). That's only a small part of the reason why. The main r

Re: Web-News Reader Problems

2010-03-08 Thread dolive
Ary Borenszweig дµ½: > dolive wrote: > > Nick Sabalausky дµ½: > > > >> "Andrej Mitrovic" wrote in message > >> news:hn3bk0$62...@digitalmars.com... > >>> Is anyone else getting errors with the digitalmars web-news reader? It > >>> seems to fail loading messages quite often for me, e.g.: > >>

Re: Is D a cult?

2010-03-08 Thread Walter Bright
grauzone wrote: Sorry for being dense, but again: what does alignment have to do with this? alias TypeTuple!(char, int) TT; These declarations must be IDENTICAL: void foo(TT); void foo(char, int); struct S { TT t; } struct S { char t1; int t2; } This means that if you have an

Re: Is D a cult?

2010-03-08 Thread Walter Bright
retard wrote: This doesn't work, because the alignment is different for different circumstances. Where does this requirement come from? The natural and efficient way to align function parameters on the stack is different from aligning them for struct fields. Is there some existing work on

Re: Holes in structs and opEquals

2010-03-08 Thread yigal chripun
Walter Bright Wrote: > yigal chripun wrote: > > The compiler knows at compile-time what variables are initialized with > > "=void". The compiler than can add a compilation error when such a struct > > variable is used in an equals expression. > > this doesn't cover use of malloc() which must be

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Don
Lars T. Kyllingstad wrote: Don wrote: Norbert Nemec wrote: Don wrote: Norbert Nemec wrote: Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, bu

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Lars T. Kyllingstad
Don wrote: Norbert Nemec wrote: Don wrote: Norbert Nemec wrote: Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, but opSlice works only for one

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: On Mon, 08 Mar 2010 13:21:14 -0500, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: Hm... this seems to be a different problem than I originally was thinking about. So in essence, you want a set of "safe" functions that will not adversely affect a range

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Don
Norbert Nemec wrote: Don wrote: Norbert Nemec wrote: Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, but opSlice works only for one dimension.

new operator overloading buggy?

2010-03-08 Thread Trass3r
Guess it's better to post this here. Are these some bugs or is there another problem? the following code strangely yields: dsfml\system\vector2.d(47): Error: variable dsfml.system.vector2.Vector2!(float).Vector2.op only parameters or foreach declarations can be ref /// element-wise operations,

Re: Container insertion and removal

2010-03-08 Thread Steven Schveighoffer
On Mon, 08 Mar 2010 13:21:14 -0500, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: Hm... this seems to be a different problem than I originally was thinking about. So in essence, you want a set of "safe" functions that will not adversely affect a range you are using to iterate w

Re: Web-News Reader Problems

2010-03-08 Thread Patrick Kreft
On Mon, 08 Mar 2010 18:20:00 +0100, Andrej Mitrovic wrote: Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for me, e.g.: " Fail to get the article: 19062 Bad article number " I guess I could use a proper news reader to avoi

Re: Container insertion and removal

2010-03-08 Thread Michel Fortin
On 2010-03-08 13:01:32 -0500, Andrei Alexandrescu said: softXxx functions that remove data should guarantee that existing ranges not including the removed elements will continue to operate on the range without seeing the removed elements. There is no guarantee that soft removal offers for ra

Re: Web-News Reader Problems

2010-03-08 Thread Ary Borenszweig
dolive wrote: Nick Sabalausky дµ½: "Andrej Mitrovic" wrote in message news:hn3bk0$62...@digitalmars.com... Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for me, e.g.: " Fail to get the article: 19062 Bad article number "

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: On Mon, 08 Mar 2010 12:53:40 -0500, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: On Sun, 07 Mar 2010 12:43:09 -0500, Robert Jacques wrote: On Sun, 07 Mar 2010 08:23:03 -0500, Steven Schveighoffer wrote: What is the advantage? Why would an algorithm

Re: Web-News Reader Problems

2010-03-08 Thread dolive
Nick Sabalausky дµ½: > "Andrej Mitrovic" wrote in message > news:hn3bk0$62...@digitalmars.com... > > Is anyone else getting errors with the digitalmars web-news reader? It > > seems to fail loading messages quite often for me, e.g.: > > > > " > > Fail to get the article: 19062 > > Bad article

Re: Container insertion and removal

2010-03-08 Thread Steven Schveighoffer
On Mon, 08 Mar 2010 12:53:40 -0500, Andrei Alexandrescu wrote: Steven Schveighoffer wrote: On Sun, 07 Mar 2010 12:43:09 -0500, Robert Jacques wrote: On Sun, 07 Mar 2010 08:23:03 -0500, Steven Schveighoffer wrote: What is the advantage? Why would an algorithm require soft functions?

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Joel C. Salomon wrote: On 3/6/2010 5:18 PM, Andrei Alexandrescu wrote: Good question. In STL, invalidation roughly means undefined behavior if you use it. With GC in tow, the concept could be significantly milder. For example, reallocating an array would leave the old contents of the array sort

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Fawzi Mohamed wrote: On 2010-03-07 14:23:03 +0100, Steven Schveighoffer said: Robert Jacques Wrote: On Sat, 06 Mar 2010 21:54:50 -0500, Steven Schveighoffer wrote: On Sat, 06 Mar 2010 11:19:15 -0500, Robert Jacques wrote: On Sat, 06 Mar 2010 08:19:36 -0500, Steven Schveighoffer wrote:

Re: Web-News Reader Problems

2010-03-08 Thread Nick Sabalausky
"Andrej Mitrovic" wrote in message news:hn3bk0$62...@digitalmars.com... > Is anyone else getting errors with the digitalmars web-news reader? It > seems to fail loading messages quite often for me, e.g.: > > " > Fail to get the article: 19062 > Bad article number > " > > I guess I could use a pr

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: On Sun, 07 Mar 2010 12:43:09 -0500, Robert Jacques wrote: On Sun, 07 Mar 2010 08:23:03 -0500, Steven Schveighoffer wrote: What is the advantage? Why would an algorithm require soft functions? What is an example of such an algorithm? Something that uses toUppe

Re: Container insertion and removal

2010-03-08 Thread Joel C. Salomon
On 3/6/2010 5:18 PM, Andrei Alexandrescu wrote: > Good question. In STL, invalidation roughly means undefined behavior if > you use it. With GC in tow, the concept could be significantly milder. > For example, reallocating an array would leave the old contents of the > array sort of around, just ob

Re: Web-News Reader Problems

2010-03-08 Thread Denis Koroskin
On Mon, 08 Mar 2010 20:20:00 +0300, Andrej Mitrovic wrote: Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for me, e.g.: " Fail to get the article: 19062 Bad article number " I guess I could use a proper news reader to avoi

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
Steven Schveighoffer wrote: On Sun, 07 Mar 2010 06:42:10 -0500, Andrei Alexandrescu wrote: Iterator invalidation has been a notion thoroughly explored by the STL and a commonly-mentioned liability of STL iterators. People find it very jarring that syntactically identical interfaces have dis

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Norbert Nemec
Don wrote: Norbert Nemec wrote: Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, but opSlice works only for one dimension. Ultimately, it should

Re: Container insertion and removal

2010-03-08 Thread Andrei Alexandrescu
dsimcha wrote: == Quote from Robert Jacques (sandf...@jhu.edu)'s article The mutation index has been used in Tango forever, and I think was in Doug Lea's original container implementations. I'm pretty sure it is sound in single-threaded uses. No it's not. version tags + integer overflow = bug.

Web-News Reader Problems

2010-03-08 Thread Andrej Mitrovic
Is anyone else getting errors with the digitalmars web-news reader? It seems to fail loading messages quite often for me, e.g.: " Fail to get the article: 19062 Bad article number " I guess I could use a proper news reader to avoid these issues. Any recommendations for newsreader software on Wi

Re: Holes in structs and opEquals

2010-03-08 Thread Don
Walter Bright wrote: Fawzi Mohamed wrote: one could argue that the unsafe operation is memset. That's right. The compiler always initializes a struct, so that what you describe should never happen in a safe program. Right. Still as you say the following example that might indeed conside

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Michel Fortin
On 2010-03-08 09:55:53 -0500, Don said: However, Andrei argued that slicing of multidimensional arrays is so rarely used that syntax sugar is not necessary. Thus, it's not in D2. And that's sad, because there are many other uses for a Slice struct. -- Michel Fortin michel.for...@michelf.com

Re: Proposal: Multidimensional opSlice solution

2010-03-08 Thread Don
Norbert Nemec wrote: Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, but opSlice works only for one dimension. Ultimately, it should be possible

Re: Is D a cult?

2010-03-08 Thread Michel Fortin
On 2010-03-08 06:37:55 -0500, Walter Bright said: grauzone wrote: I don't understand, what does alignment have to do with such a high level construct? You can use a tuple to populate a struct with fields, and it's interchangeable with manually populating the fields. You can also use a tupl

Re: Is D a cult?

2010-03-08 Thread Steven Schveighoffer
On Mon, 08 Mar 2010 07:51:31 -0500, grauzone wrote: bearophile wrote: grauzone: That aside, I'm also glad that you acknowledge that current tuples are not perfect and need improvement. I agree. It's probably already too late to fix them,< It isn't. D2 is pretty much finalized now. Th

Re: Is D a cult?

2010-03-08 Thread Denis Koroskin
On Mon, 08 Mar 2010 15:49:01 +0300, retard wrote: Mon, 08 Mar 2010 04:42:48 -0800, Walter Bright wrote: grauzone wrote: Again, I can't understand. Does the compiler rely that tuples have the same byte layout as structs or function arguments? I thought the compiler could just copy all fields.

Re: Is D a cult?

2010-03-08 Thread grauzone
Walter Bright wrote: grauzone wrote: Again, I can't understand. Does the compiler rely that tuples have the same byte layout as structs or function arguments? I thought the compiler could just copy all fields. And the backend can already return multiple values, since it can return structs and

Re: Is D a cult?

2010-03-08 Thread grauzone
bearophile wrote: grauzone: That aside, I'm also glad that you acknowledge that current tuples are not perfect and need improvement. I agree. It's probably already too late to fix them,< It isn't. D2 is pretty much finalized now. The discussion (i.e. bikeshedding) alone to determine ho

Re: Holes in structs and opEquals

2010-03-08 Thread bearophile
Walter Bright: > It can, but I don't agree that it should. For an =void initialization, > it's the user's responsibility to initialize it properly. The use of > =void implies the user knows what he's doing with it, and will take care > to initialize the 'holes' as necessary. I don't fully like

Re: Is D a cult?

2010-03-08 Thread retard
Mon, 08 Mar 2010 04:42:48 -0800, Walter Bright wrote: > grauzone wrote: >> Again, I can't understand. Does the compiler rely that tuples have the >> same byte layout as structs or function arguments? I thought the >> compiler could just copy all fields. And the backend can already return >> multip

Re: Is D a cult?

2010-03-08 Thread Walter Bright
grauzone wrote: Again, I can't understand. Does the compiler rely that tuples have the same byte layout as structs or function arguments? I thought the compiler could just copy all fields. And the backend can already return multiple values, since it can return structs and static arrays. A tup

Re: Pattern matching in D

2010-03-08 Thread Simen kjaeraas
Walter Bright wrote: foo match { case b: Bar => b.doBarMethod case b: Bar2 => b.doBar2Method case _ => println("Oh no!") } (1, (1,2)) match { case (1, (1, _)) => println("nice tuple") case _ => } def main(args: Array[Byte]) = args(0) match { case "-help" => println("Usage: ...

Re: Is D a cult?

2010-03-08 Thread bearophile
grauzone: > That aside, I'm also glad that you acknowledge that current tuples are > not perfect and need improvement. I agree. >It's probably already too late to fix them,< It isn't. >but you could always introduce a second, proper tuple type.< NO. Not even think about that. Two kinds of t

Proposal: Multidimensional opSlice solution

2010-03-08 Thread Norbert Nemec
Hi there, in implementing multi-dimensional arrays, the current way of overloading the slicing operator does not scale up. Currently, there is opIndex working for an arbitrary number of indices, but opSlice works only for one dimension. Ultimately, it should be possible to allow slicing for

Re: Pattern matching in D

2010-03-08 Thread retard
Mon, 08 Mar 2010 03:35:56 -0800, Walter Bright wrote: > retard wrote: >>> I've thought more than once about adding that, but it just seems >>> pointless. I've never run into a use case for it. If you do run into >>> one, >>> >>> if (ar == [1,2,3]) ... >>> else if (ar == [1,2,4]) ... >>>

Re: Is D a cult?

2010-03-08 Thread Hamish McTavish
Jane Doe Wrote: > Is D a cult? > > Who you calling a cult?

Re: Is D a cult?

2010-03-08 Thread grauzone
Walter Bright wrote: grauzone wrote: Walter Bright wrote: bearophile wrote: Walter Bright: There are significant technical problems with having functions return tuples.< A possibly stupid question: isn't it enough to return a custom struct? No, because of the alignment mismatches with oth

Re: opCmp: strange definition in specs

2010-03-08 Thread Steven Schveighoffer
On Mon, 08 Mar 2010 06:15:16 -0500, Norbert Nemec wrote: I just read through the specs about operators and found a strangeness in the definition of opCmp: http://www.digitalmars.com/d/2.0/operatoroverloading.html#compare Mathematically the following are equivalent a < b <=>

Re: Container insertion and removal

2010-03-08 Thread Steven Schveighoffer
On Mon, 08 Mar 2010 00:20:31 -0500, Robert Jacques wrote: On Sun, 07 Mar 2010 22:07:14 -0500, Steven Schveighoffer wrote: On Sun, 07 Mar 2010 12:43:09 -0500, Robert Jacques wrote: On Sun, 07 Mar 2010 08:23:03 -0500, Steven Schveighoffer wrote: [snip] Please define for me an O(1) slic

Re: Is D a cult?

2010-03-08 Thread Walter Bright
grauzone wrote: Walter Bright wrote: bearophile wrote: Walter Bright: There are significant technical problems with having functions return tuples.< A possibly stupid question: isn't it enough to return a custom struct? No, because of the alignment mismatches with other uses of tuples. I

Re: Pattern matching in D

2010-03-08 Thread Walter Bright
retard wrote: I've thought more than once about adding that, but it just seems pointless. I've never run into a use case for it. If you do run into one, if (ar == [1,2,3]) ... else if (ar == [1,2,4]) ... else if (ar == [1,3,2]) ... will work just fine. The same can be said abou

Re: Is D a cult?

2010-03-08 Thread Walter Bright
Simen kjaeraas wrote: Walter Bright wrote: My experience with shallow const (in C++) is that it's nearly useless. Most C++ code I've seen seems to rely on an implicit assumption of transitive const, but it isn't in the documentation and of course you don't know if it is upheld or not. This is

Re: Holes in structs and opEquals

2010-03-08 Thread Walter Bright
yigal chripun wrote: The compiler knows at compile-time what variables are initialized with "=void". The compiler than can add a compilation error when such a struct variable is used in an equals expression. this doesn't cover use of malloc() which must be the user's responsebility. e.g. S s1

opCmp: strange definition in specs

2010-03-08 Thread Norbert Nemec
I just read through the specs about operators and found a strangeness in the definition of opCmp: http://www.digitalmars.com/d/2.0/operatoroverloading.html#compare Mathematically the following are equivalent a < b <=> b > a But the definition seems to swap a < b

Complete off topic: Nimrod language

2010-03-08 Thread Bane
Spend last night reading about this new language. Has a lot of neat features, but is still missing some important stuff (will be added). http://force7.de/nimrod/

Re: Simple spell check in new DMD release

2010-03-08 Thread Joel Christensen
Thanks Lars, sounds cool. :-) Lars T. Kyllingstad wrote: Joel Christensen wrote: How does it work? I couldn't even see it. Not in the windows\bin directory or the dmd help. It's built into the compiler. :) test.d: struct S { int fooBar; } void main() { S

Re: Simple spell check in new DMD release

2010-03-08 Thread Lars T. Kyllingstad
Joel Christensen wrote: How does it work? I couldn't even see it. Not in the windows\bin directory or the dmd help. It's built into the compiler. :) test.d: struct S { int fooBar; } void main() { S s; s.fooBaz = 1; } Compilation: dmd test.d

Simple spell check in new DMD release

2010-03-08 Thread Joel Christensen
How does it work? I couldn't even see it. Not in the windows\bin directory or the dmd help.

Re: Pattern matching in D

2010-03-08 Thread retard
Sun, 07 Mar 2010 22:05:19 -0800, Walter Bright wrote: > BCS wrote: >> I think what retard was asking was what types are legal as the argument >> for a switch? >> >> IIRC the list is: all the arithmetic types and the string types. >> >> The value pattern matching that is being asked for would all

Re: Is D a cult?

2010-03-08 Thread retard
Mon, 08 Mar 2010 09:27:34 +0100, grauzone wrote: > Walter Bright wrote: >> bearophile wrote: >>> Walter Bright: There are significant technical problems with having functions return tuples.< >>> >>> A possibly stupid question: isn't it enough to return a custom struct? >> >> No, because

Re: Empty array literals

2010-03-08 Thread grauzone
Lutger wrote: Michael Rynn wrote: That IS what Walter thinks, actually. It's being moved to libraries (which is why there have been some nasty AA regressions in the past few compiler releases :-( ). Sounds good. So the source is in druntime? Does that mean I can find out how to implement opIn

Re: Is D a cult?

2010-03-08 Thread Simen kjaeraas
Walter Bright wrote: retard wrote: On the other hand Scala does provide a shallow form of immutability and some immutable data structures in the standard library. My experience with shallow const (in C++) is that it's nearly useless. Most C++ code I've seen seems to rely on an implicit as

Re: Is D a cult?

2010-03-08 Thread grauzone
Walter Bright wrote: bearophile wrote: Walter Bright: There are significant technical problems with having functions return tuples.< A possibly stupid question: isn't it enough to return a custom struct? No, because of the alignment mismatches with other uses of tuples. I don't understand

Re: Static attributes & immutability, static attributes seen from instances

2010-03-08 Thread yigal chripun
Nick Sabalausky Wrote: > "Nick Sabalausky" wrote in message > news:hmsqdk$9u...@digitalmars.com... > > > > "bearophile" wrote in message > > news:hmrtbk$1ao...@digitalmars.com... > >> > >> A bit later in the discussion div0 and Pelle M. have said/suggested that > >> accessing static vars thro

Re: Empty array literals

2010-03-08 Thread Lutger
Michael Rynn wrote: > >> That IS what Walter thinks, actually. It's being moved to libraries >> (which is why there have been some nasty AA regressions in the past few >> compiler releases :-( ). > > Sounds good. So the source is in druntime? > Does that mean I can find out how to implement opI