Re: D vs C++

2010-12-26 Thread Jérôme M. Berger
bearophile wrote: > J.M. Berger: > >> Well, that makes it 3 valid points out of 11 still ;) > > Please Jerome, this time don't feed the list owner :-) > > Bye, > bearophile :D Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr

Re: typeof(t) not working correctly?

2010-12-26 Thread Robert Jacques
On Sun, 26 Dec 2010 22:48:42 -0700, %u wrote: Hi, I'm running this code below, and it returns an array of length zero for both print statements. Is this a bug, or am I missing something? Thank you! private import std.stdio; private import std.traits; class Temp { public int bas

typeof(t) not working correctly?

2010-12-26 Thread %u
Hi, I'm running this code below, and it returns an array of length zero for both print statements. Is this a bug, or am I missing something? Thank you! private import std.stdio; private import std.traits; class Temp { public int base1; public void foo() { writeln("foo base cal

Re: auto init & what the code means

2010-12-26 Thread Jonathan M Davis
On Sunday 26 December 2010 15:02:42 Daniel Gibson wrote: > Am 26.12.2010 23:04, schrieb Jonathan M Davis: > > On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > >> On 12/26/10 8:54 AM, spir wrote: > >>> On Sun, 26 Dec 2010 14:54:12 +0100 > >>> > >>> Andrej Mitrovic wrote: > in

Re: D vs C++

2010-12-26 Thread bearophile
J.M. Berger: > Well, that makes it 3 valid points out of 11 still ;) Please Jerome, this time don't feed the list owner :-) Bye, bearophile

Re: How do I make/use my own run-time library?

2010-12-26 Thread %u
Thank you for the response! Unfortunately, though, that only gives me the name of the C functions, not the actual headers. I need to know the parameters and return type of each function in order to be able to replace the library.

Re: auto init & what the code means

2010-12-26 Thread Tomek Sowiński
spir wrote: > On Sun, 26 Dec 2010 14:54:12 +0100 > Andrej Mitrovic wrote: > > > int i;// auto-initialized to int.init > > int i = void; // not initialized > > Thanks. Actually this solves my "semantic" issue, did not even think > at 'void'. (I will use it often). By the way, I don't want to

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
On 12/27/10, Daniel Gibson wrote: > I really like how D does this: Make the safe thing default and the > unsafe thing possible via more typing. Compare this to Go, where the safe thing is the only way of doing things and the unsafe thing is impossible*. Unsafe can be useful, and D allows it. But

Re: auto init & what the code means

2010-12-26 Thread Daniel Gibson
Am 26.12.2010 23:04, schrieb Jonathan M Davis: On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: On 12/26/10 8:54 AM, spir wrote: On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: int i;// auto-initialized to int.init int i = void; // not initialized Thanks. Actua

Re: D vs C++

2010-12-26 Thread Walter Bright
Jérôme M. Berger wrote: 3. inline assembler I have almost never used inline assembler even in languages that support it. Of course, this is only a sub-point of your point 6: using inline assembly in a language as slow as Python would be completely pointless. Inline assembly isn't just for spee

Re: auto init & what the code means

2010-12-26 Thread Jonathan M Davis
On Sunday 26 December 2010 07:08:22 Andrei Alexandrescu wrote: > On 12/26/10 8:54 AM, spir wrote: > > On Sun, 26 Dec 2010 14:54:12 +0100 > > > > Andrej Mitrovic wrote: > >> int i;// auto-initialized to int.init > >> int i = void; // not initialized > > > > Thanks. Actually this solves my "se

Re: D vs C++

2010-12-26 Thread Jérôme M. Berger
Walter Bright wrote: > bearophile wrote: >> One of the few advantages of D over Python is that in D you are able to >> implement efficient and custom data structures without leaving the D >> language >> itself :-) > > few? > > How about: > > 1. scope guard Agreed > 2. multithreaded programming

Re: How do I make/use my own run-time library?

2010-12-26 Thread Simen kjaeraas
%u wrote: Hi, I've been trying to make my own run-time library for D, but I've come across a dead end: *any* library I make will inherently depend on SNN.lib, and there are no headers for that C run-time library. How can I write my own library in place of SNN.lib if I do not know what

Re: D vs C++

2010-12-26 Thread Seth Hoenig
This is certainly a personal preference, but I would add static typing to that list. On Sun, Dec 26, 2010 at 2:06 PM, Walter Bright wrote: > bearophile wrote: > >> One of the few advantages of D over Python is that in D you are able to >> implement efficient and custom data structures without l

Re: Phobos usability with text files

2010-12-26 Thread bearophile
Andrei: > Well the D Zen would attempt to reconcile the two such that the obvious > option is the safest and the fastest.< That's indeed better (but not always possible). >Let's also not forget that "safe" is a bit abused here - we're not talking >about lack of safety as much as incorrect res

Re: D vs C++

2010-12-26 Thread Walter Bright
bearophile wrote: One of the few advantages of D over Python is that in D you are able to implement efficient and custom data structures without leaving the D language itself :-) few? How about: 1. scope guard 2. multithreaded programming (the GIL doesn't count) 3. inline assembler 4. immutab

How do I make/use my own run-time library?

2010-12-26 Thread %u
Hi, I've been trying to make my own run-time library for D, but I've come across a dead end: *any* library I make will inherently depend on SNN.lib, and there are no headers for that C run-time library. How can I write my own library in place of SNN.lib if I do not know what the function specific

Re: Phobos usability with text files

2010-12-26 Thread Andrei Alexandrescu
On 12/26/10 11:56 AM, bearophile wrote: Andrei: But you don't need a new string for each line to evaluate max over line lengths; the current byLine works.< Right. There are various different ways to implement that little task in functional style. But the task requires to print the longest on

Re: Phobos usability with text files

2010-12-26 Thread Brad Roberts
On Sun, 26 Dec 2010, bearophile wrote: > Adam D. Ruppe: > > > Remember, a lot of your posts are actually very subjective. Those > > things tend to get a lot of debate without an objective right or > > wrong coming out of it. It could go both ways. > > Right. But I have discussed a lot about usab

Re: Phobos usability with text files

2010-12-26 Thread bearophile
Adam D. Ruppe: > Remember, a lot of your posts are actually very subjective. Those > things tend to get a lot of debate without an objective right or > wrong coming out of it. It could go both ways. Right. But I have discussed a lot about usability & egonomy matters in the Python newsgroups too

Re: Phobos usability with text files

2010-12-26 Thread bearophile
Michel Fortin: > > But you don't need a new string for each line to evaluate max over line > > lengths; the current byLine works. > > That's true. > > > > Generally I think buffer reuse in byLine() is too valuable to let go. > > I also agree it's wasteful. See my answers to Andrei. > But

Re: Phobos usability with text files

2010-12-26 Thread Adam D. Ruppe
bearophile wrote: > Talking about usability and egonomy in this newsgroups > is sometimes a very tiring job :-) Remember, a lot of your posts are actually very subjective. Those things tend to get a lot of debate without an objective right or wrong coming out of it. It could go both ways.

Re: Phobos usability with text files

2010-12-26 Thread Michel Fortin
On 2010-12-26 12:13:41 -0500, Andrei Alexandrescu said: On 12/26/10 10:12 AM, bearophile wrote: This is related to this (closed) issue, but this time I prefer to discuss the topic on the newsgroup: http://d.puremagic.com/issues/show_bug.cgi?id=4474 To show why this enhancement request is us

Re: Phobos usability with text files

2010-12-26 Thread bearophile
Andrei: >But you don't need a new string for each line to evaluate max over line >lengths; the current byLine works.< Right. There are various different ways to implement that little task in functional style. But the task requires to print the longest ones. So you have to filter according to t

Re: Phobos usability with text files

2010-12-26 Thread Andrei Alexandrescu
On 12/26/10 10:12 AM, bearophile wrote: This is related to this (closed) issue, but this time I prefer to discuss the topic on the newsgroup: http://d.puremagic.com/issues/show_bug.cgi?id=4474 To show why this enhancement request is useful I use a little scripting task. A D2 program has to rea

Re: D vs C++

2010-12-26 Thread bearophile
Jonathan M Davis: > and the labeled break and continue in D just makes them that > much better, I agree that D labeled break and continue are nice to have, I miss them in Python :-) In Python where you need a labeled break you sometimes have to replace the whole block of code with a function

Phobos usability with text files

2010-12-26 Thread bearophile
This is related to this (closed) issue, but this time I prefer to discuss the topic on the newsgroup: http://d.puremagic.com/issues/show_bug.cgi?id=4474 To show why this enhancement request is useful I use a little scripting task. A D2 program has to read a file that contains one word in each li

Re: auto init & what the code means

2010-12-26 Thread Andrei Alexandrescu
On 12/26/10 8:54 AM, spir wrote: On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: int i;// auto-initialized to int.init int i = void; // not initialized Thanks. Actually this solves my "semantic" issue, did not even think at 'void'. (I will use it often). By the way, I don't wa

Re: Installation problem

2010-12-26 Thread Anders F Björklund
Iain Buclaw wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article Anyone has had a similar issue? http://forums.codeblocks.org/index.php?topic=13923.0 Andrei Shouldn't codeblocks be using -lphobos2? Code::Blocks uses gcc to do the linking, and uses -lphobos (on U

Re: auto init & what the code means

2010-12-26 Thread bearophile
spir: > Actually this solves my "semantic" issue, did not even think at 'void'. (I > will use it often). Do not use =void often, it's for performance critical situations only (and other uncommon situations). It goes against the D way. Bye, bearophile

Re: auto init & what the code means

2010-12-26 Thread spir
On Sun, 26 Dec 2010 14:54:12 +0100 Andrej Mitrovic wrote: > int i;// auto-initialized to int.init > int i = void; // not initialized Thanks. Actually this solves my "semantic" issue, did not even think at 'void'. (I will use it often). By the way, I don't want to play the superhero with un

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
Well that's why I declare my variables right where I need them, compared to e.g. Pascal where you have to define all variables at the top. But If I understand correctly, then you can use the following: 3) int i = int.init; // meant to be auto-initialized to int.init 4) int i; // auto-initialized

Re: auto init & what the code means

2010-12-26 Thread bearophile
Andrej Mitrovic: > int i;// auto-initialized to int.init > int i = void; // not initialized I think the OP meant: 1) int i = void; // not initialized 2) int i = 0; // initialized to 0 3) int i; // meant to be auto-initialized to int.init, similar to case 2 4) int i; // auto-initialized to in

Re: auto init & what the code means

2010-12-26 Thread Andrej Mitrovic
int i;// auto-initialized to int.init int i = void; // not initialized There is no ambiguity. If you want to play with non-initialized values (and play a superhero) you have to work extra and "initialize" those variables with void, which means they're uninitialized. On 12/26/10, spir wrote:

auto init & what the code means

2010-12-26 Thread spir
Hello, I have a problem with D's auto-init feature. When reading in someone else's code int i; there is no way, I guess, to know whether this means "i is initialised to 0" or "i is left undefined". For this reason, in the former case I do explicitely initialise. Thus, int i = 0;

Re: D vs C++

2010-12-26 Thread Jonathan M Davis
On Sunday 26 December 2010 02:38:53 Walter Bright wrote: > Daniel Gibson wrote: > > I don't think so. They're much more clean and readable than goto (they > > just restart/jump behind the current loop or, if you use them with > > labels, an outer loop - IMHO that's quite different from jumping to >

Re: Infinite BidirectionalRange?

2010-12-26 Thread spir
On Sun, 26 Dec 2010 00:36:26 + (UTC) Tomek Sowiński wrote: > > > > > > A random-access range is a bidirectional range OR an infinite forward > > range that offers the primitive opIndex. > > > > > > > > I can't be sure whether the former should also provide the primitive > > 'length'. >

Re: tail const

2010-12-26 Thread Simen kjaeraas
Simen kjaeraas wrote: After more problems, I have also come to the conclusion that what is most commonly needed is not really tail-const, but head-mutable. Why this took me more than a few minutes to consider, I do not know. Common use-cases would then look like this: struct MyRange( Range )

Re: D vs C++

2010-12-26 Thread spir
On Sun, 26 Dec 2010 00:45:42 -0500 bearophile wrote: > You need to add some shades of grey to your palette. break, continue and goto > are bad, and it's better to limit their usage. You need to soften your rocks of certitudes, Bearophile. cycle (action0) if condi

Re: tail const

2010-12-26 Thread Simen kjaeraas
Simen kjaeraas wrote: Simen kjaeraas wrote: I've also considered a template on the form mixin tailConst!( SimpleRange, SimpleRange!( Tail!T ) ); or mixin tailConst!( SimpleRange, Tail!T ); A closer look at this reveals that it won't work that simply, because SimpleRange in this

Re: D vs C++

2010-12-26 Thread Walter Bright
Daniel Gibson wrote: I don't think so. They're much more clean and readable than goto (they just restart/jump behind the current loop or, if you use them with labels, an outer loop - IMHO that's quite different from jumping to arbitrary labels). I guess this is the reason why break and continue

Re: D vs C++

2010-12-26 Thread Walter Bright
foobar wrote: Isn't this subjective and depends on what you compare with and also depends on use cases? I think we should be careful about deciding what constructs are "bug prone" and which aren't. My attitudes on it are based on being a programmer for 35 years - my own experience with bugs,

Re: D vs C++

2010-12-26 Thread bearophile
foobar: > Structured programming is considered a huge improvement over gotos and > spaghetti code and I thought that OO is considered better than Structured > programming. Unfortunately both biological evolution and software evolution are not a March of Progress :-) So OOP doesn't automaticall

Re: D vs C++

2010-12-26 Thread foobar
Don Wrote: > bearophile wrote: > > Walter Bright: > > > >> I thought the idea that break and continue were bad died about 25 years > >> ago. > >> Pascal didn't allow them, and pretty much everyone hated the workaround of > >> having to use flag variables. > > > > You need to add some shades o