Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Ary Borenszweig via Digitalmars-d-learn
On 5/4/14, 6:04 PM, Mark Isaacson wrote: I'm looking for a means to associate a key with a value and iterate over said container in-order. My natural choice in C++ would be std::map. When I look in std.container, I see that there is a RedBlackTree implementation, however this does not associate

Re: Templating everything? One module per function/struct/class/etc, grouped by package?

2014-05-12 Thread Ary Borenszweig via Digitalmars-d-learn
On 5/12/14, 5:37 AM, JR wrote: Given that... 1. importing a module makes it compile the entirety of it, as well as whatever it may be importing in turn 2. templates are only compiled if instantiated 3. the new package.d functionality ...is there a reason *not* to make every single function/stru

Re: RegEx for a simple Lexer

2014-05-13 Thread Ary Borenszweig via Digitalmars-d-learn
On 5/13/14, 5:43 PM, anonymous wrote: On Tuesday, 13 May 2014 at 19:53:17 UTC, Tim Holzschuh via Digitalmars-d-learn wrote: If I also want to create a RegEx to filter string-expressions a la " xyz ", how would I do this? At least match( src, r"^\" (.*) $\" " ); doesn't seem to work and I couldn

Re: Array!T and find are slow

2014-05-15 Thread Ary Borenszweig via Digitalmars-d-learn
On 5/15/14, 1:31 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Thu, 15 May 2014 01:29:23 + Kapps via Digitalmars-d-learn wrote: On Wednesday, 14 May 2014 at 23:50:34 UTC, Meta wrote: On the topic of lazy, why *is* it so slow, exactly? I thought it was just shorthand for taking a

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread Ary Borenszweig via Digitalmars-d-learn
On 6/23/14, 6:18 PM, John Carter wrote: I guess between perl and Ruby and Scheme etc. I got used to creating hybrid containers Want a pair of [string, fileList]? Just make an Array with two items, one a string, one and array of strings. Done. D barfed... leaving me momentarily stunned... th

Re: Another rambling musing by a Dynamic Programmer - map!

2014-06-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 6/24/14, 4:13 PM, Jacob Carlborg wrote: On 2014-06-24 04:34, John Carter wrote: So in Ruby and R and Scheme and... I have happily used map / collect for years and years. Lovely thing. So I did the dumb obvious of string[] stringList = map!...; And D barfed, wrong type, some evil volde

Can't modify this

2014-06-28 Thread Ary Borenszweig via Digitalmars-d-learn
This doesn't work: class Foo { this() { this = new Foo; } } Error: Cannot modify 'this' However you can do this: class Foo { this() { auto p = &this; *p = new Foo(); } } It even changes the value of this! Should that compile? I mean, it's the same as modifying 'this'...

Re: Can't modify this

2014-06-28 Thread Ary Borenszweig via Digitalmars-d-learn
On 6/28/14, 6:21 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Sat, Jun 28, 2014 at 05:40:19PM -0300, Ary Borenszweig via Digitalmars-d-learn wrote: This doesn't work: class Foo { this() { this = new Foo; } } Error: Cannot modify 'this' However you can do t

Re: get number of items in DList

2014-07-11 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/11/14, 4:46 AM, bearophile wrote: pgtkda: How can i get the number of items which are currently hold in a DList? Try (walkLength is from std.range): mydList[].walkLength Bye, bearophile So the doubly linked list doesn't know it's length? That seems a bit inefficient...

Re: md5 hashing acting strangly?

2014-07-16 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/16/14, 10:22 AM, bearophile wrote: Kagamin: Report for the problem when a temporary fixed-size array is assigned to a slice, which is escaped. I think this is already in Bugzilla. But the point is: you can't solve this problem locally and with small means. You need a principled solution

Re: D JSON (WAT?!)

2014-07-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/24/14, 1:09 PM, Justin Whear wrote: On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: Thanks to all you folks who explained "in" operator for me. My bad. Let's focus on the real problem, which is JSON wrapper class. Is it needed? Wouldn't it be better to get AA from parseJSON? The followi

Re: D JSON (WAT?!)

2014-07-24 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/24/14, 1:58 PM, Justin Whear wrote: On Thu, 24 Jul 2014 13:49:27 -0300, Ary Borenszweig wrote: Nope, a JSON can only be an array or an object (hash). Ary, can you point out the place in the spec where this is specified? Not to be pedantic, but the spec only seems to define a "JSON value"

Re: D JSON (WAT?!)

2014-07-25 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/25/14, 1:06 PM, Justin Whear wrote: On Thu, 24 Jul 2014 22:00:43 +, Pavel wrote: On Thursday, 24 July 2014 at 16:09:25 UTC, Justin Whear wrote: On Thu, 24 Jul 2014 16:04:01 +, Pavel wrote: Thanks to all you folks who explained "in" operator for me. My bad. Let's focus on the rea

Re: myrange.at(i) for myrange.dropExactly(i).front

2014-07-25 Thread Ary Borenszweig via Digitalmars-d-learn
On 7/25/14, 6:39 PM, Jonathan M Davis wrote: On Friday, 25 July 2014 at 21:33:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: Is there a function for doing this? myrange.at(i) (with meaning of myrange.dropExactly(i).front) it's a common enough operation (analog to myrange[i]; the naming is

Re: Associative value order

2014-08-06 Thread Ary Borenszweig via Digitalmars-d-learn
On 8/6/14, 2:59 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Aug 06, 2014 at 05:54:23PM +, Patrick via Digitalmars-d-learn wrote: I know that there is no prescribed order that the .values array will be sorted in, however I'm curious if the order is deterministic based on keys. If I

Re: implicit conversion

2014-08-12 Thread Ary Borenszweig via Digitalmars-d-learn
On 8/12/14, 6:31 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Aug 12, 2014 at 08:23:30PM +, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, 12 August 2014 at 19:03:58 UTC, H. S. Teoh via Digitalmars-d-learn wrote: tl;dr: there are so many ways template code can go wron

Re: Auto-add static field when inherit // mixins, templates?

2014-08-21 Thread Ary Borenszweig via Digitalmars-d-learn
On 8/21/14, 6:38 AM, MarisaLovesUsAll wrote: tl;dr - how to get child classname from inherited parent function at compile time? class A { string getName(); }; class B { }; B foo = new B; assert(foo.getName() == "B"); ... Hi! I'm stuck at one issue, and I don't know how to solve it. I think this

Re: DMD Compiler - lexer

2014-08-29 Thread Ary Borenszweig via Digitalmars-d-learn
On 8/29/14, 10:41 AM, Mike James wrote: Hi, Looking at the DMD Source Guide it says "The lexer transforms the file into an array of tokens." Why is this step taken instead of, say, just calling a function that returns the next token (or however many required for the look-ahead)? Regards, -=

Re: Allowing Expressions such as (low < value < high)

2014-09-04 Thread Ary Borenszweig via Digitalmars-d-learn
On 9/4/14, 5:03 PM, "Nordlöw" wrote: Are there any programming languages that extend the behaviour of comparison operators to allow expressions such as if (low < value < high) ? This syntax is currently disallowed by DMD. I'm aware of the risk of a programmer misinterpreting this as

Re: Allowing Expressions such as (low < value < high)

2014-09-04 Thread Ary Borenszweig via Digitalmars-d-learn
On 9/4/14, 7:03 PM, "Nordlöw" wrote: On Thursday, 4 September 2014 at 22:02:20 UTC, Nordlöw wrote: D can also, in this case, do (or will do) common sub-expression elimination because it has a strict memory model (const and immutability) and function purity (template inference). Correction: foo

Re: write multiple lines without "\n" with writeln

2014-11-20 Thread Ary Borenszweig via Digitalmars-d-learn
On 11/20/14, 9:05 AM, uri wrote: On Thursday, 20 November 2014 at 10:41:24 UTC, bearophile wrote: uri: It's by design And it's a nice handy design. Bye, bearophile For Wysiwyg strings I agree that it's great but I prefer C/C++/Python like behaviour for double quoted strings. I guess it's

Re: write multiple lines without "\n" with writeln

2014-11-21 Thread Ary Borenszweig via Digitalmars-d-learn
On 11/21/14, 1:59 PM, "Marc Schütz" " wrote: On Friday, 21 November 2014 at 15:00:31 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 20 Nov 2014 14:23:23 -0300 Ary Borenszweig via Digitalmars-d-learn wrote: This way you avoid silly typing mistakes while at the same

Re: write multiple lines without "\n" with writeln

2014-11-21 Thread Ary Borenszweig via Digitalmars-d-learn
On 11/21/14, 2:46 PM, Adam D. Ruppe wrote: On Friday, 21 November 2014 at 17:43:27 UTC, Ary Borenszweig wrote: What's concatenation by juxtaposition? When "foo" "bar" turns into "foobar". The two string literals are right next to each other, no operator or anything else in between, so they are

Re: Why the DMD Backend?

2014-11-29 Thread Ary Borenszweig via Digitalmars-d-learn
On 11/29/14, 3:48 PM, ketmar via Digitalmars-d-learn wrote: On Sat, 29 Nov 2014 15:37:32 + Joakim via Digitalmars-d-learn wrote: build time for the whole DMD compiler with standard library, using G++: 100 seconds. yea, no kidding. gdc: i don't even want to think about that, way t long

Re: Class inside a Struct?

2015-01-30 Thread Ary Borenszweig via Digitalmars-d-learn
On 1/30/15 5:28 PM, Ali Çehreli wrote: On 01/30/2015 11:59 AM, chardetm wrote: > struct Container { > > private RedBlackTree!int _rbtree = new RedBlackTree!int; I think you are expecting the new expression to be be executed for every object individually. It is not the case: That new exp

Re: Class inside a Struct?

2015-01-30 Thread Ary Borenszweig via Digitalmars-d-learn
On 1/30/15 7:29 PM, Ali Çehreli wrote: On 01/30/2015 01:28 PM, Ary Borenszweig wrote: > On 1/30/15 5:28 PM, Ali Çehreli wrote: >> On 01/30/2015 11:59 AM, chardetm wrote: >> >> > struct Container { >> > >> > private RedBlackTree!int _rbtree = new RedBlackTree!int; >> >> I think yo