Re: read-only access

2010-11-02 Thread Jonathan M Davis
On Tuesday 02 November 2010 15:02:04 Jesse Phillips wrote: > Steven Schveighoffer Wrote: > > It does not say that functions should be callable without parentheses, > > because that mis-feature is deprecated. Essentially, to someone who is > > new to D, there is no need to mention the historical fe

Re: How would I optimize this parser?

2010-11-02 Thread bearophile
T.D.Spense: > public TagNode(String name){ > this.name = name; > this.children = new ArrayList(1); > } > > public TagNode(String name, Node... children){ > this.children = Arrays.asList(children); > for (Node child : children) { > child.pare

Re: problems playing audio with mciSendString

2010-11-02 Thread Tyro[a.c.edwards]
Thanks, The problem was that mciSendString was immediately returning control to the caller after being called. This simple change fixed the problem: mciSendString("play myFile wait");

Re: How would I optimize this parser?

2010-11-02 Thread T.D.Spenser
I'll reply to several posts at once. The code comments you quoted weren't meant as a criticism. They are mostly notes to myself in case I want to document my learning experience with D on some personal website no one ever visits. I'll post criticisms separately if/when I have any. :) When I was s

Re: read-only access

2010-11-02 Thread Jonathan M Davis
On Tuesday, November 02, 2010 14:14:22 spir wrote: > On Tue, 2 Nov 2010 12:47:21 -0700 > > Jonathan M Davis wrote: > > If they don't have the property attribute, then they won't work without > > parens (and in fact, you won't be able to use parens with them). That is > > how it's outlined in TPDL

Re: read-only access

2010-11-02 Thread Jesse Phillips
Steven Schveighoffer Wrote: > It does not say that functions should be callable without parentheses, > because that mis-feature is deprecated. Essentially, to someone who is > new to D, there is no need to mention the historical features of D. It > does say that you need to put @property o

Re: subclassing

2010-11-02 Thread Jesse Phillips
spir Wrote: > On Tue, 02 Nov 2010 12:33:16 -0400 > Jesse Phillips wrote: > > > spir Wrote: > > > > > > > * Why does D allow me redefining (data) slots in the subclass OddSquares, > > > which exist in the superclass? (I did this first without noting, by copy > > > & paste ;-) > > > > This is

Re: exceptions thrown by new / object constructor ?

2010-11-02 Thread Michal Minich
On Tue, 02 Nov 2010 15:58:51 +0100, Don wrote: > Jesse Phillips wrote: >> I thought there was a Bug report on this, but I guess not. I say report >> it. Ether it should compile or the compiler should error that a >> constructor can not be nothrow. > > This has already been fixed in svn, and will

Re: read-only access

2010-11-02 Thread spir
On Tue, 2 Nov 2010 12:47:21 -0700 Jonathan M Davis wrote: > If they don't have the property attribute, then they won't work without > parens > (and in fact, you won't be able to use parens with them). That is how it's > outlined in TPDL (The D Programming Language by Andrei Alexandrescu). > H

Re: read-only access

2010-11-02 Thread Steven Schveighoffer
On Tue, 02 Nov 2010 16:52:38 -0400, Jesse Phillips wrote: Steven Schveighoffer Wrote: On Tue, 02 Nov 2010 15:54:13 -0400, Jesse Phillips wrote: > Calling functions without () is a legacy feature left over which is how > D use to do properties. Some will say this is going to be removed,

Re: subclassing

2010-11-02 Thread Steven Schveighoffer
On Tue, 02 Nov 2010 16:35:39 -0400, spir wrote: On Tue, 02 Nov 2010 12:33:16 -0400 Jesse Phillips wrote: spir Wrote: > * Why does D allow me redefining (data) slots in the subclass OddSquares, which exist in the superclass? (I did this first without noting, by copy & paste ;-) This i

Re: read-only access

2010-11-02 Thread Jesse Phillips
Steven Schveighoffer Wrote: > On Tue, 02 Nov 2010 15:54:13 -0400, Jesse Phillips > wrote: > > > Calling functions without () is a legacy feature left over which is how > > D use to do properties. Some will say this is going to be removed, but > > do not recall this ever being said (only th

Re: subclassing

2010-11-02 Thread spir
On Tue, 02 Nov 2010 12:33:16 -0400 Jesse Phillips wrote: > spir Wrote: > > > > * Why does D allow me redefining (data) slots in the subclass OddSquares, > > which exist in the superclass? (I did this first without noting, by copy & > > paste ;-) > > This is either a bug or so that you don't

Re: read-only access

2010-11-02 Thread Steven Schveighoffer
On Tue, 02 Nov 2010 15:54:13 -0400, Jesse Phillips wrote: Calling functions without () is a legacy feature left over which is how D use to do properties. Some will say this is going to be removed, but do not recall this ever being said (only that it was implied it would happen if propert

Re: subclassing

2010-11-02 Thread Jesse Phillips
Jonathan M Davis Wrote: > I should point out that you forgot the save property, which is required for > forward ranges (though not input ranges). Without it, any algorithm which > processes the range will consume it. Trying to ease this guy into ranges. I did notice though, the InputRange int

Re: read-only access

2010-11-02 Thread Jesse Phillips
spir Wrote: > Hello, > > Is the D way to make read-only symbols (of a class, struct, module) to write > a getter for a private symbols? Yes, though it isn't like the getValue() from java. @property int i() {return this.my_i;} > Additional question: just realised one can omit () on func calls

Re: read-only access

2010-11-02 Thread Jonathan M Davis
On Tuesday 02 November 2010 12:33:41 spir wrote: > Hello, > > Is the D way to make read-only symbols (of a class, struct, module) to > write a getter for a private symbols? > > Additional question: just realised one can omit () on func calls! Is this > systematic when a func has no param? I thoug

read-only access

2010-11-02 Thread spir
Hello, Is the D way to make read-only symbols (of a class, struct, module) to write a getter for a private symbols? Additional question: just realised one can omit () on func calls! Is this systematic when a func has no param? I thought it was not the case, because it does not work with writel

Another shared bug?

2010-11-02 Thread Johannes Pfau
I did some experiments using shared and I came across this problem: - struct Test { void test() {} shared void test2() { (cast(Test)this).test(); } void opCall() {} } void main() { shared

Re: subclassing

2010-11-02 Thread Jonathan M Davis
On Tuesday, November 02, 2010 09:33:16 Jesse Phillips wrote: > spir Wrote: > > * Why does D allow me redefining (data) slots in the subclass OddSquares, > > which exist in the superclass? (I did this first without noting, by copy > > & paste ;-) > > This is either a bug or so that you don't have n

Re: couple of really noob questions (ranges, toString)

2010-11-02 Thread Jonathan M Davis
On Tuesday, November 02, 2010 04:16:58 spir wrote: > On Mon, 1 Nov 2010 20:40:30 -0700 > > Jonathan M Davis wrote: > > The term "pop" does _not_ mean that an element is returned but that it is > > removed from the range. This is true for pretty much anything that uses a > > pop function in any la

Re: subclassing

2010-11-02 Thread Jesse Phillips
spir Wrote: > * Why does D allow me redefining (data) slots in the subclass OddSquares, > which exist in the superclass? (I did this first without noting, by copy & > paste ;-) This is either a bug or so that you don't have name clashes with all the super classes (could really reduce the avai

Re: subclassing

2010-11-02 Thread spir
On Tue, 02 Nov 2010 10:39:27 -0400 Jesse Phillips wrote: > I'll come back with a more complete answer latter, but first. > > spir Wrote: > > > * I wrote Range as class, but I rather meant an interface. D does not let > > me do that, apparently because there is no data slot in a D interface. Is

Re: exceptions thrown by new / object constructor ?

2010-11-02 Thread Don
Jesse Phillips wrote: I thought there was a Bug report on this, but I guess not. I say report it. Ether it should compile or the compiler should error that a constructor can not be nothrow. This has already been fixed in svn, and will be in the next release. See bug 3020. nothrow is painful

Re: subclassing

2010-11-02 Thread Jesse Phillips
I'll come back with a more complete answer latter, but first. spir Wrote: > * I wrote Range as class, but I rather meant an interface. D does not let me > do that, apparently because there is no data slot in a D interface. Is then > an interface a kind of data-less superclass? Or is there somet

subclassing

2010-11-02 Thread spir
Hello, After the exchanges on ranges, I am experimenting around this notion as a way to learn about D classes, subclassing, generics, etc... In the code below, there are three obscure points for me: * I wrote Range as class, but I rather meant an interface. D does not let me do that, apparentl

Re: exception types & objects

2010-11-02 Thread Steven Schveighoffer
On Sun, 31 Oct 2010 02:51:53 -0400, Don wrote: nothrow actually prevents you from throwing anything. A nothrow function may still perform operations which may throw a compiler-generated Error. (eg, AssertError, OutOfMemoryError). It's only a spec change which is required. I think you meant

Re: 2-dimensional array confusion

2010-11-02 Thread Steven Schveighoffer
On Mon, 01 Nov 2010 03:50:12 -0400, Andreas Kaempf wrote: Hey folks! Please enlight me with that prefix notation of 2-dimensional arrays! I prepared a snippet giving me headaches: auto int[2][3] test = [[11,12],[21,22],[31,32]]; foreach (x, row; test) { Stdout.format("x={}: ", x+1);

Re: higher-order functions

2010-11-02 Thread Steven Schveighoffer
On Sun, 31 Oct 2010 19:20:04 -0400, bearophile wrote: Simen kjaeraas: They take both, in fact: auto cubes = map!((a){ return a*a*a; })(arr); But that needs to be compile-time constant, so if you have several functions, you need to put them inside a typetuple, or duplicate the code. A

Re: readf

2010-11-02 Thread bearophile
Nick Voronin: > On yet another topic :) Is there alternative to stream.readf? Somehow while > searching for explanation of unexpected behavior I got the idea that readf > and streams considered to be second-class citizens in world of D and they are > not a proper way to do things, so no one rea

Re: couple of really noob questions (ranges, toString)

2010-11-02 Thread spir
On Mon, 1 Nov 2010 20:40:30 -0700 Jonathan M Davis wrote: > The term "pop" does _not_ mean that an element is returned but that it is > removed from the range. This is true for pretty much anything that uses a pop > function in any language - stacks, lists, etc. It _is_ true that many > implem

readf

2010-11-02 Thread Nick Voronin
Hello. I'm new to D and I stumbled upon something strange about readf while writing some test code. The code: import std.stream; import std.stdio; int main(char[][] args) { string input = "2abc"; auto memstream = new TArrayStream!(string)(input); int x; memstrea

problems playing audio with mciSendString

2010-11-02 Thread Tyro[a.c.edwards]
Hello all, I would really appreciate some assistance on this. The intent is to create a vocabulary/flashcard program with proper pronunciations. Pronunciations are saved as individual mp3 files which I want to play whenever a new term is displayed. My current attempt is simply to get the the file