Re: isRef, isLazy, isOut

2009-12-20 Thread Kasumi Hanazuki
(2009/12/21 4:43), Andrei Alexandrescu wrote: > Speaking of isLazy - any fresh ideas on dissing lazy? FWIW we can > replace it with the conversion of expressions to delegates. The > resulting situation is liable to a few ambiguities but is much better > than lazy. Nobody seemed to mention in the

Re: QSort in D: is this best?

2009-12-20 Thread BCS
Hello downs, Or are there any bugs/optimization opportunities I'm missing? void qsort(T)(T[] array) { if (array.length < 2) return; static int i; auto pivot = array[i++%$]; // from is base-0, to is base-1. int from = 0, to = array.length; while (from != to) { if (array[from] >= pivot && array[t

Re: isRef, isLazy, isOut

2009-12-20 Thread Eldar Insafutdinov
Max Samukha Wrote: > On 19.12.2009 23:00, Walter Bright wrote: > > Andrei Alexandrescu wrote: > >> I asked in vain for is(var == ref), is(var == out) etc. > > > > That's because 'is' works with types, not symbols. It didn't fit. > > Will there be a way to get storage classes from function symbols

Re: Problems with Socket on linux

2009-12-20 Thread 4ybaka
4ybaka Wrote: > Hi! > I run code like this on linux (Arch and Kubuntu 9.04): > TcpSocket socket = new TcpSocket(new InternetAddress("www.google.com", > 80)); > socket.send("GET /intl/en_ALL/images/logo.gif HTTP/1.0\r\n\r\n"); > SocketStream socketStream = new SocketStream(socket

Problems with Socket on linux

2009-12-20 Thread 4ybaka
Hi! I run code like this on linux (Arch and Kubuntu 9.04): TcpSocket socket = new TcpSocket(new InternetAddress("www.google.com", 80)); socket.send("GET /intl/en_ALL/images/logo.gif HTTP/1.0\r\n\r\n"); SocketStream socketStream = new SocketStream(socket); num = sock

Re: isRef, isLazy, isOut

2009-12-20 Thread Max Samukha
On 19.12.2009 23:00, Walter Bright wrote: Andrei Alexandrescu wrote: I asked in vain for is(var == ref), is(var == out) etc. That's because 'is' works with types, not symbols. It didn't fit. Will there be a way to get storage classes from function symbols or types? Currently, we have to use

Re: isRef, isLazy, isOut

2009-12-20 Thread Andrei Alexandrescu
Walter Bright wrote: Chris Nicholson-Sauls wrote: Walter Bright wrote: Andrei Alexandrescu wrote: I asked in vain for is(var == ref), is(var == out) etc. That's because 'is' works with types, not symbols. It didn't fit. is(typeof(var) == ref) ? No, because ref is not part of the type. It

Re: isRef, isLazy, isOut

2009-12-20 Thread Walter Bright
Chris Nicholson-Sauls wrote: Walter Bright wrote: Andrei Alexandrescu wrote: I asked in vain for is(var == ref), is(var == out) etc. That's because 'is' works with types, not symbols. It didn't fit. is(typeof(var) == ref) ? No, because ref is not part of the type. It's a storage class.

Re: Go rant

2009-12-20 Thread retard
Sat, 19 Dec 2009 21:29:45 -0600, Andrei Alexandrescu wrote: > dsimcha wrote: >> == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s >>> "This code is shown for its elegance rather than its efficiency. Using >>> ++ in this way is not generally considered good programming practice."

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

2009-12-20 Thread BCS
Hello Lutger, 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 itself isn't the problem though. The only drawback in this case is verbosity which isn't re

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

2009-12-20 Thread retard
Sun, 20 Dec 2009 18:53:56 +0100, Lutger wrote: > I'm not sure, I don't think so. From what I understand, duck typing is > supposed to be dynamic, while structural and nominative typing are part > of a static type system. I meant the non-nominative kind of typing, > whatever it is. > > fwiw, this

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

2009-12-20 Thread Lutger
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

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

2009-12-20 Thread Nick Sabalausky
"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 itself isn't the problem though

Re: This seems to be the Haskell equivalent

2009-12-20 Thread retard
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? Referent

Re: QSort in D: is this best?

2009-12-20 Thread Sean Kelly
downs Wrote: > Or are there any bugs/optimization opportunities I'm missing? > > void qsort(T)(T[] array) { > if (array.length < 2) return; > static int i; > auto pivot = array[i++%$]; > // from is base-0, to is base-1. > int from = 0, to = array.length; > while (from != to) { > i

Re: QSort in D: is this best?

2009-12-20 Thread bearophile
You can try translating this in efficient, readable and short D2 code using Phobos2 (the purpose is to find spots where Phobos2 may need improvements): http://rosettacode.org/wiki/Hamming_numbers#Haskell Haskell version: hamming = 1 : map (2*) hamming `merge` map (3*) hamming `merge` map (5*) ha

Re: This seems to be the Haskell equivalent

2009-12-20 Thread Don
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: transporting qualifier from parameter to the return value

2009-12-20 Thread Steven Schveighoffer
On Sun, 20 Dec 2009 07:58:06 -0500, Jason House wrote: Steven Schveighoffer Wrote: On Sat, 19 Dec 2009 18:35:13 -0500, Jason House wrote: > The meaning of inout by a nested function isn't obvious when the > enclosing function is already using inout. Does inout of the nested > function mat

Re: QSort in D: is this best?

2009-12-20 Thread Lutger
downs wrote: > Lutger wrote: >> downs wrote: >> >>> Or are there any bugs/optimization opportunities I'm missing? >>> >>> void qsort(T)(T[] array) { >>> if (array.length < 2) return; >>> static int i; >>> auto pivot = array[i++%$]; >>> // from is base-0, to is base-1. >>> int from = 0,

Re: QSort in D: is this best?

2009-12-20 Thread downs
Lutger wrote: > downs wrote: > >> Or are there any bugs/optimization opportunities I'm missing? >> >> void qsort(T)(T[] array) { >> if (array.length < 2) return; >> static int i; >> auto pivot = array[i++%$]; >> // from is base-0, to is base-1. >> int from = 0, to = array.length; >> wh

Re: transporting qualifier from parameter to the return value

2009-12-20 Thread Jason House
Steven Schveighoffer Wrote: > On Sat, 19 Dec 2009 18:35:13 -0500, Jason House > wrote: > > > The meaning of inout by a nested function isn't obvious when the > > enclosing function is already using inout. Does inout of the nested > > function match that of the enclosing function? Or are th

Re: QSort in D: is this best?

2009-12-20 Thread Lutger
downs wrote: > Or are there any bugs/optimization opportunities I'm missing? > > void qsort(T)(T[] array) { > if (array.length < 2) return; > static int i; > auto pivot = array[i++%$]; > // from is base-0, to is base-1. > int from = 0, to = array.length; > while (from != to) { > i

This seems to be the Haskell equivalent

2009-12-20 Thread downs
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) import Data.Array.ST import Control.Monad.ST myqsort :: STUArray s Int Int -> Int -> Int -> ST s () myqsort a lo hi | lo < hi

QSort in D: is this best?

2009-12-20 Thread downs
Or are there any bugs/optimization opportunities I'm missing? void qsort(T)(T[] array) { if (array.length < 2) return; static int i; auto pivot = array[i++%$]; // from is base-0, to is base-1. int from = 0, to = array.length; while (from != to) { if (array[from] >= pivot && array[t

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

2009-12-20 Thread Lutger
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 differences, but it is

Re: isRef, isLazy, isOut

2009-12-20 Thread Chris Nicholson-Sauls
Walter Bright wrote: Andrei Alexandrescu wrote: I asked in vain for is(var == ref), is(var == out) etc. That's because 'is' works with types, not symbols. It didn't fit. is(typeof(var) == ref) ? -- Chris Nicholson-Sauls