Phobos packages a bit confusing

2009-11-29 Thread retard
Hi after using D1 and Tango for couple of years we decided to experiment with D2 and Phobos in a small scale project. For some reason the mostly flat package hierarchy seemed rather confusing. For instance, it took two of us 15 minutes to build a program that reads a line from user, converts t

Re: Phobos packages a bit confusing

2009-11-29 Thread Jason House
retard Wrote: > Hi > > after using D1 and Tango for couple of years we decided to experiment > with D2 and Phobos in a small scale project. For some reason the mostly > flat package hierarchy seemed rather confusing. > > For instance, it took two of us 15 minutes to build a program that reads

Re: Phobos packages a bit confusing

2009-11-29 Thread Andrei Alexandrescu
retard wrote: Hi after using D1 and Tango for couple of years we decided to experiment with D2 and Phobos in a small scale project. For some reason the mostly flat package hierarchy seemed rather confusing. For instance, it took two of us 15 minutes to build a program that reads a line from

Re: Phobos packages a bit confusing

2009-11-29 Thread Adam D. Ruppe
On Sun, Nov 29, 2009 at 07:12:50PM +, retard wrote: > after using D1 and Tango for couple of years we decided to experiment > with D2 and Phobos in a small scale project. For some reason the mostly > flat package hierarchy seemed rather confusing. Are you familiar with C's standard library?

Re: Phobos packages a bit confusing

2009-11-29 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > Walter and I discussed quite a few times the possibility of defining > std.all that publically imports all of std. My experiments show that a > short script importing std.all will compile slower, but not too slow, > compa

Re: Phobos packages a bit confusing

2009-11-29 Thread retard
Sun, 29 Nov 2009 14:36:24 -0500, Jason House wrote: > retard Wrote: > >> Hi >> >> after using D1 and Tango for couple of years we decided to experiment >> with D2 and Phobos in a small scale project. For some reason the mostly >> flat package hierarchy seemed rather confusing. >> >> For instanc

Re: Phobos packages a bit confusing

2009-11-29 Thread retard
Sun, 29 Nov 2009 15:30:14 -0500, Adam D. Ruppe wrote: > On Sun, Nov 29, 2009 at 07:12:50PM +, retard wrote: >> after using D1 and Tango for couple of years we decided to experiment >> with D2 and Phobos in a small scale project. For some reason the mostly >> flat package hierarchy seemed rathe

Re: Phobos packages a bit confusing

2009-11-29 Thread retard
Sun, 29 Nov 2009 20:26:07 +, dsimcha wrote: > == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s > article >> Walter and I discussed quite a few times the possibility of defining >> std.all that publically imports all of std. My experiments show that a >> short script importin

Re: Phobos packages a bit confusing

2009-11-29 Thread dsimcha
== Quote from retard (r...@tard.com.invalid)'s article > Sun, 29 Nov 2009 20:26:07 +, dsimcha wrote: > > == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s > > article > >> Walter and I discussed quite a few times the possibility of defining > >> std.all that publically imports

Re: Phobos packages a bit confusing

2009-11-29 Thread Andrei Alexandrescu
dsimcha wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article Walter and I discussed quite a few times the possibility of defining std.all that publically imports all of std. My experiments show that a short script importing std.all will compile slower, but not too s

Re: Phobos packages a bit confusing

2009-11-29 Thread Nick Sabalausky
"retard" wrote in message news:heuh3h$o7...@digitalmars.com... > Hi > > after using D1 and Tango for couple of years we decided to experiment > with D2 and Phobos in a small scale project. For some reason the mostly > flat package hierarchy seemed rather confusing. > > For instance, it took two o

Re: Phobos packages a bit confusing

2009-11-29 Thread dsimcha
== Quote from Nick Sabalausky (a...@a.a)'s article > "retard" wrote in message > news:heuh3h$o7...@digitalmars.com... > > Hi > > > > after using D1 and Tango for couple of years we decided to experiment > > with D2 and Phobos in a small scale project. For some reason the mostly > > flat package hi

Re: Phobos packages a bit confusing

2009-11-29 Thread dsimcha
== Quote from retard (r...@tard.com.invalid)'s article > Hi > after using D1 and Tango for couple of years we decided to experiment > with D2 and Phobos in a small scale project. For some reason the mostly > flat package hierarchy seemed rather confusing. > For instance, it took two of us 15 minute

Re: Phobos packages a bit confusing

2009-11-29 Thread retard
Mon, 30 Nov 2009 04:51:19 +, dsimcha wrote: > == Quote from Nick Sabalausky (a...@a.a)'s article >> "retard" wrote in message >> news:heuh3h$o7...@digitalmars.com... >> > Hi >> > >> > after using D1 and Tango for couple of years we decided to experiment >> > with D2 and Phobos in a small scal

Re: Phobos packages a bit confusing

2009-11-29 Thread retard
Mon, 30 Nov 2009 04:55:29 +, dsimcha wrote: > == Quote from retard (r...@tard.com.invalid)'s article >> Hi >> after using D1 and Tango for couple of years we decided to experiment >> with D2 and Phobos in a small scale project. For some reason the mostly >> flat package hierarchy seemed rather

Re: Phobos packages a bit confusing

2009-11-30 Thread KennyTM~
On Nov 30, 09 14:02, retard wrote: Mon, 30 Nov 2009 04:51:19 +, dsimcha wrote: == Quote from Nick Sabalausky (a...@a.a)'s article "retard" wrote in message news:heuh3h$o7...@digitalmars.com... Hi after using D1 and Tango for couple of years we decided to experiment with D2 and Phobos in

Re: Phobos packages a bit confusing

2009-11-30 Thread Ary Borenszweig
KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } yuck. Yuck?? I find that code very elegant. How would you like it to be?

Re: Phobos packages a bit confusing

2009-11-30 Thread Lars T. Kyllingstad
Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } yuck. Yuck?? I find that code very elegant. How would you l

Re: Phobos packages a bit confusing

2009-11-30 Thread retard
Mon, 30 Nov 2009 12:01:22 +0100, Ary Borenszweig wrote: > KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. >>> >>> foreach (line; new Lines!(char) (new File ("foobar.txt"))) >>>Cout (line).newline; >>>

Re: Phobos packages a bit confusing

2009-11-30 Thread KennyTM~
On Nov 30, 09 19:01, Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } yuck. Yuck?? I find that code very elegant

Re: Phobos packages a bit confusing

2009-11-30 Thread retard
Mon, 30 Nov 2009 21:06:21 +0800, KennyTM~ wrote: > On Nov 30, 09 19:01, Ary Borenszweig wrote: >> KennyTM~ wrote: > By > far the two most important pieces of I/O functionality I need are: > > 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("fo

Re: Phobos packages a bit confusing

2009-11-30 Thread Nick Sabalausky
"retard" wrote in message news:hevn56$2to...@digitalmars.com... > Mon, 30 Nov 2009 04:51:19 +, dsimcha wrote: >> >> Yeah, I dislike Tango's (and Java's) I/O design. I think it's a classic >> example of overengineering. I don't care how efficient, flexible, >> complete, etc. it is if it does

Re: Phobos packages a bit confusing

2009-11-30 Thread Nick Sabalausky
"retard" wrote in message news:hevo45$2to...@digitalmars.com... > Mon, 30 Nov 2009 04:55:29 +, dsimcha wrote: > > Well, they have been teaching the Java i/o stuff to first year students > for a while now. I completely agree that it's a bit too complicated for > novices, but it's not the only

Re: Phobos packages a bit confusing

2009-11-30 Thread Andrei Alexandrescu
retard wrote: Mon, 30 Nov 2009 21:06:21 +0800, KennyTM~ wrote: On Nov 30, 09 19:01, Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout

Re: Phobos packages a bit confusing

2009-11-30 Thread Andrei Alexandrescu
retard wrote: Mon, 30 Nov 2009 12:01:22 +0100, Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } yuck. Yuck??

Re: Phobos packages a bit confusing

2009-11-30 Thread Denis Koroskin
On Mon, 30 Nov 2009 18:25:41 +0300, Andrei Alexandrescu wrote: retard wrote: Mon, 30 Nov 2009 12:01:22 +0100, Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (

Re: Phobos packages a bit confusing

2009-11-30 Thread dsimcha
== Quote from retard (r...@tard.com.invalid)'s article > Mon, 30 Nov 2009 21:06:21 +0800, KennyTM~ wrote: > > On Nov 30, 09 19:01, Ary Borenszweig wrote: > >> KennyTM~ wrote: > > By > > far the two most important pieces of I/O functionality I need are: > > > > 1. Read a text file li

Re: Phobos packages a bit confusing

2009-11-30 Thread dsimcha
== Quote from dsimcha (dsim...@yahoo.com)'s article > == Quote from retard (r...@tard.com.invalid)'s article > > Mon, 30 Nov 2009 21:06:21 +0800, KennyTM~ wrote: > > > On Nov 30, 09 19:01, Ary Borenszweig wrote: > > >> KennyTM~ wrote: > > > By > > > far the two most important pieces of I/O

Re: Phobos packages a bit confusing

2009-11-30 Thread Andrei Alexandrescu
Denis Koroskin wrote: On Mon, 30 Nov 2009 18:25:41 +0300, Andrei Alexandrescu wrote: retard wrote: Mon, 30 Nov 2009 12:01:22 +0100, Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (li

Re: Phobos packages a bit confusing

2009-11-30 Thread Roman Ivanov
retard Wrote: > Java isn't that bad IMO - you just have to remember the buffer: > > BufferedReader input = new BufferedReader(new FileReader("foo")); > try { > String line = null; > > while (( line = input.readLine()) != null) { > } > } > finally { > input.close(); > } One of the importa

Re: Phobos packages a bit confusing

2009-11-30 Thread dsimcha
== Quote from Roman Ivanov (isro...@km.ru)'s article > retard Wrote: > > Java isn't that bad IMO - you just have to remember the buffer: > > > > BufferedReader input = new BufferedReader(new FileReader("foo")); > > try { > > String line = null; > > > > while (( line = input.readLine()) != null)

Re: Phobos packages a bit confusing

2009-11-30 Thread Leandro Lucarella
Lars T. Kyllingstad, el 30 de noviembre a las 12:16 me escribiste: > Ary Borenszweig wrote: > >KennyTM~ wrote: > By > far the two most important pieces of I/O functionality I need are: > > 1. Read a text file line-by-line. > >>> > >>>foreach (line; new Lines!(char) (new File ("foo

Re: Phobos packages a bit confusing

2009-11-30 Thread Pelle Månsson
Ary Borenszweig wrote: KennyTM~ wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } yuck. Yuck?? I find that code very elegant. How would you l

Re: Phobos packages a bit confusing

2009-11-30 Thread bearophile
Pelle MÃ¥nsson: > foreach (line; open("foobar.txt")) { >writeln(line); > } With the xio module of my dlibs: import d.xio: xfile; foreach (line; xfile("foobar.txt")) putr(line); xfile is optimized to reduce memory rellocations as much as possible in the most common case of about 90 char

Re: Phobos packages a bit confusing

2009-11-30 Thread Andrei Alexandrescu
bearophile wrote: Pelle MÃ¥nsson: foreach (line; open("foobar.txt")) { writeln(line); } With the xio module of my dlibs: import d.xio: xfile; foreach (line; xfile("foobar.txt")) putr(line); xfile is optimized to reduce memory rellocations as much as possible in the most common case

Re: Phobos packages a bit confusing

2009-11-30 Thread bearophile
Andrei Alexandrescu: > Why not just reuse the same buffer as the previous line? That approach > is inherently adaptive. That approach is unsafe. xfile yields byte strings, in D1. When I write 10 lines long scripts I usually don't need every bit of optimization, I need the less bug-prone code as

Re: Phobos packages a bit confusing

2009-12-01 Thread Pelle Månsson
bearophile wrote: Andrei Alexandrescu: Why not just reuse the same buffer as the previous line? That approach is inherently adaptive. That approach is unsafe. xfile yields byte strings, in D1. When I write 10 lines long scripts I usually don't need every bit of optimization, I need the less

Re: Phobos packages a bit confusing

2009-12-01 Thread Denis Koroskin
On Tue, 01 Dec 2009 15:22:23 +0300, Pelle Månsson wrote: bearophile wrote: Andrei Alexandrescu: Why not just reuse the same buffer as the previous line? That approach is inherently adaptive. That approach is unsafe. xfile yields byte strings, in D1. When I write 10 lines long scripts I

Re: Phobos packages a bit confusing

2009-12-01 Thread Pelle Månsson
Denis Koroskin wrote: On Tue, 01 Dec 2009 15:22:23 +0300, Pelle Månsson wrote: bearophile wrote: Andrei Alexandrescu: Why not just reuse the same buffer as the previous line? That approach is inherently adaptive. That approach is unsafe. xfile yields byte strings, in D1. When I write 10 l

Re: Phobos packages a bit confusing

2009-12-01 Thread Rainer Deyke
Pelle Månsson wrote: > File looks like a constructor. You are not constructing a file you open > for reading. "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere to disambiguate. -- Rainer Deyke - rain...@eldw

Re: Phobos packages a bit confusing

2009-12-01 Thread torhu
On 30.11.2009 7:02, retard wrote: foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } To be fair, it's a bit simpler than that in Tango: foreach (line; new TextFileInput("foobar.txt")) Cout (line).newline; } 2. Read a whole file into an array of bytes.

Re: Phobos packages a bit confusing

2009-12-01 Thread bearophile
Rainer Deyke: > "open" by itself is ambiguous. What are you opening? A window? A > network port? I think the word "file" needs to be in there somewhere to > disambiguate. When you program in Python you remember that open is a built-in function to open files :-) When you want to open other thi

Re: Phobos packages a bit confusing

2009-12-01 Thread retard
Tue, 01 Dec 2009 18:58:25 -0500, bearophile wrote: > Rainer Deyke: >> "open" by itself is ambiguous. What are you opening? A window? A >> network port? I think the word "file" needs to be in there somewhere >> to disambiguate. > > When you program in Python you remember that open is a built-i

Re: Phobos packages a bit confusing

2009-12-01 Thread Pelle Månsson
retard wrote: Tue, 01 Dec 2009 18:58:25 -0500, bearophile wrote: Rainer Deyke: "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere to disambiguate. When you program in Python you remember that open is a buil

Re: Phobos packages a bit confusing

2009-12-01 Thread Pelle Månsson
Rainer Deyke wrote: Pelle Månsson wrote: File looks like a constructor. You are not constructing a file you open for reading. "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere to disambiguate. Something l

Re: Phobos packages a bit confusing

2009-12-01 Thread Walter Bright
retard wrote: Namespaces in general seem rather useful. I hate the php like 'there's a flat global scope and everything is a free function approach'. It's annoying me each time I use phobos. If you have the same name declared in multiple imports, you cannot refer to it without qualification (

Re: Phobos packages a bit confusing

2009-12-01 Thread retard
Wed, 02 Dec 2009 08:38:29 +0100, Pelle Månsson wrote: > retard wrote: >> Tue, 01 Dec 2009 18:58:25 -0500, bearophile wrote: >> >>> Rainer Deyke: "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere

Re: Phobos packages a bit confusing

2009-12-02 Thread Pelle Månsson
retard wrote: Wed, 02 Dec 2009 08:38:29 +0100, Pelle Månsson wrote: retard wrote: Tue, 01 Dec 2009 18:58:25 -0500, bearophile wrote: Rainer Deyke: "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere to dis

Re: Phobos packages a bit confusing

2009-12-02 Thread Rainer Deyke
Pelle Månsson wrote: > Rainer Deyke wrote: >> "open" by itself is ambiguous. What are you opening? A window? A >> network port? I think the word "file" needs to be in there somewhere to >> disambiguate. >> >> > Something like new BufferedReader(new FileReader("foo.txt"))? It's quite > unambiguo

Re: Phobos packages a bit confusing

2009-12-02 Thread bearophile
retard: > Also IIRC Python has built-in print() command. What if I want to > redefine this to mean printing to a graphical quake like game console. In Python3 there is a built-in print function, that is a reference to a callable object. So you just need to redefine it, like this: def print(...)

Re: Phobos packages a bit confusing

2009-12-02 Thread Jérôme M. Berger
Rainer Deyke wrote: Pelle Månsson wrote: Rainer Deyke wrote: "open" by itself is ambiguous. What are you opening? A window? A network port? I think the word "file" needs to be in there somewhere to disambiguate. Something like new BufferedReader(new FileReader("foo.txt"))? It's quite una

Re: Phobos packages a bit confusing

2009-12-05 Thread Andrei Alexandrescu
retard wrote: Mon, 30 Nov 2009 04:51:19 +, dsimcha wrote: By far the two most important pieces of I/O functionality I need are: 1. Read a text file line-by-line. foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout (line).newline; } 2. Read a whole file into an array of b