Re: shared not working!

2016-07-03 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Monday, 4 July 2016 at 05:08:34 UTC, ag0aep6g wrote: On 07/04/2016 01:20 AM, Hiemlick Hiemlicker wrote: I have thread. It locks up. If I changed from a bool val it is using from shared to __gshared it works. I checked the address inside and outside of the thread and they are different for

Commit size and Page fault's very large for simple program

2016-07-03 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
version(Windows) void main() { import std.random; while(getchar() != EOF) { auto x = new int[std.random.uniform(100, 1000)]; writeln(""); bThread.Now(); } } more or less, ends up with a huge

Re: shared not working!

2016-07-03 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Monday, 4 July 2016 at 01:36:00 UTC, Mike Parker wrote: On Sunday, 3 July 2016 at 23:20:35 UTC, Hiemlick Hiemlicker wrote: The only difference is that the thread is a windows CreateThread. I guess D doesn't know about such threads and hence shared doesn't extend across to them? The

Re: Bug in D type inferencing

2016-07-02 Thread Hiemlick Hiemlicker via Digitalmars-d
On Saturday, 2 July 2016 at 08:02:30 UTC, John Colvin wrote: On Saturday, 2 July 2016 at 01:20:35 UTC, Hiemlick Hiemlicker wrote: public struct Foo { public void Create(T)(uint delegate(T) c, T param) { } } Foo f; f.Create((x) { }, "asdf"); cannot deduce

Re: Thunking problems with arch issues

2016-07-02 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Saturday, 2 July 2016 at 01:51:03 UTC, rikki cattermole wrote: Couple of things could be happening. 1) Alignments are off, aligning of data really really matters Where? I rewrote the code to use size_t and same problem. If alignments were off chances are it wouldn't exhibit the issues in

Re: static __gshared struct

2016-07-02 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Saturday, 2 July 2016 at 03:54:26 UTC, Mike Parker wrote: On Saturday, 2 July 2016 at 00:08:10 UTC, Hiemlick Hiemlicker wrote: I use a struct with static members so I do not have to instantiate it. It is essentially a singleton. I want all the variables to be __gshared. I guess I have

Re: string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
On Saturday, 2 July 2016 at 00:29:45 UTC, Adam D. Ruppe wrote: On Saturday, 2 July 2016 at 00:05:14 UTC, Hiemlick Hiemlicker wrote: Is there a way to write a wrapper around such that mystring s = "a string that will be converted and not appear in binary"; writeln(s); You just need to put a

Re: Does D has any support for thunks?

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Saturday, 25 June 2016 at 17:52:48 UTC, Andre Pany wrote: On Saturday, 25 June 2016 at 17:26:03 UTC, Andre Pany wrote: On Saturday, 25 June 2016 at 16:05:30 UTC, Vladimir Panteleev wrote: On Saturday, 25 June 2016 at 13:44:48 UTC, Andre Pany wrote: Does D/Phobos has any support for thunks?

Thunking problems with arch issues

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
The following code works on dmd x64. Fails on dmd x32 and ldc x64. The problem is the passed variable. import std.stdio; version (Windows) { import core.sys.windows.windows; void makeExecutable(ubyte[] code) { DWORD old; VirtualProtect(code.ptr, code.length,

Re: string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
On Saturday, 2 July 2016 at 00:39:57 UTC, Basile B. wrote: On Saturday, 2 July 2016 at 00:05:14 UTC, Hiemlick Hiemlicker wrote: On Friday, 1 July 2016 at 23:55:08 UTC, Adam D. Ruppe wrote: On Friday, 1 July 2016 at 23:23:19 UTC, Hiemlick Hiemlicker wrote: I've tried playing with opCall,

Bug in D type inferencing

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
public struct Foo { public void Create(T)(uint delegate(T) c, T param) { } } Foo f; f.Create((x) { }, "asdf"); cannot deduce arguments compiler error. Surely D can figure out that T is a string? If one simply changes this to public struct Foo(T) {

Re: string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
On Friday, 1 July 2016 at 23:55:08 UTC, Adam D. Ruppe wrote: On Friday, 1 July 2016 at 23:23:19 UTC, Hiemlick Hiemlicker wrote: ok. For some reason I thought CTFE's applied to normal functions but I realize that doesn't make a lot of sense. It is applied to normal functions, just when they

Re: static __gshared struct

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Friday, 1 July 2016 at 23:36:35 UTC, Basile B. wrote: On Friday, 1 July 2016 at 23:26:19 UTC, Hiemlick Hiemlicker wrote: On Friday, 1 July 2016 at 23:03:17 UTC, Basile B. wrote: On Friday, 1 July 2016 at 22:47:21 UTC, Hiemlick Hiemlicker wrote: Ok, Does that mean void main() {

Re: static __gshared struct

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Friday, 1 July 2016 at 23:03:17 UTC, Basile B. wrote: On Friday, 1 July 2016 at 22:47:21 UTC, Hiemlick Hiemlicker wrote: what exactly does this do? are all members _gshared? In this case __gshared is a complete NOOP. __gshared has only an effect on variables. It prevents them to reside in

Re: string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
On Friday, 1 July 2016 at 22:56:48 UTC, Basile B. wrote: On Friday, 1 July 2016 at 22:23:23 UTC, Hiemlick Hiemlicker wrote: I know this is probably a lot to ask for an many won't see the point, but a secure program should not expose readable strings, it makes it far too easy for the attacker

Re: string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
On Friday, 1 July 2016 at 22:55:21 UTC, qznc wrote: On Friday, 1 July 2016 at 22:23:23 UTC, Hiemlick Hiemlicker wrote: It seems D won't replace encrypt("This string will still end up in the binary"); with "skadf2903jskdlfaos;e;fo;aisjdfja;soejfjjfjfjfjfjfeij" or whatever the ctfe value of

static __gshared struct

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
what exactly does this do? are all members _gshared?

string encryption

2016-07-01 Thread Hiemlick Hiemlicker via Digitalmars-d
I know this is probably a lot to ask for an many won't see the point, but a secure program should not expose readable strings, it makes it far too easy for the attacker to see what is going on. Is it possible to encrypt every static string in D and decrypt before it is output in an automatic

Re: stub out your gc without hacking on druntime

2016-06-29 Thread Hiemlick Hiemlicker via Digitalmars-d
On Tuesday, 11 June 2013 at 12:13:05 UTC, Adam D. Ruppe wrote: On Tuesday, 11 June 2013 at 03:08:36 UTC, H. S. Teoh wrote: [...] Yea, that's the idea here. Like Simen said, if these were errors, your program wouldn't even start, so noop is better. Though gc_init should call thread_init,

Re: IFTI in Eponymous Templates

2016-06-29 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Wednesday, 29 June 2016 at 18:59:19 UTC, jmh530 wrote: I was playing around with some Eponymous Templates. I had been under the impression that Implicit Function-Template Instantiation (IFTI) meant that you don't have to explicitly instantiate all functions. However, it seems like there are

Possible to Animate Program

2016-06-29 Thread Hiemlick Hiemlicker via Digitalmars-d
Is it possible to add a hook to every function call/delegate/lambda both start and end? What about the ability to essentially log a programs execution path, then "play it back" and only view the source code one is interested in along with the state at any moment in time. Similar to debugging

Re: Accessing types by context

2016-06-28 Thread Hiemlick Hiemlicker via Digitalmars-d
On Wednesday, 29 June 2016 at 04:34:26 UTC, Chang Long wrote: On Wednesday, 29 June 2016 at 03:11:52 UTC, Hiemlick Hiemlicker wrote: test(myEnum.A | myEnum.B & myEnum.C). I like this: myEnum.( A | B & C) == myEnum.A | myEnum.B & myEnum.C Does that even work? Regardless, You still have

Re: Accessing types by context

2016-06-28 Thread Hiemlick Hiemlicker via Digitalmars-d
On Wednesday, 29 June 2016 at 03:50:35 UTC, Carl Vogel wrote: On Wednesday, 29 June 2016 at 03:11:52 UTC, Hiemlick Hiemlicker wrote: Suppose one has void test(myEnum e) enum myEnum { A,B,C } [...] Doesn't the with statement solve your problem here? with (myEnum) { test(A); test(B);

Accessing types by context

2016-06-28 Thread Hiemlick Hiemlicker via Digitalmars-d
Suppose one has void test(myEnum e) enum myEnum { A,B,C } It would be very cool if we could do test(A) instead of test(myEnum.A). by context, the compiler can look first in the scope for something named A then look in the enum itself and prepend myEnum internally. For flags, it would

Re: core.stdc.stdlib.malloc & alignment

2016-06-28 Thread Hiemlick Hiemlicker via Digitalmars-d-learn
On Wednesday, 29 June 2016 at 02:24:55 UTC, captaindet wrote: is there an alignment guarantee for core.stdc.stdlib.malloc? more specifically, using DMD and compiling for 32bit on windows, can i assume proper alignment for int or uint variables? background: i like to re-use a (ubyte) buffer,

Rate based allocation strategies

2016-06-28 Thread Hiemlick Hiemlicker via Digitalmars-d
Many memory management routines allocate 2x the required capacity on overflow and and de-allocate when the array is 1/2 used. This method is inefficient and wastes up to 100% of the actually memory required, although some on average is is probably much lower than this. I am thinking it