Re: literate programming in D

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Sat, Aug 30, 2014 at 1:37 AM, nikki wrote: I wasn't too happy about it and I wrote my own little parse thingie and have a literate version nice and meta and small and sloppy ;) http://nikkikoole.github.io/docs/dokidokDOC.html I use it to change my d sourcefile slightly (into valid

Re: literate programming in D

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Friday, 29 August 2014 at 23:58:19 UTC, Chris Cain wrote: I used https://www.npmjs.org/package/literate-programming (+ pandoc) to do this when writing https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf in markdown. Do you remember if some snippets can be hidden in the final

accessing memory from address

2014-08-30 Thread bojoe via Digitalmars-d-learn
I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call ReadProcessMemory at that location?

Re: accessing memory from address

2014-08-30 Thread Rikki Cattermole via Digitalmars-d-learn
On 31/08/2014 1:41 a.m., bojoe wrote: I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call ReadProcessMemory at that

Re: accessing memory from address

2014-08-30 Thread bojoe via Digitalmars-d-learn
On Saturday, 30 August 2014 at 13:41:27 UTC, bojoe wrote: I am interfacing with a dll that returns a pointer to an int. In python, I can use from_address: shape=list((c_int*rank).from_address(pi[2].contents.value)) Is there something equivalent in d? Or do I need to manually call

Re: Strange segfault (Derelict/OpenGL)

2014-08-30 Thread Robin Schroer via Digitalmars-d-learn
On Friday, 29 August 2014 at 15:20:00 UTC, Mike Parker wrote: As the README in Derelict 3 points out, that project is no longer updated. You should be using the binding from the DerelictOrg project [1] for anything new. [1] https://github.com/DerelictOrg/ stitch On 8/29/2014 9:16 PM,

Why is rehash not @safe?

2014-08-30 Thread Nordlöw
I just noticed that AA rehash is @system. Is there a reason for this? Is it system because bad things can happen or simply because it's a low level function? Should I always tag functions calling rehash as @trusted?

Re: Strange segfault (Derelict/OpenGL)

2014-08-30 Thread Mike Parker via Digitalmars-d-learn
On 8/30/2014 11:12 PM, Robin Schroer wrote: Some code would be helpful. My first thought is that you aren't loading properly. DerelictGL3 does not load deprecated functions, but you're trying to call a deprecated function. Are you loading DerelictGL or DerelictGL3? So, I dug around a lot. I

Re: Why is rehash not @safe?

2014-08-30 Thread Orvid King via Digitalmars-d-learn
On 8/30/2014 9:27 AM, Nordlöw wrote: I just noticed that AA rehash is @system. Is there a reason for this? Is it system because bad things can happen or simply because it's a low level function? Should I always tag functions calling rehash as @trusted? Rehash itself would have to be marked

Re: Why is rehash not @safe?

2014-08-30 Thread Nordlöw
On Saturday, 30 August 2014 at 14:55:19 UTC, Orvid King wrote: Rehash itself would have to be marked @trusted rather than @safe if anything. I agree, that would be more in line with my understanding of when to use @trusted---when a function is safe but it can't be proven through the

Re: Why is rehash not @safe?

2014-08-30 Thread Nordlöw
On Saturday, 30 August 2014 at 15:32:36 UTC, Nordlöw wrote: I agree, that would be more in line with my understanding of when to use @trusted---when a function is safe but it can't be proven through the type-system. Should I change it to @trusted in a PR?

Re: Why is rehash not @safe?

2014-08-30 Thread ketmar via Digitalmars-d-learn
On Sat, 30 Aug 2014 15:36:12 + Nordlöw via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Should I change it to @trusted in a PR? i think it would be good. it's the way it works. there are some places where such flags aren't set in druntime, and we should clean that up one by

getting the adress of a function by its name in string format

2014-08-30 Thread nikki via Digitalmars-d-learn
I would like to use json/or any other format for defining behavior trees. in that file format I can only use strings currently I just use the symbol directly but I was wondering how to 'find' them otherwise. float EAT_FOOD_DECISION(Agent agent){ return 1.0 - agent.hunger; } bool

Re: getting the adress of a function by its name in string format

2014-08-30 Thread Philippe Sigaud via Digitalmars-d-learn
instead I would like to use EAT_FOOD_DECISION and EAT_FOOD_BEHAVIOUR and get the functions? Is that possible somehow? If all your functions had the same signature, you could use an associative array FunctionType[string] and initialize it: FunctionType[string] myFuncs;

D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed with several 'core.exception.InvalidMemoryOperationError's. My questions: 1. Are there any special considerations

Re: getting the adress of a function by its name in string format

2014-08-30 Thread nikki via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:08:30 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: instead I would like to use EAT_FOOD_DECISION and EAT_FOOD_BEHAVIOUR and get the functions? Is that possible somehow? If all your functions had the same signature, you could use an associative array

Re: Why is rehash not @safe?

2014-08-30 Thread monarch_dodra via Digitalmars-d-learn
On Saturday, 30 August 2014 at 14:27:04 UTC, Nordlöw wrote: I just noticed that AA rehash is @system. Is there a reason for this? Is it system because bad things can happen or simply because it's a low level function? Should I always tag functions calling rehash as @trusted? AFAIK, the whole

Re: D daemon GC?

2014-08-30 Thread safety0ff via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed with several 'core.exception.InvalidMemoryOperationError's.

Re: D daemon GC?

2014-08-30 Thread Dicebot via Digitalmars-d-learn
I had similar issues. Thing is D compiler places runtime cleanup initialization code into binary constructor sections (fini_array) which is needed to support shared libraries properly. But the same code gets triggered when you run `exit` in a fork resulting in attempt to terminate other

Re: Why is rehash not @safe?

2014-08-30 Thread Nordlöw
On Saturday, 30 August 2014 at 17:31:54 UTC, monarch_dodra wrote: Really, it's lose-lose. The only (AFAIK) solution is to migrate AA's to a template-library that individually infers the correct safety for every types. Isn't there anyway to say that rehash() should infer safeness from

Re: D daemon GC?

2014-08-30 Thread via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:36:41 UTC, safety0ff wrote: On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, I tried to write a Linux daemon in D 2.065 (by translating one in C we use at work). My basic skeleton works well. But as soon as I start allocating memory it crashed

Re: Why is rehash not @safe?

2014-08-30 Thread via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:31:54 UTC, monarch_dodra wrote: On Saturday, 30 August 2014 at 14:27:04 UTC, Nordlöw wrote: I just noticed that AA rehash is @system. Is there a reason for this? Is it system because bad things can happen or simply because it's a low level function? Should I

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
Oops, I accidentally commented out the line allocating the memory in the example code... sorry. // this statement causes core.exception.InvalidMemoryOperationError // auto t = new char[4096]; should read: // this statement causes core.exception.InvalidMemoryOperationError

Re: literate programming in D

2014-08-30 Thread Chris Cain via Digitalmars-d-learn
On Saturday, 30 August 2014 at 07:33:38 UTC, Philippe Sigaud wrote: On Friday, 29 August 2014 at 23:58:19 UTC, Chris Cain wrote: I used https://www.npmjs.org/package/literate-programming (+ pandoc) to do this when writing https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf in

Re: D daemon GC?

2014-08-30 Thread Israel via Digitalmars-d-learn
On Saturday, 30 August 2014 at 17:09:41 UTC, JD wrote: Hi all, Or is there a safe D exit()? I always wondered why D doesnt have this. I tried searching google and could not find a definitive answer except interfacing with C...

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
I can already say that it nevertheless works with DMD git. Will test soon with Digger, unfortunately Bitbucket is currently down, and Digger depends on it. In the meantime I installed DMD 2.066 and I changed the exit() function after the fork as Dicebot suggested. Unfortunately I got the

Re: D daemon GC?

2014-08-30 Thread ketmar via Digitalmars-d-learn
On Sat, 30 Aug 2014 19:20:44 + Israel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Or is there a safe D exit()? I always wondered why D doesnt have this. the idiomatic way is to throw an exception which can be catched in main() (and then we can `return 1` from main() or

Re: D daemon GC?

2014-08-30 Thread via Digitalmars-d-learn
On Saturday, 30 August 2014 at 19:20:39 UTC, JD wrote: I can already say that it nevertheless works with DMD git. Will test soon with Digger, unfortunately Bitbucket is currently down, and Digger depends on it. In the meantime I installed DMD 2.066 and I changed the exit() function after the

Re: D daemon GC?

2014-08-30 Thread JD via Digitalmars-d-learn
I tested it again, and it works fine in both 2.065 and 2.066. Be aware that you should comment out: // close(STDOUT_FILENO); // close(STDERR_FILENO); A daemon normally detaches itself from the terminal by closing the STD* files. All D's runtime exception messages will not appear in

Re: Why is rehash not @safe?

2014-08-30 Thread Nordlöw
On Saturday, 30 August 2014 at 18:16:37 UTC, Marc Schütz wrote: This means that _aaRehash() can probably marked as @trusted; rehash() will then be automatically inferred as @safe, because it's a set of templates. https://github.com/D-Programming-Language/druntime/pull/942

Re: D daemon GC?

2014-08-30 Thread Dicebot via Digitalmars-d-learn
On Saturday, 30 August 2014 at 19:52:24 UTC, JD wrote: I tested it again, and it works fine in both 2.065 and 2.066. Be aware that you should comment out: // close(STDOUT_FILENO); // close(STDERR_FILENO); A daemon normally detaches itself from the terminal by closing the STD*

Re: D1: Error: duplicate union initialization for size

2014-08-30 Thread jicman via Digitalmars-d-learn
On Thursday, 28 August 2014 at 06:17:13 UTC, Jacob Carlborg wrote: On 27/08/14 23:48, jicman wrote: On Wednesday, 27 August 2014 at 06:20:24 UTC, Jacob Carlborg wrote: On 23/08/14 19:50, jicman wrote: This is line 7634: const Size DEFAULT_SCALE = { 5, 13 }; What does the error say and how

Re: D1: Error: duplicate union initialization for size

2014-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2014 06:05 PM, jicman wrote: Really is or how one can fix it? This is the only time that I have found myself without answers with D. Strange. Maybe folks are not that into D1, but D1 was before D2. Any thoughts would be greatly appreciated. Even from Walter. :-) Thanks. I

Re: D1: Error: duplicate union initialization for size

2014-08-30 Thread Dicebot via Digitalmars-d-learn
On Sunday, 31 August 2014 at 02:53:35 UTC, Ali Çehreli wrote: On 08/30/2014 06:05 PM, jicman wrote: Really is or how one can fix it? This is the only time that I have found myself without answers with D. Strange. Maybe folks are not that into D1, but D1 was before D2. Any thoughts would

Re: tried to use wstring in my terminal and see what happened.

2014-08-30 Thread Vladimir Panteleev via Digitalmars-d-learn
On Friday, 29 August 2014 at 22:01:58 UTC, Cassio Butrico wrote: Anyone help me... I am using the version for the windows dmd v 2.066 to last I believe. tried to use wstring in my terminal and see what happened. name = cast(wstring)chomp(readln()); This line is incorrect. You are

Re: I can ask questions about dmd on windows here in this forum?

2014-08-30 Thread Vladimir Panteleev via Digitalmars-d-learn
On Sunday, 31 August 2014 at 03:16:38 UTC, Cassio Butrico wrote: I'm new to this language, and I wonder if I will have some support simple questions. Thank you for your attention. Yes.

I can ask questions about dmd on windows here in this forum?

2014-08-30 Thread Cassio Butrico via Digitalmars-d-learn
I'm new to this language, and I wonder if I will have some support simple questions. Thank you for your attention.

Re: I can ask questions about dmd on windows here in this forum?

2014-08-30 Thread Cassio Butrico via Digitalmars-d-learn
On Sunday, 31 August 2014 at 03:20:00 UTC, Vladimir Panteleev wrote: On Sunday, 31 August 2014 at 03:16:38 UTC, Cassio Butrico wrote: I'm new to this language, and I wonder if I will have some support simple questions. Thank you for your attention. Yes. My question is about wstring and

Re: tried to use wstring in my terminal and see what happened.

2014-08-30 Thread Cassio Butrico via Digitalmars-d-learn
On Sunday, 31 August 2014 at 03:18:57 UTC, Vladimir Panteleev wrote: On Friday, 29 August 2014 at 22:01:58 UTC, Cassio Butrico wrote: Anyone help me... I am using the version for the windows dmd v 2.066 to last I believe. tried to use wstring in my terminal and see what happened. name =

Re: I can ask questions about dmd on windows here in this forum?

2014-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2014 08:37 PM, Cassio Butrico wrote: My question is about wstring and dstring, which and the best way to input data, converting and which should I use Unless there is a specific reason not to, use 'string'. When you really need random access to characters, then use 'dstring'. To

Re: I can ask questions about dmd on windows here in this forum?

2014-08-30 Thread Cassio Butrico via Digitalmars-d-learn
On Sunday, 31 August 2014 at 05:27:15 UTC, Ali Çehreli wrote: On 08/30/2014 08:37 PM, Cassio Butrico wrote: My question is about wstring and dstring, which and the best way to input data, converting and which should I use Unless there is a specific reason not to, use 'string'. When you

How to build dlang.org dd files

2014-08-30 Thread Mike via Digitalmars-d-learn
I've been trying to update some documentation on dlang.org. The instructions at https://github.com/D-Programming-Language/dlang.org/blob/master/CONTRIBUTING.md say I should be able to do make -f posix.make file.html This doesn't seem to work, as I get no rule t omake target 'file.html'.