Re: Post increment and decrement

2015-03-12 Thread monarch_dodra via Digitalmars-d
On Wednesday, 11 March 2015 at 17:23:15 UTC, welkam wrote: Observation Nr. 1 People prefer to write var++ instead of ++var. The root of your reasoning stems from this observation, which I argue is wrong. The recommendation has always been to chose ++var, unless you have a reason to chose

Re: Two suggestions for safe refcounting

2015-03-06 Thread monarch_dodra via Digitalmars-d
On Friday, 6 March 2015 at 07:46:13 UTC, Zach the Mystic wrote: The second, harder problem, is when you take a reference to a subcomponent of an RC'd type, e.g. an individual E of an RCArray of E: struct RCArray(E) { E[] array; int* count; ... } auto x = RCArray([E()]); E* t = x[0];

Re: A Refcounted Array Type

2015-03-05 Thread monarch_dodra via Digitalmars-d
On Thursday, 5 March 2015 at 16:19:09 UTC, Marc Schütz wrote: On Thursday, 5 March 2015 at 15:20:47 UTC, monarch_dodra wrote: On Monday, 23 February 2015 at 22:15:54 UTC, Walter Bright wrote: private: E[] array; size_t start, end; int* count; What is the point of keeping start/end?

Re: A Refcounted Array Type

2015-03-05 Thread monarch_dodra via Digitalmars-d
On Monday, 23 February 2015 at 22:15:54 UTC, Walter Bright wrote: private: E[] array; size_t start, end; int* count; What is the point of keeping start/end? Aren't those baked into the array slice? Not storing start end means not having to do index arithmetic (minor), reducing

Re: New std.range submodule

2014-11-21 Thread monarch_dodra via Digitalmars-d
On Wednesday, 19 November 2014 at 18:22:27 UTC, H. S. Teoh via Digitalmars-d wrote: On Wed, Nov 19, 2014 at 06:06:26PM +, Nick Treleaven via Digitalmars-d wrote: On 14/11/2014 21:52, David Nadlinger wrote: On Friday, 14 November 2014 at 06:10:43 UTC, Rikki Cattermole wrote:

Named parameter builder pattern for template parameters

2014-11-21 Thread monarch_dodra via Digitalmars-d
I trust everyone here knows about the builder pattern (http://en.wikipedia.org/wiki/Builder_pattern)? It can be very useful when the number of (optional) arguments in a function start to run rampant, and you know the user only wants to start setting a subset of these. D has phenomenal meta

Re: Named parameter builder pattern for template parameters

2014-11-21 Thread monarch_dodra via Digitalmars-d
On Friday, 21 November 2014 at 14:46:00 UTC, ketmar via Digitalmars-d wrote: On Fri, 21 Nov 2014 13:39:42 + monarch_dodra via Digitalmars-d digitalmars-d@puremagic.com wrote: D has phenomenal meta programming possibilities, and I see more and more templates taking more and more

Re: OT: Minecraft death by GC

2014-10-21 Thread monarch_dodra via Digitalmars-d
On Tuesday, 21 October 2014 at 09:07:04 UTC, ROOAR wrote: I could quote the entire post, but the bottom line is: this issue has nothing to do with the GC. Crappy code is crappy code. So your OP is just pointless troll. This issue sure does seem to crop up in GC world, wonder why. Oh well.

Re: example of pointer usefulness in D

2014-10-21 Thread monarch_dodra via Digitalmars-d
On Tuesday, 21 October 2014 at 12:22:54 UTC, edn wrote: Could someone provide me with examples showing the usefulness of pointers in the D language? They don't seem to be used as much as in C and C++. The only difference between C/C++ and D is that C uses pointers for both pointer to object

Re: GCC Undefined Behavior Sanitizer

2014-10-19 Thread monarch_dodra via Digitalmars-d
On Saturday, 18 October 2014 at 23:10:15 UTC, Ola Fosheim Grøstad wrote: On Saturday, 18 October 2014 at 08:22:25 UTC, monarch_dodra wrote: Besides, the code uses x + 1, so the code is already in undefined state. It's just as wrong as the horrible code with UB we wère trying to avoid in the

Re: GCC Undefined Behavior Sanitizer

2014-10-19 Thread monarch_dodra via Digitalmars-d
On Sunday, 19 October 2014 at 09:56:44 UTC, Ola Fosheim Grøstad wrote: In C++ you should default to int and avoid uint unless you do bit manipulation according to the C++ designers. There are three reasons: speed, portability to new hardware and correctness. Speed: How so? Portability: One

Re: Error: Undefined identifier when moving import to another module

2014-10-19 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 19 October 2014 at 09:39:05 UTC, nrgyzer wrote: Hi guys, when I do the following: static if ( isCallable!(mixing(m) ) mixing ? void main() { /* do something here */ } What exactly are you doing here? ... I'm getting many error messages like these:

Re: Error: Undefined identifier when moving import to another module

2014-10-19 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 19 October 2014 at 16:09:41 UTC, nrgyzer wrote: mixing should be replaced with mixin: static if ( isCallable!(mixin(m) ) My main is empty in both cases. So nothing done in my main (currently). Posting full code that actually compiles and reproduces the issue helps.

Re: GCC Undefined Behavior Sanitizer

2014-10-18 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 13:44:24 UTC, ketmar via Digitalmars-d wrote: On Fri, 17 Oct 2014 09:46:48 + via Digitalmars-d digitalmars-d@puremagic.com wrote: In D (and C++) you would get: if (x ((x+1)0x)){…} perfect. nice and straightforward way to do overflow checks.

Re: Postblit bug

2014-10-18 Thread monarch_dodra via Digitalmars-d
On Saturday, 18 October 2014 at 06:43:28 UTC, Marco Leise wrote: Am Fri, 17 Oct 2014 17:25:46 + schrieb monarch_dodra monarchdo...@gmail.com: But maybe this answers your question? import std.stdio; struct S { int* p; this(this) { ++*p; } } void main() {

Re: C++ Ranges proposal for the Standard Library

2014-10-18 Thread monarch_dodra via Digitalmars-d
On Saturday, 18 October 2014 at 15:39:36 UTC, Ola Fosheim Grøstad wrote: On Saturday, 18 October 2014 at 15:17:09 UTC, Andrei Alexandrescu wrote: No need to implement it. http://dlang.org/phobos/std_algorithm.html#.sum It isn't accurate. Did you look at the doc. It's specially designed

Re: C++ Ranges proposal for the Standard Library

2014-10-18 Thread monarch_dodra via Digitalmars-d
On Saturday, 18 October 2014 at 17:31:18 UTC, Walter Bright wrote: I agree. It's like foreach in D. It's less powerful and foundational than a for loop (in fact, the compiler internally rewrites foreach into for), but that takes nothing away from how darned useful (and far less bug prone)

Re: C++ Ranges proposal for the Standard Library

2014-10-17 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 09:17:52 UTC, ZombineDev wrote: I saw [this][0] proposal for adding ranges to C++'s standard library. The [paper][1] looks at D style ranges, but concludes: Since iterators can implement D ranges, but D ranges cannot be used to implement iterators, we conclude

Re: Postblit bug

2014-10-17 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 00:55:25 UTC, ketmar via Digitalmars-d wrote: On Fri, 17 Oct 2014 00:42:24 + IgorStepanov via Digitalmars-d digitalmars-d@puremagic.com wrote: Can someone comment this code? Should I think that it's a bug. it's just an anomaly. const postblit can do alot of

Re: How to iterate over const(RedBlackTree)?

2014-10-17 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 01:09:00 UTC, John McFarlane wrote: On Friday, 3 January 2014 at 07:22:32 UTC, monarch_dodra wrote: On Thursday, 2 January 2014 at 14:59:55 UTC, Adam D. Ruppe wrote: On Thursday, 2 January 2014 at 13:30:06 UTC, monarch_dodra wrote: Currently, this is not possible.

Re: Postblit bug

2014-10-17 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 16:19:47 UTC, IgorStepanov wrote: It's just common words=) I meant that when postblit is called when new object is being creating and doesn't exists for user code. E.g. const S v1 = v2; Ok, v1 _will_ be const when it will be _created_. However postblit can think

Re: C++ Ranges proposal for the Standard Library

2014-10-17 Thread monarch_dodra via Digitalmars-d
On Friday, 17 October 2014 at 19:11:48 UTC, eles wrote: On Friday, 17 October 2014 at 17:14:24 UTC, Paulo Pinto wrote: Am 17.10.2014 um 17:14 schrieb Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com: On Friday, 17 October 2014 at 09:52:26 UTC, Marco Leise wrote: And

Re: @safety of Array

2014-10-14 Thread monarch_dodra via Digitalmars-d
On Tuesday, 14 October 2014 at 01:47:10 UTC, Brad Roberts via Digitalmars-d wrote: On 10/13/2014 1:28 PM, monarch_dodra via Digitalmars-d wrote: On Monday, 13 October 2014 at 17:16:40 UTC, Brad Roberts via Digitalmars-d wrote: On 10/13/2014 7:47 AM, Andrei Alexandrescu via Digitalmars-d wrote

Re: @safety of Array

2014-10-14 Thread monarch_dodra via Digitalmars-d
On Tuesday, 14 October 2014 at 17:59:43 UTC, Brad Roberts via Digitalmars-d wrote: On 10/14/2014 3:49 AM, monarch_dodra via Digitalmars-d wrote: You say I'm focused on impl, but @safe *is* an implementation certification. I'm not derailing the thread or talking about process. If Array can't

Re: @safety of Array

2014-10-13 Thread monarch_dodra via Digitalmars-d
On Monday, 13 October 2014 at 17:16:40 UTC, Brad Roberts via Digitalmars-d wrote: On 10/13/2014 7:47 AM, Andrei Alexandrescu via Digitalmars-d wrote: On 10/12/14, 5:41 PM, Brad Roberts via Digitalmars-d wrote: I know it's a tricky implementation, but let's focus on the goal.. should Array be

Re: @safety of Array

2014-10-13 Thread monarch_dodra via Digitalmars-d
Example: ref int getAsRef(int a) @safe //Magic! { RefCounted!int rc = a; return rc.getPayload(); } I wouldn't want to be on the calling end of this safe function...

Re: Formatted output of range of tuples

2014-10-13 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 8 October 2014 at 23:28:34 UTC, bearophile wrote: anonymous: You can turn the tuples into ranges with `only`: writef(%(%(%s %)\n%), zip(indexes, source).map!(t = only(t.expand))); This is a nice idea. Expand can probably be replaced by a []. I presume this works only if the

Re: DList!int.remove(range.takeOne) - workarounds?

2014-10-12 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 12 October 2014 at 09:45:22 UTC, Algo wrote: DList seems to have an issue with remove: void main() { import std.container, std.range, std.algorithm; auto list = DList!int([1, 2, 4, 6]); auto res = find(list[], 2); list.remove(res); //ok /*

Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

2014-10-11 Thread monarch_dodra via Digitalmars-d
On Saturday, 11 October 2014 at 04:11:30 UTC, Dicebot wrote: On Friday, 10 October 2014 at 02:38:42 UTC, Walter Bright wrote: This has come up before, and has been debated at length. const is used both as a storage class and as a type constructor, and is distinguished by the grammar:

Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

2014-10-11 Thread monarch_dodra via Digitalmars-d
On Saturday, 11 October 2014 at 12:45:40 UTC, Dicebot wrote: On Saturday, 11 October 2014 at 07:36:21 UTC, monarch_dodra wrote: Wait what? Are you saying there is a single case when this: const T var; is not identical to this: const(T) var; No, look at the pointer symbol. module test;

Re: struct and default constructor

2014-10-10 Thread monarch_dodra via Digitalmars-d
On Sunday, 27 November 2011 at 19:50:24 UTC, deadalnix wrote: Hi, I wonder why struct can't have a default constructor. TDPL state that it is required to allow every types to have a constant .init . That is true, however not suffiscient. A struct can has a void[constant] as a member and

Re: Splitting Ranges using Lambda Predicates

2014-10-10 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 10 October 2014 at 05:55:00 UTC, Nordlöw wrote: On Thursday, 9 October 2014 at 22:01:31 UTC, monarch_dodra wrote: My quick guess is you are missing the *global* imports for the restraints. The compiler doesn't complain because the constraint is in a is(typeof(...)) test. The reason

Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

2014-10-09 Thread monarch_dodra via Digitalmars-d
On Thursday, 9 October 2014 at 08:50:52 UTC, Martin Nowak wrote: Would this affect your code? I've written code before in the style: @property pure nothrow const //- HERE int foo(); So anybody else using this style might be affected. But even then, I agree. D has always been about if it's

Re: Splitting Ranges using Lambda Predicates

2014-10-09 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 9 October 2014 at 21:55:03 UTC, Nordlöw wrote: On Wednesday, 11 June 2014 at 08:58:58 UTC, monarch_dodra wrote: auto slicer(alias isTerminator, Range)(Range input) if (((isRandomAccessRange!Range hasSlicing!Range) || isSomeString!Range)

Re: scope() statements and return

2014-10-07 Thread monarch_dodra via Digitalmars-d
On Monday, 6 October 2014 at 16:59:35 UTC, Andrei Alexandrescu wrote: Whenever an exception is converted to a string, the chained exceptions should be part of it too. On Monday, 6 October 2014 at 17:12:00 UTC, Jakob Ovrum wrote: However, the whole point is implicit chaining, which is where

Re: The pull request of the day: 3998

2014-10-07 Thread monarch_dodra via Digitalmars-d
On Tuesday, 7 October 2014 at 17:58:41 UTC, Dicebot wrote: On Tuesday, 7 October 2014 at 17:36:24 UTC, Jonathan wrote: What are some common uses for multiple aliasing? I understand the feature, but curious where it would be commonly employed. To me, this allows structs to have something like

Re: coding practices: include whole module or only the needed function

2014-10-07 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 7 October 2014 at 07:33:24 UTC, Gary Willoughby wrote: On Monday, 6 October 2014 at 21:24:56 UTC, AsmMan wrote: Which practice do you use: if you need only one or two functions from a module: import myModule : func, func2; or (import whole module, assuming no function name

Re: coding practices: include whole module or only the needed function

2014-10-07 Thread monarch_dodra via Digitalmars-d-learn
On Tuesday, 7 October 2014 at 17:29:45 UTC, ketmar via Digitalmars-d-learn wrote: On Tue, 07 Oct 2014 17:24:40 + bachmeier via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 7 October 2014 at 08:37:59 UTC, monarch_dodra wrote: As a general rule, avoid imports

Re: scope() statements and return

2014-10-06 Thread monarch_dodra via Digitalmars-d
On Monday, 6 October 2014 at 02:35:52 UTC, Shammah Chancellor wrote: It doesn't catch the error. Propigation should continue as normal. Right, it only intercepts, cleanups, and rethrows. But the argument is that even that shouldn't happen, as you aren't sure the cleanup code is still

Re: scope() statements and return

2014-10-06 Thread monarch_dodra via Digitalmars-d
On Monday, 6 October 2014 at 13:48:07 UTC, Andrei Alexandrescu wrote: On 10/6/14, 12:27 AM, Walter Bright wrote: On 10/5/2014 10:09 AM, Dicebot wrote: On Sunday, 5 October 2014 at 17:03:07 UTC, Andrei Alexandrescu wrote: On 10/5/14, 9:42 AM, Dicebot wrote: On Sunday, 5 October 2014 at

Re: scope() statements and return

2014-10-06 Thread monarch_dodra via Digitalmars-d
On Monday, 6 October 2014 at 14:54:21 UTC, Andrei Alexandrescu wrote: On 10/6/14, 7:24 AM, monarch_dodra wrote: If your catch throws an exception, then the new exception simply squashes replaces the old one: // catch (Exception e) { thisMightThrow(); //Lose e here throw e; }

Re: array append result type

2014-10-06 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 6 October 2014 at 11:28:16 UTC, John Colvin wrote: string a; char[] b; pragma(msg, typeof(a ~ b)); // char[] why not string? What are the rules that determine this? *Ideally*, I'd have said it returns char[], so that you can chose via purity. However, it's not pure, so that

Re: array append result type

2014-10-06 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 6 October 2014 at 16:38:37 UTC, Steven Schveighoffer wrote: I filed this ER ages ago: https://issues.dlang.org/show_bug.cgi?id=1654 Not sure if anyone has it on their radar at this point. -Steve I didn't read the whole thing, but wouldn't purity be a major game changer for 1654?

Re: slidingSplitter + retro

2014-10-06 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 6 October 2014 at 20:06:41 UTC, Nordlöw wrote: I've almost satisfied with my new range slidingSplitter at https://github.com/nordlow/justd/blob/master/range_ex.d#L19 All unittest work as expected except my radial test https://github.com/nordlow/justd/blob/master/range_ex.d#L243

Re: scope() statements and return

2014-10-05 Thread monarch_dodra via Digitalmars-d
On Saturday, 4 October 2014 at 18:42:05 UTC, Shammah Chancellor wrote: Didn't miss anything. I was responding to Andrei such that he might think it's not so straightforward to evaluate that code. I am with you on this. It was my original complaint months ago that resulted in this being

Re: scope() statements and return

2014-10-05 Thread monarch_dodra via Digitalmars-d
On Sunday, 5 October 2014 at 12:36:30 UTC, ketmar via Digitalmars-d wrote: On Sun, 05 Oct 2014 11:28:59 + monarch_dodra via Digitalmars-d digitalmars-d@puremagic.com wrote: In theory, you should seldom ever catch Errors. I don't understand why scope(exit) are catching them. 'cause scope

Re: scope() statements and return

2014-10-05 Thread monarch_dodra via Digitalmars-d
On Sunday, 5 October 2014 at 15:03:08 UTC, ketmar via Digitalmars-d wrote: On Sun, 05 Oct 2014 14:53:37 + monarch_dodra via Digitalmars-d digitalmars-d@puremagic.com wrote: Promises hold provided the precondition your program is in a valid state. Having an Error invalidates

Re: How to detect start of Unicode symbol and count amount of graphemes

2014-10-05 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 5 October 2014 at 08:27:58 UTC, Uranuz wrote: I have struct StringStream that I use to go through and parse input string. String could be of string, wstring or dstring type. I implement function popChar that reads codeUnit from Stream. I want to have *debug* mode of parser (via CT

Re: No TypeTuple expansion for assert?

2014-10-04 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 20:28:21 UTC, H. S. Teoh via Digitalmars-d wrote: On Fri, Oct 03, 2014 at 08:02:14PM +, monarch_dodra via Digitalmars-d wrote: On Friday, 3 October 2014 at 19:21:38 UTC, Dmitry Olshansky wrote: 03-Oct-2014 23:08, Ali Çehreli пишет: I know that assert

Re: Feedback Wanted on Homegrown @nogc WriteLn Alternative

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Thursday, 2 October 2014 at 23:32:32 UTC, H. S. Teoh via Digitalmars-d wrote: Alright, today I drafted up the following proof of concept: [...] writefln!Number: %d Tag: %s(123, mytag); I had (amongst with others) thought about the possibility of ct-write. I think an even more powerful

Re: Division by zero

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 12:55:35 UTC, Adam D. Ruppe wrote: On Friday, 3 October 2014 at 12:31:54 UTC, Marc Schütz wrote: For integral operands of the / and % operators, [...]. If the divisor is zero, an Exception is thrown. It should probably just say that is implementation defined. I'm

Re: Division by zero

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 13:29:18 UTC, Walter Bright wrote: In any case, a bugzilla issue should be filed for this. https://issues.dlang.org/show_bug.cgi?id=13569

Re: Feedback Wanted on Homegrown @nogc WriteLn Alternative

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 17:01:46 UTC, H. S. Teoh via Digitalmars-d wrote: For a compile-string that's statically fixed (i.e., writefln!...(...)), we can do a lot more than what ctFmt does. For example, we can parse the format at compile-time to extract individual formatting specifiers and

Re: Feedback Wanted on Homegrown @nogc WriteLn Alternative

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 17:01:46 UTC, H. S. Teoh via Digitalmars-d wrote: On Fri, Oct 03, 2014 at 11:15:28AM +, monarch_dodra via Digitalmars-d wrote: On Thursday, 2 October 2014 at 23:32:32 UTC, H. S. Teoh via Digitalmars-d wrote: Alright, today I drafted up the following proof

Re: On exceptions, errors, and contract violations

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 17:40:43 UTC, Sean Kelly wrote: A contract has preconditions and postconditions to validate different types of errors. Preconditions validate user input (caller error), and postconditions validate resulting state (callee error). Technically, a precondition

Re: No TypeTuple expansion for assert?

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 19:21:38 UTC, Dmitry Olshansky wrote: 03-Oct-2014 23:08, Ali Çehreli пишет: I know that assert is not a function but it would be nice to have. Indeed. If we make it a function and put in object.d would anyone notice the change? I think there are semantics

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 15:22:06 UTC, Nordlöw wrote: Destroy, please! As a quick comment, your definition of moveFront is not what phobos understands with moveFront: https://github.com/D-Programming-Language/phobos/blob/7914fa31cb3b53f4e50421399f2b99d2012e8031/std/range.d#L8267

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 17:06:41 UTC, Nordlöw wrote: On Friday, 3 October 2014 at 16:32:24 UTC, monarch_dodra wrote: If anything, I'd have expected you to provide something returns the popped element. What you do pops an element, and then returns the *next* one. What good is that? My

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 19:12:54 UTC, Nordlöw wrote: On Friday, 3 October 2014 at 17:46:18 UTC, monarch_dodra wrote: If your implementation use two ranges that you slice on the fly, then you can trivially support strings, thanks to popFront. Very clever. That's what I wanted. I threw

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 19:46:10 UTC, Nordlöw wrote: Is prefix ++ preferred in D because of some specific reason? I recall it, for some containers/iterators, gives smaller/faster codegen in C++? Be it C, C++ or D, pre increment is maybe faster, and is never slower. So as a rule of

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 20:28:24 UTC, Nordlöw wrote: On Friday, 3 October 2014 at 20:15:33 UTC, Nordlöw wrote: Could you please take a look again at I made another update at https://github.com/nordlow/justd/blob/master/range_ex.d#L15 I had forgotten to move front and popFront out of

Re: RFC on SlidingSplitter Range

2014-10-03 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 3 October 2014 at 20:15:33 UTC, Nordlöw wrote: Note that I had to tweak empty() a bit. I don't know if I got right. Could you check? Sounds about right, but I didn't really look. Further I can't get string support to work: writefln(%(%s\n%), slidingSplitter(Nordlöw)); errors

Re: Find Semantically Correct Word Splits in UTF-8 Strings

2014-10-02 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 1 October 2014 at 21:34:40 UTC, Nordlöw wrote: On Wednesday, 1 October 2014 at 17:09:57 UTC, monarch_dodra wrote: Does that even work? takeExactly would pop up to N *codepoints*, whereas your string only has N *codeunits*. Your're right again :) If forgot that takeExactly

Re: How do I check if a function got CTFE?

2014-10-02 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 2 October 2014 at 18:42:56 UTC, AsmMan wrote: I was thiking the dmd compiler did CTFE without someone ask for this, in the way as I've mentioned, checking for constant arguments + function's purity and if all this is true, it did the CTFE rather than generate code to compute it at

Re: std.utf.decode @nogc please

2014-10-01 Thread monarch_dodra via Digitalmars-d
On Wednesday, 1 October 2014 at 10:51:25 UTC, Walter Bright wrote: On 10/1/2014 3:10 AM, Robert burner Schadek wrote: Ideas, Suggestions ... ? any takers? You can use .byDchar instead, which is nothrow @nogc. Being forced out of using exception just to be able to have the magic @nogc tag

Re: std.utf.decode @nogc please

2014-10-01 Thread monarch_dodra via Digitalmars-d
On Wednesday, 1 October 2014 at 10:10:51 UTC, Robert burner Schadek wrote: lately when working on std.string I run into problems making stuff nogc as std.utf.decode is not nogc. https://issues.dlang.org/show_bug.cgi?id=13458 Also I would like a version of decode that takes the string not as

Re: @safe pure nothrow compiler inference

2014-10-01 Thread monarch_dodra via Digitalmars-d
On Wednesday, 1 October 2014 at 15:12:41 UTC, Kagamin wrote: On Monday, 29 September 2014 at 14:40:34 UTC, Daniel N wrote: It can be done, Walter wanted to do it, but there was large resistance, mainly because library APIs would become unstable, possibly changing between every release. Huh?

Re: Find Semantically Correct Word Splits in UTF-8 Strings

2014-10-01 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 1 October 2014 at 11:47:41 UTC, Nordlöw wrote: On Wednesday, 1 October 2014 at 11:06:24 UTC, Nordlöw wrote: I'm looking for a way to make my algorithm Update: S[] findMeaningfulWordSplit(S)(S word, HLang[] langs = []) if (isSomeString!S)

Re: Find Semantically Correct Word Splits in UTF-8 Strings

2014-10-01 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 1 October 2014 at 11:06:24 UTC, Nordlöw wrote: I'm looking for a way to make my algorithm S[] findWordSplit(S)(S word, HLang[] langs = []) { for (size_t i = 1; i + 1 word.length; i++) { const first = word[0..i];

Re: Find Semantically Correct Word Splits in UTF-8 Strings

2014-10-01 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 1 October 2014 at 11:47:41 UTC, Nordlöw wrote: On Wednesday, 1 October 2014 at 11:06:24 UTC, Nordlöw wrote: I'm looking for a way to make my algorithm Update: S[] findMeaningfulWordSplit(S)(S word, HLang[] langs = []) if (isSomeString!S)

Re: Creeping Bloat in Phobos

2014-09-29 Thread monarch_dodra via Digitalmars-d
On Sunday, 28 September 2014 at 23:06:28 UTC, Walter Bright wrote: Note that autodecode does not always happen - it doesn't happen for ranges of chars. It's very hard to look at piece of code and tell if autodecode is going to happen or not. Arguably, this means we need to unify the behavior

Re: Creeping Bloat in Phobos

2014-09-29 Thread monarch_dodra via Digitalmars-d
On Sunday, 28 September 2014 at 23:21:15 UTC, Walter Bright wrote: It's very simple for an algorithm to decode if it needs to, it just adds in a .byDchar adapter to its input range. Done. No special casing needed. The lines of code written drop in half. And it works with both arrays of chars,

Re: Creeping Bloat in Phobos

2014-09-29 Thread monarch_dodra via Digitalmars-d
On Sunday, 28 September 2014 at 23:48:54 UTC, Walter Bright wrote: I think it was you that suggested that instead of throwing on invalid UTF, that the replacement character be used instead? Or maybe not, I'm not quite sure. Regardless, the replacement character method is widely used and

Re: Creeping Bloat in Phobos

2014-09-29 Thread monarch_dodra via Digitalmars-d
On Sunday, 28 September 2014 at 23:06:28 UTC, Walter Bright wrote: It's very hard to disable the autodecode when it is not needed, though the new .byCodeUnit has made that much easier. One issue with this though is that byCodeUnit is not actually an array. As such, by using byCodeUnit, you

Re: isArray and std.container.Array

2014-09-29 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 29 September 2014 at 10:18:09 UTC, Marc Schütz wrote: On Sunday, 28 September 2014 at 20:24:11 UTC, monarch_dodra wrote: On Sunday, 28 September 2014 at 19:06:09 UTC, Marc Schütz wrote: On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at

Re: Turn function into infinite range

2014-09-29 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 29 September 2014 at 17:02:43 UTC, Martin Nowak wrote: I though I've seen this around somewhere but can no longer find it. AFAIK, this as never existed. We recently merged in cache into phobos. This seems like a prime candidate to expand to also take a function/delegate, as on of

Re: Turn function into infinite range

2014-09-29 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 29 September 2014 at 21:16:27 UTC, Daniel Kozák via Digitalmars-d-learn wrote: V Mon, 29 Sep 2014 19:02:36 +0200 Martin Nowak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Does anyone know a construct to turn a lambda into an infinite range. import

Re: isArray and std.container.Array

2014-09-28 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:06:09 UTC, Marc Schütz wrote: On Sunday, 28 September 2014 at 16:12:53 UTC, Meta wrote: On Sunday, 28 September 2014 at 08:01:00 UTC, Nordlöw wrote: Is there a reason why isArray!T doesn't match T when T is a std.container.Array? I'm asking because after

Re: Non-const std.container.Array.opIndex and alikes blocks serialization

2014-09-28 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 28 September 2014 at 09:04:42 UTC, Nordlöw wrote: On Sunday, 28 September 2014 at 08:58:27 UTC, Nordlöw wrote: In my strive to add msgpacking support for std.container.Array I've been blocked by the fact that std.container.Array.opIndex only has one overload which is non-const

Re: A few questions regarding GC.malloc

2014-09-26 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 26 September 2014 at 18:03:40 UTC, Steven Schveighoffer wrote: On 9/25/14 6:03 PM, Sean Kelly wrote: On Thursday, 25 September 2014 at 21:43:53 UTC, monarch_dodra wrote: On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote: What does BlkAttr.FINALIZE do when used in

Re: Remove filename from path

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 17:15:39 UTC, Ali Çehreli wrote: find() and friends can be used: import std.algorithm; void main() { string path = myFile.doc; string extension = .doc; path = findSplitBefore(path, extension)[0]; assert(path == myFile); } I had thought of

immutable T.init, and pointers to mutable data

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member to the address to a static global: // __gshared int a = 0; struct S { int* p = a; } // Then, in theory, any variable, be they mutable or

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I may have found a type loophole. Given that you may initialize a pointer member to the address to a static global:

Re: immutable T.init, and pointers to mutable data

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 13:37:52 UTC, Steven Schveighoffer wrote: On 9/25/14 9:00 AM, monarch_dodra wrote: On Thursday, 25 September 2014 at 12:46:01 UTC, Steven Schveighoffer wrote: On 9/25/14 5:47 AM, monarch_dodra wrote: I was playing around with how T.init works. And I think I

Re: Fail to compile phobos

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 17:20:42 UTC, JJDuck wrote: I tried to compile phobos according to the last paragraph in this page: http://dlang.org/dmd-linux.html but this is the error I have fatal: Not a git repository (or any of the parent directories): .git I dont know what happened,

Re: A few questions regarding GC.malloc

2014-09-25 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 25 September 2014 at 20:58:29 UTC, Gary Willoughby wrote: A few questions regarding GC.malloc. When requesting a chunk of memory from GC.malloc am i right in assuming that this chunk is scanned for pointers to other GC resources in order to make decisions whether to collect them

Re: Remove filename from path

2014-09-24 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 10:11:04 UTC, Suliman wrote: What is the best way to remove file name from full path? string path = thisExePath() Seems like dirName in std.path is a good candidate ;) http://dlang.org/phobos/std_path.html#.dirName You'll find many other path manipulation

Re: Remove filename from path

2014-09-24 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 10:35:29 UTC, Suliman wrote: I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if stripExtension would be your friend here. If you want

Re: Remove filename from path

2014-09-24 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 10:35:29 UTC, Suliman wrote: I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if strip doens't work that way. It simply removes

Re: Recursive function call

2014-09-24 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 10:57:27 UTC, Suliman wrote: string getFileName() { //чтобы было проще обрабатываемый файл будем хранить рядом с бинариком string filename = chomp(readln()); string path = getcwd(); writeln((path ~ \\ ~ filename)); if

Re: Remove filename from path

2014-09-24 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 24 September 2014 at 12:29:09 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 24 Sep 2014 12:21:40 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Unfortunately, there is no generic function that allows striping of a specific ending range

Re: Local imports hide local symbols

2014-09-23 Thread monarch_dodra via Digitalmars-d
On Tuesday, 23 September 2014 at 19:18:08 UTC, H. S. Teoh via Digitalmars-d wrote: But this would cause a compile error: mod.d module mod; string x, y; main.d void main() { int x, y, z; import mod;

Re: Local imports hide local symbols

2014-09-23 Thread monarch_dodra via Digitalmars-d
On Tuesday, 23 September 2014 at 20:10:35 UTC, H. S. Teoh via Digitalmars-d wrote: Sounds reasonable. How would that be implemented, though? Currently, in the compiler, lookup is implemented via a linked list of Scope objects that contain, among other things, a symbol table for the symbols

Re: put string[] into a appender without loop?

2014-09-22 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 21 September 2014 at 23:50:50 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Sun, Sep 21, 2014 at 11:41:56PM +, AsmMan via Digitalmars-d-learn wrote: I'd like to copy an array string into a appender!string() but I can't see how to do this without loop myself over the string

Re: can't understand why code do not working

2014-09-22 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 22 September 2014 at 20:37:42 UTC, Cliff wrote: Is stdout threadsafe? Yes. All io operations lock in D, so are thread safe. You will never have interlaced io. If you want to do several opeations, then you can use LockingTextWriter, which is faster, s it locks once until you are

Re: can't understand why code do not working

2014-09-22 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 22 September 2014 at 21:19:37 UTC, Steven Schveighoffer wrote: On 9/22/14 4:37 PM, Cliff wrote: Is stdout threadsafe? Yes, stdout is thread safe, it's based on C's stdout which is thread safe. -Steve Techinallly, though thread safe, concurrent writes will create garbled

Re: can't understand why code do not working

2014-09-22 Thread monarch_dodra via Digitalmars-d-learn
On Monday, 22 September 2014 at 20:12:28 UTC, Suliman wrote: std.concurrency.OwnerTerminated@std\concurrency.d(234): Owner terminated You need to make sure your main waits for its workers before exiting. When main dies, it sends an exception message to anyone still working.

Re: destroy(someStruct)

2014-09-21 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 20 September 2014 at 22:46:10 UTC, John Colvin wrote: import core.stdc.stdio; struct S { ~this() { printf(%x\n.ptr, this); } } void main() { S* sp = new S; destroy(*sp); S s; destroy(s); auto sa = new

Re: What are the worst parts of D?

2014-09-20 Thread monarch_dodra via Digitalmars-d
On Saturday, 20 September 2014 at 16:54:08 UTC, Andrei Alexandrescu wrote: On 9/20/14, 7:42 AM, Tofu Ninja wrote: On Saturday, 20 September 2014 at 12:39:23 UTC, Tofu Ninja wrote: What do you think are the worst parts of D? Oh another bad part of D is the attribute names with some being

Re: Example of the perils of binding rvalues to const ref

2014-09-18 Thread monarch_dodra via Digitalmars-d
On Thursday, 18 September 2014 at 00:53:40 UTC, Andrei Alexandrescu wrote: On 9/17/14, 12:28 PM, IgorStepanov wrote: I want to place Foo(1) to buckets[nn].key without postblit call. Compiler can't help me now, however, I think, It can do it without language change. File an enhancement

  1   2   3   4   >