Re: Inner struct accessing host member

2014-08-05 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 20:32:08 UTC, Philippe Sigaud wrote: But the compiler tells me 'need this for i of type int[]'. Is there any way I can gain access on i inside B? Been thinking about this a bit. I know some of my relies are in the 2012 fourm posts regarding it, but access

Re: unittest affects next unittest

2014-08-05 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 17:41:06 UTC, Marc Schütz wrote: It's a consequence of the fact that every type in D has a default initializer which is known at compile time. Then doesn't this mean it should pop out a warning in case that's the behavior you wanted, perhaps a reference to the D

Re: Inner struct accessing host member

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 05:53:55 UTC, Philippe Sigaud wrote: I see. I didn't know one could create an A.B 'outside'. I saw inner types as Voldemort types, but that is true only for inner structs in functions. But we weren't creating them, we were copying them, no constructors were

Re: unittest affects next unittest

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 17:42:02 UTC, Jonathan M Davis wrote: It wouldn't make sense to warn about that, because it could be very legitimately be what the programmer wants to do. We can't warn about anything that would be legitimate to have, because it would force programmers to change

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
(Moved from: What have I missed?) If this is the wrong place to ask these questions I apologize, getting back into this takes some work. So I guess I need to ask: Should I try to resume work on the BitManip library? (So far it seems none of my code has been integrated to phobos)

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 01:51:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Since this is about contributing to Phobos, probably a better place to ask is on the main D forum. Yeah posted in my 'what have i missed?' as well... Do you have a pull request? Which one is it?

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 02:04:13 UTC, Era Scarecrow wrote: On Thursday, 7 August 2014 at 01:51:46 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Do you have a pull request? Which one is it? https://github.com/rtcvb32/phobos/pull/1 From the looks of things it's 4 commits that are merged

Re: BitArray/BitFields - Review

2014-08-06 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 02:12:20 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Hold on a sec... that's a pull for your own fork of Phobos. You need to submit a pull to the main Phobos repo in order to get it reviewed and merged. :-) Well, no wonder, your pull was submitted against

Re: CSV Data to Binary File

2014-08-07 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 15:11:48 UTC, TJB wrote: Here is a snippet of my csv data: 34220, 37, 371200, 1, 1, 12, N, 34220, 369000, 372500, 1, 11, 12, P, 34220, 37, 371200, 1, 2, 12, N, I can't help but think somehow that as long as the data is numbers or words, that scanf would

Re: Struct alignment vs alignment of fields

2014-08-07 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 7 August 2014 at 17:22:15 UTC, Marc Schütz wrote: (Original discussion: http://forum.dlang.org/thread/fckwpddiwxonabqaf...@forum.dlang.org#post-pskjgieddhpntzaokohj:40forum.dlang.org) I would expect `B` to have a gap between `ex` and `mmid`. AFAIK the outer `align(1)` only

Re: Struct alignment vs alignment of fields

2014-08-07 Thread Era Scarecrow via Digitalmars-d-learn
Still watching this, but the Dconf 2014 bare metal presentation gets into it a bit... http://youtu.be/qErXPomAWYI?t=37m20s

Re: 'with(Foo):' not allowed, why?

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
I've given my thoughts on the D section. It would be heavily useful as a shorthand for enums you plan on using a lot in a switch case or something, beyond that it could be troublesome...

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 18:58:50 UTC, Jonathan M Davis wrote: No overloaded operators in D can be put outside of a struct or class. They have to be member functions. If I remember right, opApply was somewhat broken and only worked correctly in a few cases. But that was 18 months ago, a

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 21:57:29 UTC, Jonathan M Davis wrote: I'm not aware of opApply being broken, but I never use it, I remember very specifically it was brought up, that opApply was not working correctly and you could only use it with a very specific cases because... the

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 22:03:28 UTC, Era Scarecrow wrote: I remember very specifically it was brought up, On Wed, Jul 09, 2014 at 03:16:37PM -0700, H. S. Teoh via Digitalmars-d wrote: Judging from this, a big missing piece of the current implementation is the actual enforcement of

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 11 August 2014 at 02:03:15 UTC, Jonathan M Davis wrote: IIRC, opApply doesn't play well with various attributes, but I don't remember the details. That's the only issue with opApply that I'm aware of. It looks like you'll have to go digging into those other threads if you want to

Re: Sorting algorithms

2014-08-12 Thread Era Scarecrow via Digitalmars-d-learn
Rewatching lectures... And a thought came to me. Most sorting algorithms work with handling one element at a time; Although you may do a binary tree to sort getting NlogN, the optimal number of compares is still out of reach due to the number of extra compares done. However to build a

Re: Why I can't catch the exception?

2016-06-05 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 5 June 2016 at 18:15:47 UTC, Adam D. Ruppe wrote: On Sunday, 5 June 2016 at 18:02:12 UTC, Suliman wrote: I really can't understand why try-catch block do not handle exception. digit 1 is printing, so exception is accrue after it, but why nothing in catch block?

Re: Gotchas for returning values from blocks

2016-06-12 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 12 June 2016 at 18:24:58 UTC, jmh530 wrote: I'm just not sure if there are any gotchas to be aware of. Aside from forgetting it's it's own block, you might add a return statement to it and leave the entire function. Or forget what's in what scope (assuming you do more than 1-2

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-03 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 4 June 2016 at 01:44:38 UTC, ZILtoid1991 wrote: Problem solved. Current assembly code: //moving the values to their destinations mov EBX, p[EBP]; movdMM0, src; movdMM1, [EBX]; The actual problem was the poor documentation of MMX instructions as it never really

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? Is there a way to rangify a tuple? The tuple is identified/used at compile-time, as

Re: asm woes...

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:22:49 UTC, Guillaume Piolat wrote: You have to write your code three times, one for version(D_InlineAsm_X86) version (D_InlineAsm_X86_64) and a version without assembly. Rather than make a new thread I wonder if struct inheritance wouldn't solve this, as trying

Re: asm woes...

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 10:10:19 UTC, ZombineDev wrote: The great thing about D's UFCS is that it allows exactly that: Also, you can implement inc() in terms of ulong[2] - void inc(ref ulong[2] w), which makes it applicable for other types, with the same memory representation. E.g. cent

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote: Is there any way around this? Any way to declare a function @trusted as long as the methods of the template argument are at least @trusted? Thank you in advance. Use traits.. https://dlang.org/phobos/std_traits.html#isSafe

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote: On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote: auto doSomethingDumb(T)(ref T t) if(isSafe!(T)) The problem is that T is a type, and I should check for safety of every method of T that I'm using in my

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote: auto doSomethingDumb(T)(ref T t) if(isSafe!(T)) Should also probably test for a function or delegate. So...? auto doSomethingDumb(T)(ref T t) if(isSafe!T && (isFunctionPointer!T || isDelegate!T)) { T* pt =

Re: Fibers, what for?

2016-06-11 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 12 June 2016 at 02:43:40 UTC, Patric Dexheimer wrote: I learned about Fibers on D, and now I´m starting to read about it (Threads/Fibers/Coroutines) etc. But when I try to make something usefull with it I just fail to see the real advantage over a normal structured programming

Re: nested inout return type

2016-06-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 19:48:06 UTC, Steven Schveighoffer wrote: I honestly think the best place to go figure these things out is stackoverflow (or just the internet in general). Whenever I have a technical problem I can't figure out (or am too lazy to diagnose myself), I search and SO

Re: nested inout return type

2016-06-14 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 14 June 2016 at 14:47:11 UTC, Steven Schveighoffer wrote: On Tuesday, 14 June 2016 at 01:50:17 UTC, Era Scarecrow wrote: return cast(inout(Slice)) Slice(cast(T*)ptr+a, b-a); Better: inout(Slice)(ptr+a, b-a); Of course... My amateur D-fu skills show themselves. cast()

Re: Gotchas for returning values from blocks

2016-06-13 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 13 June 2016 at 14:16:58 UTC, jmh530 wrote: So returning a reference to something on the stack is a bad idea, but copying the value would be fine. This is easy enough to get wrong elsewhere too. I recall having an issue with a foreach, until I added a 'ref' to it. Looking at the

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 14:54:13 UTC, Era Scarecrow wrote: Well here's what i got. Maybe someone else will tell me how i did this wrong... Using the pragma to output how the lines were being generated i finally figured out why it kept complaining about the stack pointer and 'this'. So

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote: On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote: Do you still want the template i'm building? Thank you very much for your effort. Please if you don't need it, don't make it, because I don't know if I'll use

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote: On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote: Do you still want the template i'm building? Thank you very much for your effort. Please if you don't need it, don't make it, because I don't know if I'll use

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote: The only problem is that these structures are parameterized, and the type parameters may have unsafe operations that I use. Do you still want the template i'm building? It doesn't like stack frame pointers, but will work with

asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
Well decided I should dig my hand in assembly just to see if it would work. Using wideint.d as a starting point I thought I would do the simplest operation I could do, an increment. https://github.com/d-gamedev-team/gfm/blob/master/integers/gfm/integers/wideint.d

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote: The problem is that T is a type, and I should check for safety of every method of T that I'm using in my function. This does not scale well, and if I change the body of the function to use a new method, I may forget to add it

Re: @trusting generic functions

2016-05-28 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote: On Saturday, 28 May 2016 at 13:03:10 UTC, Adam D. Ruppe wrote: What kind of pointer usage do you have? Remember that basic & and * operations ARE @safe. If you have more internally, you might be able to wrap them up in an

Re: asm woes...

2016-05-31 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 31 May 2016 at 18:52:16 UTC, Marco Leise wrote: The 'this' pointer is usually in some register already. On Linux 32-bit for example it is in EAX, on Linux 64-bit is in RDI. The AX register seems like a bad choice, since you require the AX/DX registers when you do multiplication

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:22:49 UTC, Guillaume Piolat wrote: On Friday, 27 May 2016 at 09:11:01 UTC, Era Scarecrow wrote: Hmmm it just occurs to me I made a big assumption. I assumed that if the CPU supports 64bit operations, that it would be compiled to use 64bit registers when possible.

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:39:36 UTC, Era Scarecrow wrote: I suppose there's the requirement to have a register pointing to this, which then would be mov EAX, this, and then add lo[EAX], 1... Nope, still hangs...

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 10:00:40 UTC, Era Scarecrow wrote: On Friday, 27 May 2016 at 09:51:56 UTC, rikki cattermole wrote: struct Foo { int x; void foobar() { asm { mov EAX, this; inc [EAX+Foo.x.offsetof]; } } } You have to reference the field via a register.

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 08:20:02 UTC, Era Scarecrow wrote: Anyone with inline assembly experience who can help me out a little? 2 add instructions shouldn't cause it to hang... Hmmm it just occurs to me I made a big assumption. I assumed that if the CPU supports 64bit operations, that it

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 10:14:31 UTC, Era Scarecrow wrote: inc dword ptr [EAX+Foo.x.offsetof]; So just tested it, and it didn't hang, meaning all unittests also passed. Final solution is: asm pure @nogc nothrow { mov EAX, this; add dword ptr [EAX+wideIntImpl.lo.offsetof],

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:51:36 UTC, Guillaume Piolat wrote: On Friday, 27 May 2016 at 09:44:47 UTC, Era Scarecrow wrote: Nope, still hangs... We can't know why your code hangs if you don't post any code. Considering I'd have to include the whole of wideint.d, that is highly

Re: asm woes...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:51:56 UTC, rikki cattermole wrote: Me and p0nce solved this on IRC. struct Foo { int x; void foobar() { asm { mov EAX, this; inc [EAX+Foo.x.offsetof]; } } } void main() { import std.stdio; Foo foo = Foo(8); foo.foobar;

Re: Testing array ptr for offset 0...

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 09:18:47 UTC, Marc Schütz wrote: You can do that with arrays, too, without causing allocations: assert(slice.length < static_array.length); slice = slice.ptr[0 .. slice.length+1]; Of course that's unsafe, but your pointer magic certainly is, too. Initial

Re: opCall override default constructor?

2016-06-02 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 2 June 2016 at 08:50:26 UTC, Jacob Carlborg wrote: Is it intentional that a non-static opCall overrides the default constructor of a struct? auto f = Foo(3); // line 14 main.d(14): Error: function main.Foo.opCall (string b) is not callable using argument types (int) It

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-02 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 2 June 2016 at 13:32:51 UTC, ZILtoid1991 wrote: On Thursday, 2 June 2016 at 07:17:23 UTC, Johan Engelen wrote: Could you also paste the D version of your code? Perhaps the compiler (LDC, GDC) will generate similarly vectorized code that is inlinable, etc. ubyte[4] dest2 = *p;

Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
So I'm experimenting and want to override how arrays are managed for a short duration, this is for optimization of not having to make another array to keep track of lengths and then shorten them when i can in fact just manage it myself *very* briefly. So, I need to make sure the structure

Re: import in mixin template

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 05:20:25 UTC, vitus wrote: Why 'alias wln1 = writeln;' doesnt't work but 'alias wln2 = std.stdio.writeln;' work when import is not static? Why 'wln2("test");' work but 'std.stdio.writeln("test");' doesn't? (changing import to static import doesn't change anything)

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 11:47:13 UTC, ag0aep6g wrote: I don't follow. Why can't you use a built-in array? What can you do with the stand-in that you can't do with the array itself? I can do the job with the built-in arrays, however the need for another temporary array to keep track of

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 22:15:42 UTC, ag0aep6g wrote: On 05/26/2016 11:13 PM, Era Scarecrow wrote: void scan(ref Data[][] data, Condition cond) { foreach(i; ...) { if (cond) data[i] ~= ... } } Sorry, I'm still lost. Why can't you do whatever you're doing

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 12:33:31 UTC, Adam D. Ruppe wrote: On Thursday, 26 May 2016 at 12:30:30 UTC, Alex Parrill wrote: The line "not having to make another array to keep track of lengths and then shorten them" is fairly vague. "Shortening" an array via slicing is basically free (it's

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 09:16:48 UTC, Kagamin wrote: try this: struct X { byte[] data; alias data this; } This doesn't help me with what I want, and effectively does nothing as far as I can tell. Although testing is showing managing the pointer & length directly is a

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 2 June 2016 at 00:52:48 UTC, ZILtoid1991 wrote: On Thursday, 2 June 2016 at 00:51:15 UTC, ZILtoid1991 wrote: I could get the code working with a bug after replacing pmulhuw with pmullw, but due to integer overflow I get a glitched image. I try to get around the fact that pmulhuw

Re: Can I get a more in-depth guide about the inline assembler?

2016-06-01 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 1 June 2016 at 23:23:49 UTC, ZILtoid1991 wrote: After some debugging, I found out that the p pointer becomes null at the end instead of pointing to a value. I have no experience with using in-line assemblers (although I made a few Hello World programs for MS-Dos with a

Re: Why simple code using Rebindable doesn't compile ?

2016-05-31 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 31 May 2016 at 05:31:59 UTC, chmike wrote: My conclusion is that rebindable is not a satisfying solution to have mutable references to immutable objects. I don't understand the rationale of these immutable references. It is too constraining. I still don't know why you're trying

Re: Read registry keys recursively

2016-05-29 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 29 May 2016 at 15:48:49 UTC, TheDGuy wrote: Hello, i am wondering what is wrong with my code: import std.windows.registry; import std.stdio; void main(){ Key lclM = Registry.localMachine(); Key hrdw = lclM.getKey("HARDWARE"); writeRegistryKeys(hrdw); } void

Re: Read registry keys recursively

2016-05-29 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 29 May 2016 at 16:46:34 UTC, Era Scarecrow wrote: you should see the problem. Here's the correct line! writeRegistryKeys(k.getKey(key.name())); this just occurred to me i tried to keep to the example but i shouldn't have. Since you already have the inner key, just pass

Re: is my code to get CTFE instantiated object valid D ?

2016-05-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 May 2016 at 20:20:36 UTC, chmike wrote: The public interface of Category is designed so that the object's state can't be modified and thus remains immutable. Then... why cast away immutable? I suppose there's always a core set of variables that are what the object actually

Re: String compare in words?

2016-05-29 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 29 May 2016 at 17:38:17 UTC, Jonathan M Davis wrote: In what way are you trying to compare them? If all you're doing is comparing them for equality, then just use ==. e.g. if(str1 == str2) { } And if you're not simply comparing for equality, what are you looking to figure out?

Re: String compare in words?

2016-05-29 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 29 May 2016 at 17:13:49 UTC, qznc wrote: Given two string (or char[] or ubyte[]) objects, I want to compare them. The naive loop accesses the arrays byte-wise. How could I turn this into a word-wise compare for better performance? Is a cast into size_t[] ok? Some Phobos helper

Re: mutable keyword

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 19 May 2016 at 20:44:54 UTC, ciechowoj wrote: Is there D equivalent of C++'s mutable keyword? Like the one that allows to modify a field of struct from constant method. Or some alternative solution? A little personal experience. I wrote a tool that had certain flags that did

Re: Compile Tango for DMD2 - Any instructions how to do it?

2016-05-18 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 03:13:18 UTC, Mike Parker wrote: All of dsource.org is outdated. It's a long dead site, maintained now only in read-only mode because it still has some stuff worth keeping around. I remember trying to read through an in-depth manual to how to use Tango, and I

Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 20 May 2016 at 02:04:56 UTC, captaindet wrote: i am most curious about your solution. why does printAll() has a synchronized block? in case you would call it before thread_joinAll() i.e. before all threads are terminated? then again, why is there a synchronized block necessary in

Re: missing data with parallel and stdin

2016-05-23 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 23 May 2016 at 15:53:23 UTC, moechofe wrote: On Monday, 23 May 2016 at 14:16:13 UTC, Jack Stouffer wrote: Sounds like a data race problem. Use a lock on the file write operation and see if that helps. That didn't solve anything. What I observe is: when the process is slower, more

Proper way to write benchmark code...

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn
Is there a good article written for this? Preferably for D specifically... I notice as I'm working a bit with my challenge to make/update the symbol/id compressor that perhaps the GC is getting in the way and skewing the results. Means a number of what I've put up as benchmark values may

Re: Is there a 128-bit integer in D?

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 22 May 2016 at 12:03:16 UTC, Guillaume Piolat wrote: I don't know how this works, someone has to propose it, clean it up and respond to feedback I guess. Glancing briefly at the source, it appears (from what I saw) it's heavily based on doubling the size of a lower type (2 64's

Re: Basic question about stderr

2016-05-21 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:21:31 UTC, chaseratx wrote: I'm learning D and I have a basic question. I'm trying to write stderr to a file using open() (rather than shell piping/redirection). It works for stdout but doesn't seem to work with stderr. http://pastebin.com/KgzR9wAF stdout is

Linking C code with D...

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn
While trying to make a benchmark for comparing results of my possible compression replacement, I'm finding it quite difficult to link the c code with the d code. So I've managed to compile the compress.c file using dmc, but when I link the obj file to reference it I don't seem to see it...

Re: Linking C code with D...

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 22 May 2016 at 06:10:07 UTC, rikki cattermole wrote: Move id_compress out of the unittest block. Well that certainly did it...

Re: Basic question about stderr

2016-05-21 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range error. That was put there intentionally to create stderr output. I wonder, this sounds like a TLS (Thread Local Storage)

Re: Basic question about stderr

2016-05-21 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range error. That was put there intentionally to create stderr output. I'm trying to figure out how to get ALL stderr output directed to a file the same as if I had used a "2>error.log"

Re: Division - precision

2016-05-21 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:45:19 UTC, Rygel wrote: Hi there. I'm a beginners, so my questions could be silly. double x1 = 7.0; double x2 = 3.0; writeln(x1 / x2); this is ok but how can i get more digits? For example: 2.3. I'm not sure how to globally

Re: Is there a 128-bit integer in D?

2016-05-22 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 22 May 2016 at 09:39:45 UTC, Saurabh Das wrote: On Sunday, 22 May 2016 at 09:07:32 UTC, Guillaume Piolat wrote: https://github.com/d-gamedev-team/gfm/blob/master/integers/gfm/integers/wideint.d wideint was exactly what I was looking for! Thank you so much :) I WANT! If this does

Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 19 May 2016 at 19:31:26 UTC, Era Scarecrow wrote: An alternate to writing a custom appender is simply to make the assignment atomic. Haven't tried this but if you did 'shared string[] lines;' I'll experiment with this and get back with you. Multi-threading isn't my strong suit

Re: How to share an appender!string?

2016-05-19 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 19 May 2016 at 13:33:50 UTC, Thorsten Sommer wrote: Issue analysis: My main issue was that the main() does not waited for the new thread (I used spawn() before I opened this discussion). Thus, a simple thread_joinAll(); solved that. Since each thread can run at different times

Re: Reading ASCII file with some codes above 127 (exten ascii)

2016-05-15 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 24 May 2012 at 19:47:06 UTC, era scarecrow wrote: On Wednesday, 23 May 2012 at 21:02:27 UTC, Paul wrote: I wonder about the speed between this method and Era's home-spun solution? Who knows? Perhaps it will be added to phobos once the table is verified. Well after taking to

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 12:06:58 UTC, Adam D. Ruppe wrote: Slicing and indexing are both allowed (actually, that's a way to disable bounds checking on an individual expression, see tip: http://arsdnet.net/this-week-in-d/dec-06.html ) on pointers, though it isn't considered @safe. Be

Re: Is there anything fundamentally wrong with this code?

2017-02-04 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 3 February 2017 at 18:37:15 UTC, Johan Engelen wrote: The error is in this line. Instead of assigning to the `postProc` at module scope, you are defining a new local variable and assigning to it. Wasn't the compiler suppose to warn you when you are shadowing another variable? Or

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-26 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 11:40:15 UTC, Nestor wrote: Thanks, but unfortunately this function does not produce proper UTF8 strings, as a matter of fact the output even starts with the BOM. Also it doesn't handle CRLF, and even for LF terminated lines it doesn't seem to work for lines

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 January 2017 at 07:02:52 UTC, Jack Applegame wrote: On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote: static char[1024*4] buffer; //4k reusable buffer, NOT thread safe Maybe I'm wrong, but I think it's thread safe. Because static mutable non-shared variables

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-21 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 21 February 2017 at 22:34:57 UTC, Chad Joan wrote: In this case the AA isn't actually coded into the executable; but at least the configuration from some_data.csv will be in the executable as a string. The program will construct the AA at startup. It's not as "cool", but it

Re: simple static if / traits question...

2017-02-22 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote: I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code build static if ( (__traits(compiles, audio)) && audio)

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 11 February 2017 at 20:19:51 UTC, Nestor wrote: Notice this is no ordinary matrix, but an Anti-Simmetric QuasiGroup of order 10, and tmpdigit (called interim in the algorithm) is used in each round (although the function isn't recursive) together with each digit to calculate final

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 11 February 2017 at 21:02:40 UTC, Era Scarecrow wrote: Yes i know, which is why i had 3 to calculate 2 inputs because the third is the temp/previous calculation. Alright I've found the bug and fixed it, and it passes with flying colors (brute force tests up to 6 digits);

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 11 February 2017 at 21:41:11 UTC, Era Scarecrow wrote: But it seriously is a lot of overhead for such a simple function. Just ran the unittests under the dmd profiler, says the algorithm is 11% faster now. So yeah slightly more optimized. Another level and we could probably

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 12 February 2017 at 00:43:55 UTC, Nestor wrote: I fail to see where you are declaring QG10Matrix2, because apparently it's an array of chars, but buildMatrix2 returns an array of int (2560 elements??) with lots of -1 values. I declared it here:

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 11 February 2017 at 21:56:54 UTC, Era Scarecrow wrote: Just ran the unittests under the dmd profiler, says the algorithm is 11% faster now. So yeah slightly more optimized. Ran some more tests. Without optimization but with with 4 levels (a 2.5Mb table), it gains to a whopping

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 9 February 2017 at 19:39:49 UTC, Nestor wrote: OK I changed the approach using a multidimensional array for the matrix so I could ditch arithmetic operations altogether, but curiously after measuring a few thousand runs of both implementations through avgtime, I see no noticeable

Re: Can this implementation of Damm algorithm be optimized?

2017-02-12 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 13 February 2017 at 00:56:37 UTC, Nestor wrote: On Sunday, 12 February 2017 at 05:54:34 UTC, Era Scarecrow wrote: Ran some more tests. Wow! Thanks for the interest and effort. Certainly. But the bulk of the answer comes down that the 2 levels that I've already provided are the

Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote: I was trying to port C code from the article in Wikiversity [1] to D, but I'm not sure this implementation is the most efficient way to do it in D, so suggestions to optimize it are welcome: import std.stdio; static immutable

Re: Can this implementation of Damm algorithm be optimized?

2017-02-11 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 10 February 2017 at 11:27:02 UTC, Nestor wrote: Thank you for the detailed reply. I wasn't able to follow you regarding the multilevel stuff though :( The idea behind it is like this (which you can scale up): static immutable int[] QG10Matrix2 = buildMatrix2(); int[]

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-16 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote: I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each iteration) without loading the entire file into memory? Could... roll your own? Although if you wanted it to be

Re: D1: zlib string to decode

2016-09-08 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 8 September 2016 at 16:19:44 UTC, jicman wrote: I have a zlib string that I want to decode. Anybody has any idea how to do that? I am trying to figure out what to send with a POST to create a new internal log and the person that created the form is no longer available, but I

Re: New to D

2016-10-27 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 27 October 2016 at 13:43:26 UTC, Steven Schveighoffer wrote: It depends on the size of the file and the expectation of duplicate words. I'm assuming the number of words is limited, so you are going to allocate far less data by duping on demand. In addition, you may incur penalties

Re: how to debug memory errors

2016-11-07 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 7 November 2016 at 02:22:35 UTC, Steven Schveighoffer wrote: OP: it's not legal to destroy or even access GC allocated members in a destructor. The GC may have already destroyed that data. I would recommend printing the stack trace when you get the exception, and figure out where

Re: typeof(SortedRange) and is operator

2016-11-08 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 8 November 2016 at 21:14:41 UTC, Jonathan M Davis wrote: No, as the others have point out, it's not a bug. If anything it's a language design flaw that no one has figured out how to resolve yet. The idea of a special struct for code that strips whitespace out, or a function that

Re: Sockets and using them...

2016-11-06 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 6 November 2016 at 09:51:41 UTC, sarn wrote: It sounds like you want to do the same thing: design a protocol that includes some kind of message that's agreed to mean, "Yo, make a new connection on this port." Basically, any off-the-shelf textbook on network protocol design will

  1   2   3   >