Re: Making generalized Trie type in D

2012-07-19 Thread Marco Leise
Am Mon, 04 Jun 2012 23:18:31 +0400 schrieb Dmitry Olshansky dmitry.o...@gmail.com: Compiler is like a nasty stepchild it will give up on generating good old jump tables given any reason it finds justifiable. (but it may use few small jump tables + binary search, could be fine... if not in

Re: Making generalized Trie type in D

2012-06-24 Thread Roman D. Boiko
On Monday, 11 June 2012 at 18:42:14 UTC, Dmitry Olshansky wrote: 0 ^ 0 = 1 while T.init P^ T.init == T.init :) other are almot the same but 1 ^ 1 = 0 while x P^ y == y So it's not symmetric when x,y != T.init for starters ;) Just a remark that DCT no longer needs tries to be immutable, since

Re: Making generalized Trie type in D

2012-06-24 Thread Dmitry Olshansky
On 24-Jun-12 14:50, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:42:14 UTC, Dmitry Olshansky wrote: 0 ^ 0 = 1 while T.init P^ T.init == T.init :) other are almot the same but 1 ^ 1 = 0 while x P^ y == y So it's not symmetric when x,y != T.init for starters ;) Just a remark that DCT no

Re: Making generalized Trie type in D

2012-06-11 Thread Roman D. Boiko
On Tuesday, 5 June 2012 at 13:27:12 UTC, Roman D. Boiko wrote: maybe it is better to avoid immutability... or do bulk ins /del before copy. Would it be difficult to introduce two optimizations: * have strings of all lengths above configurable threshold go to the same bucket (is it

Re: Making generalized Trie type in D

2012-06-11 Thread Dmitry Olshansky
On 11.06.2012 16:11, Roman D. Boiko wrote: On Tuesday, 5 June 2012 at 13:27:12 UTC, Roman D. Boiko wrote: maybe it is better to avoid immutability... or do bulk ins /del before copy. Would it be difficult to introduce two optimizations: * have strings of all lengths above configurable

Re: Making generalized Trie type in D

2012-06-11 Thread Roman D. Boiko
On Monday, 11 June 2012 at 14:48:27 UTC, Dmitry Olshansky wrote: On 11.06.2012 16:11, Roman D. Boiko wrote: On Tuesday, 5 June 2012 at 13:27:12 UTC, Roman D. Boiko wrote: maybe it is better to avoid immutability... or do bulk ins /del before copy. Would it be difficult to introduce two

Re: Making generalized Trie type in D

2012-06-11 Thread Dmitry Olshansky
On 11.06.2012 20:43, Roman D. Boiko wrote: [snip] Actually, in my case, deletions could be deferred and performed in bulk. OTOH, I will need to count how many times a string is inserted minus number of times it has been deleted. Alternatively, I could just check from time to time which strings

Re: Making generalized Trie type in D

2012-06-11 Thread Roman D. Boiko
On Monday, 11 June 2012 at 18:16:45 UTC, Dmitry Olshansky wrote: On 11.06.2012 20:43, Roman D. Boiko wrote: [snip] Actually, in my case, deletions could be deferred and performed in bulk. OTOH, I will need to count how many times a string is inserted minus number of times it has been

Re: Making generalized Trie type in D

2012-06-11 Thread Roman D. Boiko
On Monday, 11 June 2012 at 18:27:58 UTC, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:23:39 UTC, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:16:45 UTC, Dmitry Olshansky wrote: I meant an operation pseudo-XOR x P^ y where x is part of snapshot and y is part of diff page. x P^ y

Re: Making generalized Trie type in D

2012-06-11 Thread Roman D. Boiko
On Monday, 11 June 2012 at 18:23:39 UTC, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:16:45 UTC, Dmitry Olshansky wrote: I meant an operation pseudo-XOR x P^ y where x is part of snapshot and y is part of diff page. x P^ y == x when y == T.init x P^ y == y when y != T.init I

Re: Making generalized Trie type in D

2012-06-11 Thread Dmitry Olshansky
On 11.06.2012 22:30, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:27:58 UTC, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:23:39 UTC, Roman D. Boiko wrote: On Monday, 11 June 2012 at 18:16:45 UTC, Dmitry Olshansky wrote: I meant an operation pseudo-XOR x P^ y where x is part of

Re: Making generalized Trie type in D

2012-06-05 Thread Dmitry Olshansky
On 05.06.2012 9:33, Roman D. Boiko wrote: On Tuesday, 5 June 2012 at 05:28:48 UTC, Roman D. Boiko wrote: ... without deep analysis I can't come up with a good API / design for that (without overcomplicating it). Probably keeping mutable and immutable APIs separate is the best choice. Will

Re: Making generalized Trie type in D

2012-06-05 Thread Roman D. Boiko
On Tuesday, 5 June 2012 at 12:57:10 UTC, Dmitry Olshansky wrote: On 05.06.2012 9:33, Roman D. Boiko wrote: On Tuesday, 5 June 2012 at 05:28:48 UTC, Roman D. Boiko wrote: ... without deep analysis I can't come up with a good API / design for that (without overcomplicating it). Probably keeping

Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
Cross-posting from my GSOC list as I think we had a lack of D rox posts lately :) I rarely am surprised by generic code flexibility and power these days. But once I fleshed out last bits of generalized Trie I was amazed. In short: it allows something like make a multistage integer lookup

Re: Making generalized Trie type in D

2012-06-04 Thread Denis Shelomovskij
04.06.2012 13:46, Dmitry Olshansky написал: enum keywords = [ abstract, alias, align, //... all of them, except @ ones __traits ]; A nitpick: constant arrays should be defined as `immutable` instead of `enum`. `enum` means

Re: Making generalized Trie type in D

2012-06-04 Thread Andrei Alexandrescu
On 6/4/12 4:46 AM, Dmitry Olshansky wrote: Cross-posting from my GSOC list as I think we had a lack of D rox posts lately :) [snip] I think it would be great if you converted this post into an article. Andrei

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 04.06.2012 18:19, Andrei Alexandrescu wrote: On 6/4/12 4:46 AM, Dmitry Olshansky wrote: Cross-posting from my GSOC list as I think we had a lack of D rox posts lately :) [snip] I think it would be great if you converted this post into an article. Andrei Sounds good, will do once I fix

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 04.06.2012 16:15, Denis Shelomovskij wrote: 04.06.2012 13:46, Dmitry Olshansky написал: enum keywords = [ abstract, alias, align, //... all of them, except @ ones __traits ]; A nitpick: constant arrays should be defined as `immutable` instead of `enum`. `enum` means every time `keywords`

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 15:35:31 UTC, Dmitry Olshansky wrote: On 04.06.2012 18:19, Andrei Alexandrescu wrote: On 6/4/12 4:46 AM, Dmitry Olshansky wrote: Cross-posting from my GSOC list as I think we had a lack of D rox posts lately :) [snip] I think it would be great if you converted this

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 12:15:33 UTC, Denis Shelomovskij wrote: 04.06.2012 13:46, Dmitry Olshansky написал: enum keywords = [ abstract, alias, align, //... all of them, except @ ones __traits ]; A nitpick: constant arrays

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 04.06.2012 22:42, Roman D. Boiko wrote: On Monday, 4 June 2012 at 15:35:31 UTC, Dmitry Olshansky wrote: On 04.06.2012 18:19, Andrei Alexandrescu wrote: On 6/4/12 4:46 AM, Dmitry Olshansky wrote: Cross-posting from my GSOC list as I think we had a lack of D rox posts lately :) [snip] I

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 19:18:32 UTC, Dmitry Olshansky wrote: On 04.06.2012 22:42, Roman D. Boiko wrote: ... it is possible to create persistent (immutable) tries with efficient (log N) inserting / deleting (this scenario is very important for my DCT project). Immutable hash tables would

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
[snip] Aye, the good thing about them - the amount of data affected by any change is localized to one page. So you just copy it over and remap indices/pointers. Actually, Microsoft went this way (immutable hash tables) in their Roslyn preview implementation. However, I still believe that tries

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 20:40:03 UTC, Dmitry Olshansky wrote: [snip] Sorry my Trie implementation focused on constructe once - read everywhere case. My cases will likely have quite low amortized number of reads per insert / delete. How do you handle situations when not existent, etc., is

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 21:07:02 UTC, Roman D. Boiko wrote: For example, one by one would allow ignoring key encoding (and thus using multiple encodings simultaneously just as easily as single). It's just as easy with the whole thing. Treat it as bytes ;) Except when equivalent keys in

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 05.06.2012 1:16, Roman D. Boiko wrote: On Monday, 4 June 2012 at 21:07:02 UTC, Roman D. Boiko wrote: For example, one by one would allow ignoring key encoding (and thus using multiple encodings simultaneously just as easily as single). It's just as easy with the whole thing. Treat it as

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 21:39:50 UTC, Dmitry Olshansky wrote: And before you run away with that horrible idea of ever decoding UTF in lexer... Just don't do that. Trust me, it's not as small a price as it seems at first. At least keep it only at prototype stage as it simplifies things. I

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 21:39:50 UTC, Dmitry Olshansky wrote: On 05.06.2012 1:16, Roman D. Boiko wrote: I believe that once encoidng is established your compiler tool should use the best code for that encoding. And that means templates, tailored per encoding in my book. If anything I plan

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 05.06.2012 1:56, Roman D. Boiko wrote: On Monday, 4 June 2012 at 21:39:50 UTC, Dmitry Olshansky wrote: On 05.06.2012 1:16, Roman D. Boiko wrote: I believe that once encoidng is established your compiler tool should use the best code for that encoding. And that means templates, tailored per

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 05.06.2012 2:06, Dmitry Olshansky wrote: On 05.06.2012 1:56, Roman D. Boiko wrote: On Monday, 4 June 2012 at 21:39:50 UTC, Dmitry Olshansky wrote: On 05.06.2012 1:16, Roman D. Boiko wrote: I believe that once encoidng is established your compiler tool should use the best code for that

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 22:06:49 UTC, Dmitry Olshansky wrote: On 05.06.2012 1:56, Roman D. Boiko wrote: Will it be difficult to adapt your API for immutable tries? E.g., it is not possible to implement immutable sequence (linked list) as a range, Linked list? I'm horrified. Though I'd need

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 22:21:42 UTC, Dmitry Olshansky wrote: And you can fake immutability, buy always picking up an unused slot btw. No need to go beyond logical immutability. That's applicable in some cases, not in general. But I agree that often it is possible to optimize if use cases are

Re: Making generalized Trie type in D

2012-06-04 Thread Dmitry Olshansky
On 05.06.2012 2:28, Roman D. Boiko wrote: On Monday, 4 June 2012 at 22:21:42 UTC, Dmitry Olshansky wrote: And you can fake immutability, buy always picking up an unused slot btw. No need to go beyond logical immutability. That's applicable in some cases, not in general. But I agree that often

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Tuesday, 5 June 2012 at 04:42:07 UTC, Dmitry Olshansky wrote: On 05.06.2012 2:28, Roman D. Boiko wrote: My example concern was about fundamental problem of range APIs for immutable data structures, which is not possible to emulate: popFront is mutating by design. Keep in mind Ranges are

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Monday, 4 June 2012 at 22:22:34 UTC, Roman D. Boiko wrote: On Monday, 4 June 2012 at 22:06:49 UTC, Dmitry Olshansky wrote: On 05.06.2012 1:56, Roman D. Boiko wrote: so range API doesn't fit that (but could with a tweak - returning tail instead of mutating in popFront). If trie API will

Re: Making generalized Trie type in D

2012-06-04 Thread Roman D. Boiko
On Tuesday, 5 June 2012 at 05:28:48 UTC, Roman D. Boiko wrote: ... without deep analysis I can't come up with a good API / design for that (without overcomplicating it). Probably keeping mutable and immutable APIs separate is the best choice. Will return to this problem once I get a bit of