Re: Ambiguous mangling of symbols declared in nested scopes

2014-07-16 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 16 July 2014 at 17:24:27 UTC, H. S. Teoh via Digitalmars-d wrote: Today I was investigating this bug: https://issues.dlang.org/show_bug.cgi?id=10619 and found that the problem appears to be an ambiguous mangling of local variables declared in nested scopes. ... Amazing how

Won a programming contest using D - Thank you for the tool!

2014-08-17 Thread Ivan Kazmenko via Digitalmars-d
Hi, I just won a three-month-long programming contest (Al Zimmermann's Programming Contest - Alphabet City) using the D programming language as my main tool. I want to share my happiness, and express my deep gratitude, to the people who work on this tool. You are a part of what made this a

Re: Won a programming contest using D - Thank you for the tool!

2014-08-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 August 2014 at 07:10:02 UTC, bearophile wrote: Ivan Kazmenko: My contest program, now on GitHub: https://github.com/GassaFM/alphabet-city/ dmd bug: wrong file and line for array bounds check Did you report the bugs? Yeah, that one got reduced to

Re: Won a programming contest using D - Thank you for the tool!

2014-08-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 August 2014 at 07:44:14 UTC, Joakim wrote: A technical report draft: http://acm.math.spbu.ru/~gassa/az/alphabet-city/technical-report.html It would be good if you could expand on your thoughts on D from part 11 of your technical report and post it somewhere, so that others can

Re: Won a programming contest using D - Thank you for the tool!

2014-08-19 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 August 2014 at 07:44:14 UTC, Joakim wrote: Nice, though I don't know how fair it is to have a university professor take part in such a contest. ;) The contest is open for everyone. For example, Tomas Rokicki (one of the previous contests' winners) is a member of the God's

Re: Won a programming contest using D - Thank you for the tool!

2014-08-19 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 August 2014 at 18:04:50 UTC, Ali Çehreli wrote: On 08/18/2014 03:11 AM, Ivan Kazmenko wrote: my program usually hit an out-of-memory error very soon. It worked fine when compiled with 64-bit DMD but failed to collect the garbage in time with 32-bit DMD and with recent LDC.

Re: problem with size_t and an easy solution

2014-12-08 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 8 December 2014 at 08:46:49 UTC, bearophile wrote: Freddy: Why not keep size_t implictly convertable but disallow it for usize. This is an interesting idea. (But the name uword seems better). The char, wchar (word char) and dchar (double word char) types seem to disagree. The

Re: problem with size_t and an easy solution

2014-12-08 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 8 December 2014 at 14:31:50 UTC, ketmar via Digitalmars-d wrote: On Mon, 08 Dec 2014 13:49:30 + Ivan Kazmenko via Digitalmars-d digitalmars-d@puremagic.com wrote: Personally, when I face the need for a size_t, I usually can (and do) use auto instead. And even if I have to spell

Re: problem with size_t and an easy solution

2014-12-09 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 9 December 2014 at 03:14:23 UTC, ketmar via Digitalmars-d wrote: somehow Walter can't accept that after emiting the first error compiler is in undefined state, and trying to pretend that it is in well-defined state or guess what well-defined state must be is a nonsense. A

Re: problem with size_t and an easy solution

2014-12-10 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 10 December 2014 at 02:15:04 UTC, ketmar via Digitalmars-d wrote: On Tue, 09 Dec 2014 17:28:15 + Ivan Kazmenko via Digitalmars-d digitalmars-d@puremagic.com wrote: A well-designed language allows to recover from errors with good probability if compiler can recover from

Re: problem with size_t and an easy solution

2014-12-10 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 10 December 2014 at 10:59:17 UTC, ketmar via Digitalmars-d wrote: that is absolutely nonsense, you *CAN'T* recover from invalid code. that is the fact. fact: Earth is not a sphere. fact: you can't automatically recover from invalid code. That sounds much like an opinion, a

Re: readln() doesn't stop to read the input.

2015-03-27 Thread Ivan Kazmenko via Digitalmars-d
On Friday, 27 March 2015 at 04:37:34 UTC, jonaspm wrote: Please, i need your help, I tried this: write(Write p: ); readln(p); p = chomp(p); writeln(Write q: ); readln(q); q = chomp(q); but the result is: Write p: Write q: and doesn't pause to read keyboard input... what's wrong? Thanks in

Re: Quit running foreign unittests _

2015-04-28 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 28 April 2015 at 16:40:05 UTC, Dicebot wrote: On Monday, 27 April 2015 at 11:30:04 UTC, Steven Schveighoffer wrote: On 4/27/15 6:20 AM, Dicebot wrote: On Monday, 27 April 2015 at 10:15:20 UTC, Kagamin wrote: On Monday, 27 April 2015 at 09:22:48 UTC, Dicebot wrote: Compiling tests

Re: Quit running foreign unittests _

2015-04-27 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 27 April 2015 at 11:30:04 UTC, Steven Schveighoffer wrote: The problem is as follows: 1. Unit tests for some library are written for that library. They are written to run tests during unit tests of that library only (possibly with certain requirements of environment, including

Re: Quit running foreign unittests _

2015-04-27 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 27 April 2015 at 15:29:05 UTC, Steven Schveighoffer wrote: On 4/27/15 10:30 AM, Ivan Kazmenko wrote: On Monday, 27 April 2015 at 11:30:04 UTC, Steven Schveighoffer wrote: The problem is as follows: 1. Unit tests for some library are written for that library. They are written to

Re: Quit running foreign unittests _

2015-04-27 Thread Ivan Kazmenko via Digitalmars-d
To me, the proposed version(PhobosUnitTests) hack looks good for the particular case. But I don't see whether such trick scales well for the whole ecosystem of libraries. Another approach that might work specifically for containers is to pass as an additional template parameter whether the

Re: dmd codegen improvements

2015-08-21 Thread Ivan Kazmenko via Digitalmars-d
On Friday, 21 August 2015 at 01:29:12 UTC, H. S. Teoh wrote: On Fri, Aug 21, 2015 at 01:20:25AM +, jmh530 via Digitalmars-d wrote: On Friday, 21 August 2015 at 00:00:09 UTC, H. S. Teoh wrote: The gdc version, by contrast, inlines *everything*, This could be why I've observed performance

Re: dmd codegen improvements

2015-08-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 18 August 2015 at 23:30:26 UTC, Walter Bright wrote: On 8/18/2015 4:05 PM, H. S. Teoh via Digitalmars-d wrote: Maybe when I get some free time this week, I could look at the disassembly of one of my programs again to give some specific examples. Please do. Sorry to repeat

Re: dmd codegen improvements

2015-08-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 18 August 2015 at 10:45:49 UTC, Walter Bright wrote: ... 3. data flow analysis optimizations like constant propagation, dead code elimination, register allocation, loop invariants, etc. Modern compilers (including dmd) do all three. So if you're comparing code generated by

Re: Today was a good day

2016-01-15 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 13 January 2016 at 03:38:45 UTC, Andrei Alexandrescu wrote: I tried a static rng but found out that pure functions call sort(). Overall I'm not that worried about attacks on sort(). So, sort() is still Introsort (O(n log n) worst case), but topN() can show quadratic performance?

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 January 2016 at 12:00:10 UTC, Ivan Kazmenko wrote: On Sunday, 17 January 2016 at 22:20:30 UTC, Andrei Alexandrescu wrote: All - let me know how things can be further improved. Thx! Here goes the test which shows quadratic behavior for the new version:

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Sunday, 17 January 2016 at 22:20:30 UTC, Andrei Alexandrescu wrote: On 01/17/2016 03:32 PM, Ivan Kazmenko wrote: Here is a more verbose version. OK, very nice. Thanks! I've modified topN to work as follows. In a loop: * If nth <= r.length / log2(r.length)^^2 (or is similarly close to

Re: topN using a heap

2016-01-17 Thread Ivan Kazmenko via Digitalmars-d
On Sunday, 17 January 2016 at 16:06:31 UTC, Andrei Alexandrescu wrote: On 01/17/2016 06:41 AM, Ivan Kazmenko wrote: The average case is O(n + (k log n log k)) for small enough k. So, any k below roughly n / log^2 (n) makes the second summand less than the first. I don't understand how you

Re: topN using a heap

2016-01-16 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 16 January 2016 at 15:25:50 UTC, Andrei Alexandrescu wrote: That's quite a bit of work, so 3934 uses an alternate strategy for finding the smallest 10: 1. Organize the first 11 elements into a max heap 2. Scan all other elements progressively. Whenever an element is found that

Re: topN using a heap

2016-01-16 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 16 January 2016 at 15:25:50 UTC, Andrei Alexandrescu wrote: 3. At the end, swap the largest in the heap with the 10th and you're done! And why this? Do we additionally require the k-th element to arrive exactly on k-th place?

Re: topN using a heap

2016-01-17 Thread Ivan Kazmenko via Digitalmars-d
On Sunday, 17 January 2016 at 03:26:54 UTC, Andrei Alexandrescu wrote: On 1/16/16 9:37 PM, Timon Gehr wrote: Ivan's analysis suggests that even something significantly larger, like n/log(n)² might work as an upper bound for k. I'm not clear on how you got to that boundary. There are a few

Re: topN using a heap

2016-01-17 Thread Ivan Kazmenko via Digitalmars-d
On Sunday, 17 January 2016 at 02:37:48 UTC, Timon Gehr wrote: On 01/17/2016 03:09 AM, Andrei Alexandrescu wrote: On 1/16/16 8:00 PM, Timon Gehr wrote: The implementation falls back to topNHeap whenever k is within the first or last ~n/8 elements and therefore is Ω(n log n) on average.

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 January 2016 at 23:39:02 UTC, Andrei Alexandrescu wrote: On 1/18/16 6:18 PM, Ilya wrote: A RNGs don't improve worst case. It only changes an permutation for worst case. --Ilya Well it does improve things. The probability of hitting the worst case repeatedly is practically zero,

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 January 2016 at 23:18:03 UTC, Ilya wrote: A RNGs don't improve worst case. It only changes an permutation for worst case. --Ilya Still, use of RNG makes it impossible to construct the worst case beforehand, once and for all. In that sense, this is a regression.

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 19 January 2016 at 00:11:40 UTC, Andrei Alexandrescu wrote: 4. sort was and is attackable before all of these changes No, sort utilizes Introsort (Quicksort but switch to Heapsort if recurse too deep): see

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 19 January 2016 at 00:11:40 UTC, Andrei Alexandrescu wrote: 4. sort was and is attackable before all of these changes (b) Improve sort() first, then apply a similar strategy to improving topN. Do not use RNGs at all. Since point 4 is in fact already fixed a good while ago, my

Re: topN using a heap

2016-01-18 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 18 January 2016 at 12:00:10 UTC, Ivan Kazmenko wrote: Here goes the test which shows quadratic behavior for the new version: http://dpaste.dzfl.pl/e4b3bc26c3cf (dpaste kills the slow code before it completes the task) Correction: this is the result of removing a uniform call in

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 6 February 2016 at 00:59:17 UTC, Andrei Alexandrescu wrote: On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such flat structure. Under what circumstances isn't your function

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Saturday, 6 February 2016 at 07:06:27 UTC, Ivan Kazmenko wrote: On Saturday, 6 February 2016 at 00:59:17 UTC, Andrei Alexandrescu wrote: On 02/05/2016 06:36 AM, Ivan Kazmenko wrote: Another interesting task would be to make the function stable, but I don't see how it is possible with such

Re: Idempotent partition around median of 5?

2016-02-05 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 4 February 2016 at 01:24:15 UTC, Andrei Alexandrescu wrote: So there's got to be a better solution. Your challenge - should you choose to accept it :o) - is an algorithm that does the partitioning in 6 comparisons and <= 9 swaps, which is idempotent: when applied twice, it always

Re: The Quick Mom Algorithm

2016-02-02 Thread Ivan Kazmenko via Digitalmars-d
On Friday, 29 January 2016 at 22:47:44 UTC, Andrei Alexandrescu wrote: http://dpaste.dzfl.pl/05a82699acc8 While thinking of MoM and the core reasons of its being slow (adds nice structure to its input and then "forgets" most of it when recursing), I stumbled upon a different algorithm. It's

Re: So... add maxCount and maxPos?

2016-01-20 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 21 January 2016 at 01:11:19 UTC, Andrei Alexandrescu wrote: On 01/20/2016 04:22 PM, Ivan Kazmenko wrote: 1. The minimum or maximum element itself. I write it as a.minPos.front. That's almost fine, but maybe there is a more expressive way? Sadly, no. I'm very willing to add an

Re: So... add maxCount and maxPos?

2016-01-21 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 21 January 2016 at 12:17:26 UTC, default0 wrote: On Thursday, 21 January 2016 at 02:36:05 UTC, Ivan Kazmenko wrote: An alternative would be to define min(one argument) to just be that argument. That would be consistent with what we have now, but violates the principle of least

Re: topN using a heap

2016-01-19 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 19 January 2016 at 13:52:08 UTC, Andrei Alexandrescu wrote: On 01/18/2016 09:21 PM, Ivan Kazmenko wrote: Do you think sort and topN would be attackable if they used a per-process-seeded RNG as per Xinok's idea? -- Andrei Yes, but with a little interactivity (not generating the

Re: So... add maxCount and maxPos?

2016-01-20 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 20 January 2016 at 17:16:00 UTC, Andrei Alexandrescu wrote: This is one of those cases in which we were pedantically right to not add them, but their equivalents look like crap. https://github.com/D-Programming-Language/phobos/pull/3942 As it seems related, let me share my

Mention GSoC on the front page?

2016-04-14 Thread Ivan Kazmenko via Digitalmars-d
Hi, I just navigated to https://gentoo.org (home of Gentoo Linux), and among the scarce news items on the front page, the topmost is about Gentoo and Google Summer of Code. It links to two detailed pages on how and why to get involved. The thought is: maybe GSoC deserves a place on the

Compiling with -profile=gc makes program crash - why?

2016-04-20 Thread Ivan Kazmenko via Digitalmars-d
I'm trying to use DMD option "-profile=gc". With this option, the following simple program crashes with 2.071.0 down to 2.069.0 but still works on 2.068.2. The command line is "dmd -g -profile=gc prfail1.d" on Windows (compiled to 32-bit by default). -prfail1.d- import

Re: Compiling with -profile=gc makes program crash - why?

2016-04-20 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 20 April 2016 at 22:27:36 UTC, Ivan Kazmenko wrote: I'm trying to use DMD option "-profile=gc". With this option, the following simple program crashes with 2.071.0 down to 2.069.0 but still works on 2.068.2. The command line is "dmd -g -profile=gc prfail1.d" on Windows

Re: Compiling with -profile=gc makes program crash - why?

2016-04-21 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 21 April 2016 at 10:57:12 UTC, Ivan Kazmenko wrote: Humm, when I searched whether it should work, I only found a reassuring post by Walter[1] almost a year ago. The issue tracker does not seem to contain an entry either. Perhaps I should create one, then. [1]

Re: Compiling with -profile=gc makes program crash - why?

2016-04-21 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 21 April 2016 at 09:23:26 UTC, tcak wrote: I'm trying to use DMD option "-profile=gc". You are using "spawn". So it is a multithreaded program. -profile=gc doesn't work with multithreadd programs. Always creates problems. Humm, when I searched whether it should work, I only

Re: add attributes to debug

2016-07-24 Thread Ivan Kazmenko via Digitalmars-d
On Sunday, 24 July 2016 at 21:33:20 UTC, Gorge Jingale wrote: To allow for different debug versions without having to go full blown version(). @mem debug do something memory wise @see debug write a message to console I don't get what would be the benefit. Currently, you can write that like:

Re: D for competitive programming

2016-07-30 Thread Ivan Kazmenko via Digitalmars-d
Hi! On Thursday, 28 July 2016 at 21:20:29 UTC, urxvt1 wrote: I wanted to try topcoder problems (never used this site before) and I found out that it doesn't support dlang. They only have c++, java, c#, vb.net, python languages. It would be great to see D on this list. I highly doubt TopCoder

Re: 16MB static arrays again...

2016-08-24 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 24 August 2016 at 07:50:25 UTC, Tomer Filiba wrote: #WEKA #INDUSTRY I found this post from 2007 http://forum.dlang.org/post/fdspch$d3v$1...@digitalmars.com that refers to this post from 2006 http://www.digitalmars.com/d/archives/digitalmars/D/37038.html#N37071 -- and I still

Re: Function Proposal: std.algorithm.iteration : cumulativeSum

2016-11-01 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 1 November 2016 at 22:13:29 UTC, e-y-e wrote: On Tuesday, 1 November 2016 at 22:09:50 UTC, e-y-e wrote: On Tuesday, 1 November 2016 at 22:06:36 UTC, Ivan Kazmenko wrote: ... damn, that was a typo [cumulativeFold -> cumulativeSum] similarly, in the first para, cumulativeSum!((a,

Re: Function Proposal: std.algorithm.iteration : cumulativeSum

2016-11-01 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 1 November 2016 at 21:52:40 UTC, e-y-e wrote: I'd like to propose the function cumulativeFold as a new addition to std.algorithm.iteration. I have already opened a pull request [1] for this addition so the full implementation is available there. The function signatures are: DMD

Re: To use a scripting language or not to use a scripting language?

2017-01-06 Thread Ivan Kazmenko via Digitalmars-d
On Friday, 6 January 2017 at 14:19:34 UTC, Anton Pastukhov wrote: As a game developer I can recommend to use Lua. This language is tradtionally used in many games/game engines. Ironically, one of D's declared selling points is, according to https://dlang.org/overview.html: Who is D For?

Re: Zcoin implementation bug enabled attacker to create 548, 000 Zcoins

2017-03-09 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 9 March 2017 at 15:42:22 UTC, qznc wrote: I'm curious. Where does it make sense for opEquals to be non-pure? Likewise opCmp, etc. An example would be tracking the number of comparisons made. This sounds like debug information (and then, debug statement can be used to escape

Re: Why does phobos have collisions?

2017-06-07 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 7 June 2017 at 10:01:30 UTC, Mike B Johnson wrote: Error: template std.algorithm.mutation.strip cannot deduce function from argument types !()(string), candidates are: src\phobos\std\algorithm\mutation.d(2280): std.algorithm.mutation.strip(Range, E)(Range range, E element)

Re: [OT] Algorithm question

2017-05-01 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 1 May 2017 at 04:15:35 UTC, H. S. Teoh wrote: Given a set A of n elements (let's say it's a random-access range of size n, where n is relatively large), and a predicate P(x) that specifies some subset of A of elements that we're interested in, what's the best algorithm (in terms of

Re: [OT] Algorithm question

2017-05-02 Thread Ivan Kazmenko via Digitalmars-d
On Monday, 1 May 2017 at 21:54:43 UTC, MysticZach wrote: On Monday, 1 May 2017 at 16:56:58 UTC, MysticZach wrote: The goal is to have the first hit be the one you return. The method: if a random pick doesn't satisfy, randomly choose the partition greater than or less than based on

Re: [OT] Algorithm question

2017-05-02 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 2 May 2017 at 10:35:46 UTC, Ivan Kazmenko wrote: I hope some part of the idea is still salvageable. For example, what if we put the intervals in a queue instead of a stack? I tried to implement a similar approach, but instead of a queue or a stack, I used a random-access array of

An unfortunate quirk of DMD32 converting floating-point to string

2017-12-26 Thread Ivan Kazmenko via Digitalmars-d
While exploring quirks of floating-point values, as well as C/C++/D convenience with them, I stumbled on, in essence, the following (DMD32 on Windows): void main () { import std.stdio : writefln; double x = 128.0;// same for real or float writefln ("%.20a", x); //

Re: An unfortunate quirk of DMD32 converting floating-point to string

2017-12-28 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 26 December 2017 at 23:58:43 UTC, Walter Bright wrote: On 12/26/2017 3:41 PM, Ivan Kazmenko wrote: While exploring quirks of floating-point values, as well as C/C++/D convenience with them, I stumbled on, in essence, the following (DMD32 on Windows): The issue is really with the

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 18 July 2018 at 15:13:24 UTC, rikki cattermole wrote: On 19/07/2018 3:03 AM, Ivan Kazmenko wrote: That's by DMD32 on Windows.  (Sorry, my DMD64 broke after upgrading Visual Studio to 2017, and I failed to fix it right now.  Anyway, it's not like x86_64 uses a different set of

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 18 July 2018 at 14:02:28 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 18 July 2018 at 13:12:05 UTC, Ivan Kazmenko wrote: Leaving x uninitialized, or using floats, work about the same. No, floats are a whole lot less slow. Are they? Locally, I don't see much difference.

Re: opCmp / opEquals do not actually support partial orders

2018-07-18 Thread Ivan Kazmenko via Digitalmars-d
On Tuesday, 17 July 2018 at 21:18:12 UTC, John Colvin wrote: Just do what std.typecons.Proxy does and return float.nan for the incomparable case. Isn't it slow though on current processors? I just threw together a test program. - import std.datetime.stopwatch, std.math, std.stdio;

Re: dmd optimizer now converted to D!

2018-07-05 Thread Ivan Kazmenko via Digitalmars-d
On Wednesday, 4 July 2018 at 17:22:22 UTC, H. S. Teoh wrote: ... dmd *is* capable of things like strength reduction and code lifting, but as Walter himself has said, it does *not* implement loop unrolling. Ow! I always thought it did loop unrolling in some cases, I was just never lucky when

Re: dmd optimizer now converted to D!

2018-07-05 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 5 July 2018 at 14:05:42 UTC, Seb wrote: FYI: you can introduce scopes with static foreach to declare new variables: for (int i = 0; i < 4 * n; i += 4) { static foreach (k; 0..4) {{ auto idx = i + k a[idx] += idx; }} } Thanks! The two parentheses trick

Re: dmd optimizer now converted to D!

2018-07-05 Thread Ivan Kazmenko via Digitalmars-d
On Thursday, 5 July 2018 at 14:30:05 UTC, Dukc wrote: foreach(j, ref piece; cast(int[4][]) a) { auto pieceI = j * 4; static foreach(i; 0 .. piece.length) piece[i] = pieceI + i; } Can probably be made even better by designing some template helper. Thanks! The cast to an array of

Re: Different random shuffles generated when compiled with gdc than with dmd

2014-06-01 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 31 May 2014 at 21:22:48 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 31/05/14 22:37, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: On 30/05/14 22:45, monarch_dodra via Digitalmars-d-learn wrote: Didn't you make changes to how and when the global PRNG is

hijacking override from template mixin

2014-06-09 Thread Ivan Kazmenko via Digitalmars-d-learn
The D language pays certain attention to avoiding hijacking [1]. So I was surprised when I hijacked a function override from a template mixin by mistake. Here is a commented example. The comments explain the relevant part of the life cycle of the program. - // Start with class A with

Re: hijacking override from template mixin

2014-06-10 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 9 June 2014 at 16:13:50 UTC, monarch_dodra wrote: On Monday, 9 June 2014 at 15:54:21 UTC, Ivan Kazmenko wrote: I'd expect a multiple overrides of same function error, much like if I just paste the mixin code by hand. Is that a bug or working by design? In the latter case, please

Re: why does clearing an array set its capacity to 0?

2014-07-01 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 13:03:54 UTC, Vlad Levenfeld wrote: I was mistaken earlier, decrementing the length counter also sets the capacity to 0. Besides just learning to use assumeSafeAppend (as mentioned already), I'd also recommend reading the article on D slices to deeper understand

Re: Learning to use ranges instead of arrays

2014-07-21 Thread Ivan Kazmenko via Digitalmars-d-learn
Also, there is std.array.array for the ranges you want to convert to arrays. For example, if a is an array, a.map!(x = x * 2).array produces an new array of doubled values (as opposed to a lazy range produced by std.algorithm.map).

Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. - (hex: D0 A2 D0 B5 D1 81 D1 82 2E 0D 0A) Example output: -

Re: Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file into a string was what I indeed expected it to do. So, if there is an idiomatic way to read the whole

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:03:03 UTC, Ali Çehreli wrote: On 11/03/2014 11:47 AM, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is Unicode-compatible, it would be great to learn that, too. Maybe something like

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 11:46:24 UTC, Kagamin wrote: https://issues.dlang.org/show_bug.cgi?id=12990 this? Similar, but not quite that. Bugs 12990 and 1448 (linked from there) seem to have Windows console as an important part of the process. For me, the example does not work even

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 13:01:48 UTC, anonymous wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); }

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 18:09:48 UTC, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is

cannot sort an array of char

2014-11-05 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c); } - Why is char [] so special that it can't be sorted? For example, if I know the array contains only ASCII characters, sorting

Re: cannot sort an array of char

2014-11-06 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort

Re: cannot sort an array of char

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
IK For example, isRandomAccessRange[0] states the problem: IK - IK Although char[] and wchar[] (as well as their qualified IK versions including string and wstring) are arrays, IK isRandomAccessRange yields false for them because they use IK variable-length encodings (UTF-8 and UTF-16

Re: cannot sort an array of char

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
IK Why is char [] so special that it can't be sorted? SS Because sort works on ranges, and std.range has the view that SS char[] is a range of dchar without random access. Nevermind SS what the compiler thinks :) SS SS I believe you can get what you want with SS std.string.representation: SS SS

Re: Russian translation of the range term?

2014-11-11 Thread Ivan Kazmenko via Digitalmars-d-learn
I was thinking about list comprehension, which is what programming on ranges is. Isn't it? list is a good term, but it's already taken. so naming range as list will create unnecessary confusion. alas. yet набор is short and easy, and it's not widely used, as set is translated as множество.

Re: printing array of strings with writefln?

2014-11-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 16 November 2014 at 15:08:10 UTC, JR wrote: On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote: writefln(%(%s-%), [a, b, c]) doesn't print the intended a-b-c but surrounds each string with double quotes - a-b-c, which I find inconsistent with the fact that

Re: Russian translation of the range term?

2014-11-17 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 20:48:00 UTC, Jack Applegame wrote: интервал, область Thanks to all for the suggestions and reasoning! I don't yet see a word which clicks in this case, but we got multiple reasonable suggestions here. Perhaps I'll be fine with one of them. Ivan

Re: Getting DAllegro 5 to work in Windows

2014-12-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 24 December 2014 at 06:47:26 UTC, Joel wrote: I can't get implib.exe (http://ftp.digitalmars.com/bup.zip) to produce .lib files from dlls (https://www.allegro.cc/files/). I think it works for other people. Thanks for any help. Reading Part II of this answer on Stackoverflow

Re: A specifier readf() for BigInt

2015-02-16 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 16 February 2015 at 19:52:20 UTC, Dennis Ritchie wrote: Hi. And how to read Data from the input stream? import std.stdio; import std.bigint; void main() { BigInt n; readf( %?, n); writeln(n); } The readf function does not seem to support reading BigInts

Re: How to make a Currency class from std.BigInt?

2015-01-30 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 30 January 2015 at 20:34:53 UTC, RuZzz wrote: What do I need to learn? c[BTC][N-01] = 1.0002;//Error: cannot implicitly convert expression (1) of type double to axfinance.api.currencies.Currencies As I see it, there is no constructor in your class with a double argument.

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 31 January 2015 at 13:45:22 UTC, RuZzz wrote: I want to understand the correct architecture of the class. Sorry, you still did not state your problem (or what you are trying to achieve) clearly. Writing down a clear problem description is likely to get you halfway to the

Re: The best way to compare floating point values.

2015-02-14 Thread Ivan Kazmenko via Digitalmars-d-learn
There is an approxEqual in std.math, in addition in feqrel: http://dlang.org/phobos/std_math.html#.approxEqual It takes maximum absolute and relative difference as arguments.

refactoring issues

2015-03-17 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi, I was just refactoring a project to compile under 2.067. The fixes themselves were trivial: just adding import std.traits; to some files. Apparently its pieces were publicly imported by another module in 2.066. So, it's the right fix anyway. Understanding what happened, however, took

Re: refactoring issues

2015-03-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 20 March 2015 at 18:37:57 UTC, Vladimir Panteleev wrote: On Friday, 20 March 2015 at 18:36:19 UTC, Vladimir Panteleev wrote: On Friday, 20 March 2015 at 18:05:07 UTC, Ivan Kazmenko wrote: Thanks. I was able to reproduce the workflow you showed in the gif to the part where an error

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 14:31:20 UTC, Dennis Ritchie wrote: In C++ it is fully working: char s[25], t[25]; scanf(%s%s, s, t); Indeed. Generate a 10-character string: - import std.range, std.stdio; void main () {'a'.repeat (10).writeln;} - Try to copy it with D

Re: The difference in string and char[], readf() and scanf()

2015-03-21 Thread Ivan Kazmenko via Digitalmars-d-learn
On Saturday, 21 March 2015 at 16:34:44 UTC, Dennis Ritchie wrote: And why in D copied only the first 32767 characters of the string? I'm more days couldn't understand what was going on... To me, it looks like a bug somewhere, though I don't get where exactly. Is it in bits of DigitalMars

Re: refactoring issues

2015-03-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 19 March 2015 at 10:21:09 UTC, Vladimir Panteleev wrote: On Tuesday, 17 March 2015 at 15:11:02 UTC, Ivan Kazmenko wrote: For the former problem, is there a tool which jumps out and tells you use Phobos without importing things properly, or suggests a Phobos import by the name of

Re: refactoring issues

2015-03-20 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 19 March 2015 at 16:06:31 UTC, Vladimir Panteleev wrote: On Thursday, 19 March 2015 at 14:32:53 UTC, Ivan Kazmenko wrote: Hey, I also happen to use Far Manager and its internal editor, at least for simple projects. Is that dcheck triggering a Far plugin? I have a bit of

Re: BigInt and xor

2015-03-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote: Will file an issue soon. Here it is: https://issues.dlang.org/show_bug.cgi?id=14340 And another one, a 2.067 regression: https://issues.dlang.org/show_bug.cgi?id=14341

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:09:53 UTC, bearophile wrote: Dennis Ritchie: A more effective solution for C ++: #include iostream #include vector #include range/v3/all.hpp int main() { using namespace ranges; auto rng = istreamint( std::cin ) | to_vector |

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:17:57 UTC, bearophile wrote: Ivan Kazmenko: (1) For me, the name of the function is obscure. Something like sortBy would be a lot easier to find than schwartzSort. I've asked to change the name of that function for years. But Andrei Alexandrescu is a

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 19:32:43 UTC, Dennis Ritchie wrote: On Wednesday, 25 March 2015 at 19:01:43 UTC, bearophile wrote: One solution: Thanks. On Wednesday, 25 March 2015 at 19:03:27 UTC, bearophile wrote: But calling count for each item is not efficient (in both C# and D). If your

Re: C# to D

2015-03-25 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 20:02:20 UTC, Ivan Kazmenko wrote: (2) The documentation says it is more efficient than the first version in the number of comparisons (verbose lambda with plain sort) [1], but I don't get how it is possible: unless we know than (not pred1(a,b)) and (not

  1   2   3   >