Re: What's wrong with D's templates?

2009-12-21 Thread grauzone
Walter Bright wrote: I can expound on the huge advantages immutability and purity offer, if you want. Yes, I'd like to hear about this. You can leave away the things that are not going to be implemented (like memorization of pure return values), are only micro-optimizations (common sub-expres

Re: What's wrong with D's templates?

2009-12-21 Thread yigal chripun
Walter Bright Wrote: > Yigal Chripun wrote: > > But that doesn't mean the idea itself isn't valid. Perhaps a different > > language with different goals in mind can provide a much simpler non > > convoluted implementation and semantics for the same idea? > > You've shown in the past that you're

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Tim Matthews
On 22/12/2009 5:24 p.m., Walter Bright wrote: Andrei Alexandrescu wrote: That definition is what was discussed in this thread and alleged to be anything but beautiful. I've been in museums in europe where they proudly display ornate swords and armor as "beautiful". I always kinda thought other

mixin not overloading other mixins, Bug or feature?

2009-12-21 Thread Travis Boucher
float func1(float[2] v) { return v[0]; } float func1(float[3] v) { return v[0]; } template Test (size_t S) { float func2(float[S] v) { return v[0]; } } mixin Test!(2); mixin Test!(3); void main() { float[2] a2; func1(a2); func2(a2); } Here the call to func1 is

Re: What's wrong with D's templates?

2009-12-21 Thread Walter Bright
Yigal Chripun wrote: On 22/12/2009 05:22, Walter Bright wrote: Kevin Bealer wrote: The performance / impl-hiding conflict is a fundamental problem -- if the user's compiler can't see the template method definitions, then it can't optimize them very well. If it can, then the user can too. Any me

Re: What's wrong with D's templates?

2009-12-21 Thread Walter Bright
grauzone wrote: Walter Bright wrote: I believe that D's template constraint feature fills the bill, it does everything Concepts purported to do, and more, in a simple and easily explained manner, except check the template body against the constraint. The latter is, in my not-so-humble opinion

Re: What's wrong with D's templates?

2009-12-21 Thread Yigal Chripun
On 22/12/2009 05:22, Walter Bright wrote: Kevin Bealer wrote: The performance / impl-hiding conflict is a fundamental problem -- if the user's compiler can't see the template method definitions, then it can't optimize them very well. If it can, then the user can too. Any method of compiling them

Re: What's wrong with D's templates?

2009-12-21 Thread Yigal Chripun
On 21/12/2009 22:41, Kevin Bealer wrote: dsimcha Wrote: == Quote from Yigal Chripun (yigal...@gmail.com)'s article but even more frustrating is the fact that template compilation bugs will also happen at the client. There's a whole range of designs for this and related issues and IMO the C++ d

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Tim Matthews
On 22/12/2009 1:16 p.m., Nick Sabalausky wrote: "Tim Matthews" wrote in message news:hgp10e$2sj...@digitalmars.com... On 21/12/2009 8:57 p.m., Don wrote: retard wrote: Sun, 20 Dec 2009 16:44:03 +0100, Don wrote: downs wrote: according to http://www.mail-archive.com/haskell-cafe%40haskell.o

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Walter Bright
Andrei Alexandrescu wrote: That definition is what was discussed in this thread and alleged to be anything but beautiful. I've been in museums in europe where they proudly display ornate swords and armor as "beautiful". I always kinda thought otherwise, because all that decoration and encrust

Re: one suggestion for improving the performance of gc and memroy management

2009-12-21 Thread Michel Fortin
On 2009-12-21 20:56:37 -0500, zsxxsz said: I have another idea about the gc and memroy management: each thread use it's own memory slice pool with using thread local storage, which can avoiding the global lock on system memory management. This is a pretty good idea, which happen to have been

Re: What's wrong with D's templates?

2009-12-21 Thread grauzone
Walter Bright wrote: Yigal Chripun wrote: But that doesn't mean the idea itself isn't valid. Perhaps a different language with different goals in mind can provide a much simpler non convoluted implementation and semantics for the same idea? You've shown in the past that you're willing to break

Re: What's wrong with D's templates?

2009-12-21 Thread Walter Bright
Kevin Bealer wrote: The performance / impl-hiding conflict is a fundamental problem -- if the user's compiler can't see the template method definitions, then it can't optimize them very well. If it can, then the user can too. Any method of compiling them that preserves enough info for the compil

Re: What's wrong with D's templates?

2009-12-21 Thread Walter Bright
Yigal Chripun wrote: But that doesn't mean the idea itself isn't valid. Perhaps a different language with different goals in mind can provide a much simpler non convoluted implementation and semantics for the same idea? You've shown in the past that you're willing to break backward compatibilit

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Andrei Alexandrescu
Tim Matthews wrote: On 21/12/2009 8:57 p.m., Don wrote: retard wrote: Sun, 20 Dec 2009 16:44:03 +0100, Don wrote: downs wrote: according to http://www.mail-archive.com/haskell-cafe%40haskell.org/msg63381.html I'll let this speak for itself. import Data.Array.Base (unsafeRead, unsafeWrite)

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Andrei Alexandrescu
Pelle Månsson wrote: On 12/22/2009 01:16 AM, Nick Sabalausky wrote: It's already been pointed out in a number of places that that's not quicksort. Quicksort is in-place and doesn't use the head as the pivot. Besides "It probably performs like a bitch" defeats the whole point of quicksort, doesn'

one suggestion for improving the performance of gc and memroy management

2009-12-21 Thread zsxxsz
Some days before, someone talked about the D's performance in multicore system. dsimcha gave one suggestion that in gc using spinlock maybe better than mutexlock. I have another idea about the gc and memroy management: each thread use it's own memory slice pool with using thread local storage, whic

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Pelle Månsson
On 12/22/2009 01:16 AM, Nick Sabalausky wrote: It's already been pointed out in a number of places that that's not quicksort. Quicksort is in-place and doesn't use the head as the pivot. Besides "It probably performs like a bitch" defeats the whole point of quicksort, doesn't it? And, going along

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Nick Sabalausky
"Tim Matthews" wrote in message news:hgp10e$2sj...@digitalmars.com... > On 21/12/2009 8:57 p.m., Don wrote: >> retard wrote: >>> Sun, 20 Dec 2009 16:44:03 +0100, Don wrote: >>> downs wrote: > according to > http://www.mail-archive.com/haskell-cafe%40haskell.org/msg63381.html > >>

Re: Go rant

2009-12-21 Thread Phil Deets
On Mon, 21 Dec 2009 14:01:23 -0500, Walter Bright wrote: retard wrote: Agreed. Will be fixed later. Keep in mind that D is older language than Scala - now tell me what mystruct.tupleof.stringof does - where's the documentation? From the top of my head I can imagine at least 200 differen

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Tim Matthews
On 21/12/2009 8:57 p.m., Don wrote: retard wrote: Sun, 20 Dec 2009 16:44:03 +0100, Don wrote: downs wrote: according to http://www.mail-archive.com/haskell-cafe%40haskell.org/msg63381.html I'll let this speak for itself. import Data.Array.Base (unsafeRead, unsafeWrite) [snip] Brilliant.

Re: QSort in D: is this best?

2009-12-21 Thread bearophile
Andrei Alexandrescu: > This is a great example that I don't have the time to look into now. It's a nice example, and I know you don't have a lot of time to implement it now. > Currently Phobos doesn't have the means to compute the cross-product of > ranges. The idea is to have standard means

Re: QSort in D: is this best?

2009-12-21 Thread Andrei Alexandrescu
This is a great example that I don't have the time to look into now. In essence the task is to generate all numbers of the form 2^^a*3^^b*5^^c where a, b, and c are natural numbers. Currently Phobos doesn't have the means to compute the cross-product of ranges. I encourage people to think abou

Re: What's wrong with D's templates?

2009-12-21 Thread bearophile
S: >This isn't a bug. This is how it is template code is supposed to work.< It's not a bug, but a smarter compiler can try to reduce binary size conflating parts of asm code that are equal, to reduce the size of the resulting binary. It's a way to reduce one of the disadvantages of C++/D-style

Re: What's wrong with D's templates?

2009-12-21 Thread BCS
Hello Yigal, On 20/12/2009 03:11, BCS wrote: I don't know how it does it but there has to be more to it in C# because they allow you to do thing to the objects that Object doesn't support. For that to happen, the objects have to be wrapped or tagged or something so that the generics code can m

Re: Go rant

2009-12-21 Thread Nick Sabalausky
"Andrei Alexandrescu" wrote in message news:4b2fcf53.9050...@erdani.org... > Walter Bright wrote: >> retard wrote: >>> I have several imperative language programming books and instead of >>> qsort they introduce the reader to the wonderful world of bubble sort! >> >> Bubble sort should be part o

Re: Go rant

2009-12-21 Thread Kevin Bealer
Walter Bright Wrote: > dsimcha wrote: > > == Quote from Walter Bright (newshou...@digitalmars.com)'s article > >> qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs) > >> prominently featured in Haskell's official introduction page: > >> http://www.haskell.org/haskellwiki/Int

Re: Go rant

2009-12-21 Thread Denis Koroskin
On Tue, 22 Dec 2009 00:10:44 +0300, Jérôme M. Berger wrote: Andrei Alexandrescu wrote: Walter Bright wrote: retard wrote: I have several imperative language programming books and instead of qsort they introduce the reader to the wonderful world of bubble sort! Bubble sort should be part

Re: What's wrong with D's templates?

2009-12-21 Thread S
On 2009-12-18 17:07:57 -0800, bearophile said: Yigal Chripun: .Net generics for example work by creating an instantiation for each value type (same as c++ templates) and one instantiation for all reference types since at the binary level all reference types are simply addresses. C++ can't do

Re: What's wrong with D's templates?

2009-12-21 Thread Kevin Bealer
yigal chripun Wrote: > of the three above I think option 3 is the worst design and option 2 is my > favorite design. I think that in reality you'll almost always want to define > such an interface and I really can't think of any useful use cases for an > unrestricted template parameter as in C+

Re: What's wrong with D's templates?

2009-12-21 Thread Nick Sabalausky
"retard" wrote in message news:hgnlug$45...@digitalmars.com... > Mon, 21 Dec 2009 04:05:01 -0700, Rainer Deyke wrote: > >> yigal chripun wrote: >>> Rainer Deyke Wrote: I prefer to think of option 2 as explicitly typed while option 3 uses type inference. Type inference is a good thing.

Re: Go rant

2009-12-21 Thread Jérôme M. Berger
Andrei Alexandrescu wrote: Walter Bright wrote: retard wrote: I have several imperative language programming books and instead of qsort they introduce the reader to the wonderful world of bubble sort! Bubble sort should be part of an introductory programming course, if only because: 1. it'

Re: What's wrong with D's templates?

2009-12-21 Thread Yigal Chripun
On 21/12/2009 19:53, Walter Bright wrote: Don wrote: The problem is, I'm not sure that it's feasible in general. At least, it's not obvious how to do it. C++0x Concepts tried to do it in a limited form, and it got so complicated nobody could figure out how it was supposed to work and it capsiz

Re: What's wrong with D's templates?

2009-12-21 Thread Kevin Bealer
dsimcha Wrote: > == Quote from Yigal Chripun (yigal...@gmail.com)'s article > > but even more frustrating is the fact that > > template compilation bugs will also happen at the client. > > There's a whole range of designs for this and related issues and IMO the > > C++ design is by far the worst o

Enhanced array appending

2009-12-21 Thread Steven Schveighoffer
All, I created a new patched druntime that prevents array stomping and at the same time increases append performance for thread-local array appending. The patch is attached to bugzilla entry 3637. ( http://d.puremagic.com/issues/show_bug.cgi?id=3637 ) For those of you unfamiliar with arra

Re: Go rant

2009-12-21 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s > I fail to see how in D you'd be hard pressed to think in terms of lower > level abstractions. > Andrei Devil's advocate since I mostly agree: Conservative GC?

Re: Go rant

2009-12-21 Thread Andrei Alexandrescu
retard wrote: Mon, 21 Dec 2009 12:13:48 -0600, Andrei Alexandrescu wrote: Daniel de Kok wrote: On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu said: "This code is shown for its elegance rather than its efficiency. Using ++ in this way is not generally considered good programming practice."

Re: Go rant

2009-12-21 Thread Andrei Alexandrescu
Walter Bright wrote: retard wrote: I have several imperative language programming books and instead of qsort they introduce the reader to the wonderful world of bubble sort! Bubble sort should be part of an introductory programming course, if only because: 1. it's an algorithm that gets rei

Re: writeln & cie. not reliable on Mac OS X

2009-12-21 Thread Michel Fortin
On 2009-12-21 14:34:39 -0500, Michel Fortin said: I have an annoying problem where writing to the output stream with writeln and other similar functions crash with an null dereference, but it appear to depend on the order the modules are compiled or linked. I wasn't able to reduce it to a I

writeln & cie. not reliable on Mac OS X

2009-12-21 Thread Michel Fortin
I have an annoying problem where writing to the output stream with writeln and other similar functions crash with an null dereference, but it appear to depend on the order the modules are compiled or linked. I wasn't able to reduce it to a I've found a workaround. I can add this at the beginni

Re: Go rant

2009-12-21 Thread Walter Bright
retard wrote: I have several imperative language programming books and instead of qsort they introduce the reader to the wonderful world of bubble sort! Bubble sort should be part of an introductory programming course, if only because: 1. it's an algorithm that gets reinvented if one is not

Re: Go rant

2009-12-21 Thread retard
Mon, 21 Dec 2009 12:13:48 -0600, Andrei Alexandrescu wrote: > Daniel de Kok wrote: >> On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu >> said: >>> "This code is shown for its elegance rather than its efficiency. Using >>> ++ in this way is not generally considered good programming practice." >>

Re: Go rant

2009-12-21 Thread retard
Mon, 21 Dec 2009 20:04:05 +0100, Lutger wrote: > retard wrote: > >> Mon, 21 Dec 2009 18:54:19 +0100, Daniel de Kok wrote: >> >>> On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu >>> said: "This code is shown for its elegance rather than its efficiency. Using ++ in this way is not gen

Re: Go rant

2009-12-21 Thread Lutger
retard wrote: > Mon, 21 Dec 2009 18:54:19 +0100, Daniel de Kok wrote: > >> On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu >> said: >>> "This code is shown for its elegance rather than its efficiency. Using >>> ++ in this way is not generally considered good programming practice." >>> >>> So

Re: Go rant

2009-12-21 Thread Walter Bright
retard wrote: Agreed. Will be fixed later. Keep in mind that D is older language than Scala - now tell me what mystruct.tupleof.stringof does - where's the documentation? From the top of my head I can imagine at least 200 different cases where the D/Phobos's documentation sucks. I would appre

Re: Go rant

2009-12-21 Thread retard
Mon, 21 Dec 2009 18:01:29 +0100, Daniel de Kok wrote: > On 2009-12-18 18:02:28 +0100, retard said: >> I've only seen how Scala solves problems elegantly. These are from some >> biased blog posts etc. Can you show one example that looks uglier in >> Scala, but looks decent in D or some other langu

Re: Go rant

2009-12-21 Thread retard
Mon, 21 Dec 2009 18:54:19 +0100, Daniel de Kok wrote: > On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu > said: >> "This code is shown for its elegance rather than its efficiency. Using >> ++ in this way is not generally considered good programming practice." >> >> So if the code is inefficien

Re: What's wrong with D's templates?

2009-12-21 Thread Yigal Chripun
On 20/12/2009 03:11, BCS wrote: Hello Yigal, On 18/12/2009 17:34, dsimcha wrote: I think variadics, static if and alias parameters qualify more as a "better design" than fixing "minor issues". actually they qualify as - "even worse design". duplicating the syntax like that is butt ugly.

Re: Go rant

2009-12-21 Thread Andrei Alexandrescu
Daniel de Kok wrote: On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu said: "This code is shown for its elegance rather than its efficiency. Using ++ in this way is not generally considered good programming practice." So if the code is inefficient and in poor programming practice, how in th

Re: Go rant

2009-12-21 Thread Andrei Alexandrescu
Daniel de Kok wrote: On 2009-12-18 20:39:08 +0100, Walter Bright said: Ain't that cool? But look closer. The advantage of quicksort is that it is an *in-place* sort. The Haskell one creates new arrays for every state in the sort. But it does have one nice property: due to laziness, the n-th

Re: What's wrong with D's templates?

2009-12-21 Thread Walter Bright
Don wrote: The problem is, I'm not sure that it's feasible in general. At least, it's not obvious how to do it. C++0x Concepts tried to do it in a limited form, and it got so complicated nobody could figure out how it was supposed to work and it capsized and sank. I don't think it's possibl

Re: Go rant

2009-12-21 Thread Daniel de Kok
On 2009-12-19 21:04:32 +0100, Andrei Alexandrescu said: "This code is shown for its elegance rather than its efficiency. Using ++ in this way is not generally considered good programming practice." So if the code is inefficient and in poor programming practice, how in this blessed world could

Re: Go rant

2009-12-21 Thread Daniel de Kok
On 2009-12-18 20:39:08 +0100, Walter Bright said: Ain't that cool? But look closer. The advantage of quicksort is that it is an *in-place* sort. The Haskell one creates new arrays for every state in the sort. But it does have one nice property: due to laziness, the n-th elements of the sorte

Re: dynamic classes and duck typing

2009-12-21 Thread Ary Borenszweig
Ary Borenszweig wrote: Ary Borenszweig wrote: retard wrote: Tue, 01 Dec 2009 03:16:47 -0800, Walter Bright wrote: Ary Borenszweig wrote: Can you show examples of points 2, 3 and 4? Have opDispatch look up the string in an associative array that returns an associated delegate, then call the

Re: Go rant

2009-12-21 Thread Daniel de Kok
On 2009-12-18 18:02:28 +0100, retard said: I've only seen how Scala solves problems elegantly. These are from some biased blog posts etc. Can you show one example that looks uglier in Scala, but looks decent in D or some other language? I can not paste any of this particular code ($WORK). From

Re: What's wrong with D's templates?

2009-12-21 Thread yigal chripun
Don Wrote: > yigal chripun wrote: > > Don Wrote: > >>> The way I see it we have three options: > >>> > >>> assume we have these definitions: > >>> interface I {...} > >>> class Foo : I {...} > >>> class Bar {...} // structurally compatible to I > >>> > >>> template tp (I) {...} > >>> > >>> 1) .Net

Re: What's wrong with D's templates?

2009-12-21 Thread Leandro Lucarella
Don, el 21 de diciembre a las 09:20 me escribiste: > >http://en.wikipedia.org/wiki/Duck_typing#Structural_type_systems > > That Wikipedia page doesn't any make sense to me. Is that *really* > what duck typing is? If so, it's a complete misnomer. Because it's > totally different to "if it looks lik

Re: dmd-x64

2009-12-21 Thread bearophile
alkor: > anybody see the 64-bit version of dmd compiler? I can't see it. It must be absent. Bye, bearophile

Re: What's wrong with D's templates?

2009-12-21 Thread Lutger
retard wrote: Thanks for links, that should help.

Re: What's wrong with D's templates?

2009-12-21 Thread retard
Mon, 21 Dec 2009 12:25:35 +0100, Lutger wrote: > Don wrote: > >> Lutger wrote: > ... >>> http://en.wikipedia.org/wiki/Duck_typing#Structural_type_systems >> >> That Wikipedia page doesn't any make sense to me. Is that *really* what >> duck typing is? If so, it's a complete misnomer. Because it's

dmd-x64

2009-12-21 Thread alkor
anybody see the 64-bit version of dmd compiler?

Re: What's wrong with D's templates?

2009-12-21 Thread Lutger
Don wrote: > Lutger wrote: ... >> http://en.wikipedia.org/wiki/Duck_typing#Structural_type_systems > > That Wikipedia page doesn't any make sense to me. Is that *really* what > duck typing is? If so, it's a complete misnomer. Because it's totally > different to "if it looks like a duck, quacks li

Re: What's wrong with D's templates?

2009-12-21 Thread retard
Mon, 21 Dec 2009 04:05:01 -0700, Rainer Deyke wrote: > yigal chripun wrote: >> Rainer Deyke Wrote: >>> I prefer to think of option 2 as explicitly typed while option 3 uses >>> type inference. Type inference is a good thing. > >> You might prefer that but it's incorrect. > > It's not incorrect,

Re: What's wrong with D's templates?

2009-12-21 Thread Rainer Deyke
yigal chripun wrote: > Rainer Deyke Wrote: >> I prefer to think of option 2 as explicitly typed while option 3 uses >> type inference. Type inference is a good thing. > You might prefer that but it's incorrect. It's not incorrect, it's another way of looking at the same thing. Structural type in

Re: What's wrong with D's templates?

2009-12-21 Thread Don
yigal chripun wrote: Don Wrote: The way I see it we have three options: assume we have these definitions: interface I {...} class Foo : I {...} class Bar {...} // structurally compatible to I template tp (I) {...} 1) .Net nominative typing: tp!(Foo) // OK tp!(Bar) //not OK 2) structural typi

Re: What's wrong with D's templates?

2009-12-21 Thread yigal chripun
Rainer Deyke Wrote: > yigal chripun wrote: > > 2) structural typing (similllar to Go?) > > tp!(Foo) // OK > > tp!(Bar) // also OK > > > > 3) C++ style templates where the compatibility check is against the > > *body* of the template. > > > > If you think of templates as functions the compiler ex

Re: What's wrong with D's templates?

2009-12-21 Thread Rainer Deyke
yigal chripun wrote: > 2) structural typing (similllar to Go?) > tp!(Foo) // OK > tp!(Bar) // also OK > > 3) C++ style templates where the compatibility check is against the > *body* of the template. > > If you think of templates as functions the compiler executes, the > difference between the la

Re: What's wrong with D's templates?

2009-12-21 Thread yigal chripun
Don Wrote: > > The way I see it we have three options: > > > > assume we have these definitions: > > interface I {...} > > class Foo : I {...} > > class Bar {...} // structurally compatible to I > > > > template tp (I) {...} > > > > 1) .Net nominative typing: > > tp!(Foo) // OK > > tp!(Bar) //no

Re: What's wrong with D's templates?

2009-12-21 Thread Don
yigal chripun wrote: Lutger Wrote: Yigal Chripun wrote: On 19/12/2009 01:31, Lutger wrote: Yigal Chripun wrote: On 18/12/2009 02:49, Tim Matthews wrote: In a reddit reply: "The concept of templates in D is exactly the same as in C++. There are minor technical differences, syntactic differ

Re: What's wrong with D's templates?

2009-12-21 Thread Don
Lutger wrote: Nick Sabalausky wrote: "Lutger" wrote in message news:hgl440$tl...@digitalmars.com... Yigal Chripun wrote: The .Net implementation isn't perfect of course and has a few issues that should be resolved, one of these is the problem with using operators. requiring interfaces by its

Re: What's wrong with D's templates?

2009-12-21 Thread yigal chripun
Lutger Wrote: > Yigal Chripun wrote: > > > On 19/12/2009 01:31, Lutger wrote: > >> Yigal Chripun wrote: > >> > >>> On 18/12/2009 02:49, Tim Matthews wrote: > In a reddit reply: "The concept of templates in D is exactly the same > as in C++. There are minor technical differences, syntact

Re: This seems to be the Haskell equivalent

2009-12-21 Thread Don
retard wrote: Sun, 20 Dec 2009 16:44:03 +0100, Don wrote: downs wrote: according to http://www.mail-archive.com/haskell-cafe%40haskell.org/msg63381.html I'll let this speak for itself. import Data.Array.Base (unsafeRead, unsafeWrite) [snip] Brilliant. What is so brilliant? Referential tr