Re: call stack tracing

2016-08-05 Thread Mark J Twain via Digitalmars-d-learn
On Saturday, 6 August 2016 at 01:44:04 UTC, Adam D. Ruppe wrote: On Saturday, 6 August 2016 at 01:29:37 UTC, Mark "J" Twain wrote: Of course, exceptions have TraceInfo... could that be used anywhere or hacked to get what I need? The function is defaultTraceHandler in druntime for what the

Re: D safety! New Feature?

2016-08-05 Thread Mark J Twain via Digitalmars-d
On Friday, 5 August 2016 at 21:12:06 UTC, ag0aep6g wrote: On 08/05/2016 09:39 PM, Mark J Twain wrote: In the case of ImmutableQueue, There is no Enqueue! See, there is a difference between "not callable" and "does not exists". Ok, but what cool stuff is enabled by "does not exist" that

call stack tracing

2016-08-05 Thread Mark J Twain via Digitalmars-d-learn
Any solution out there that can get call stack, file and line info? Similar to exceptions but I simply want to track memory allocations and need the complete call stack rather than just the previous call(using __FUNCTION__/__FILE__/etc), which is usually useless. Of course, exceptions have

Re: Get size of mem to free by free

2016-08-05 Thread Mark J Twain via Digitalmars-d-learn
On Friday, 5 August 2016 at 20:43:12 UTC, H.Loom wrote: On Friday, 5 August 2016 at 19:55:22 UTC, Mark "J" Twain wrote: [...] You can wrap the C memory allocations functions with a version identifier, e.g version(stat) { __gshared size_t[size_t] sizes; } version(stat) { auto

Get size of mem to free by free

2016-08-05 Thread Mark J Twain via Digitalmars-d-learn
I use malloc to allocate some memory, then free it later. For monitoring purposes, I would like to know how much is free'ed by free by just knowing the object. Or, rather, given a ptr allocated by malloc, bet the block size it allocated from the ptr alone. Some C compilers have special

Re: D safety! New Feature?

2016-08-05 Thread Mark J Twain via Digitalmars-d
On Thursday, 4 August 2016 at 18:58:18 UTC, ag0aep6g wrote: On 08/04/2016 08:22 PM, Mark J Twain wrote: The problem is that you have fixated on the *array* and not the general principle. The Array was an example. I'm having trouble understanding what you're getting at, so I'm trying to get

Re: vsprintf or printf variable arguments

2016-08-05 Thread Mark J Twain via Digitalmars-d-learn
On Friday, 5 August 2016 at 08:32:42 UTC, kink wrote: On Thursday, 4 August 2016 at 21:03:52 UTC, Mark "J" Twain [...] This has absolutely nothing to do with D as these are C functions, so you'd be better off asking this in another forum. Um, then I wonder why I am using D? Why does D even

Re: vsprintf or printf variable arguments

2016-08-04 Thread Mark J Twain via Digitalmars-d-learn
On Thursday, 4 August 2016 at 21:03:52 UTC, Mark "J" Twain wrote: How can I construct a va_list for vsprintf when all I have is the a list of pointers to the data, without their type info? A va_list seems to be a packed struct of values and/or pointers to the data. While I could construct

vsprintf or printf variable arguments

2016-08-04 Thread Mark J Twain via Digitalmars-d-learn
How can I construct a va_list for vsprintf when all I have is the a list of pointers to the data, without their type info? A va_list seems to be a packed struct of values and/or pointers to the data. While I could construct such a list, theoretically, I don't always know when I should store

Re: Self Optimizing Code

2016-08-04 Thread Mark J Twain via Digitalmars-d
On Thursday, 4 August 2016 at 11:35:41 UTC, crimaniak wrote: On Tuesday, 2 August 2016 at 22:06:38 UTC, Mark "J" Twain wrote: Instead, a better solution would be to use variables: if (n*length > m*capacity) expand(l*length) Some time ago I played with self-optimizing cache layer. Problem:

Re: Self Optimizing Code

2016-08-04 Thread Mark J Twain via Digitalmars-d
On Thursday, 4 August 2016 at 04:41:43 UTC, Chris Wright wrote: In your example, you have a size_t or double factor for array growth. If you set it to -1, you would have an unpleasant time. You need a way to specify the range of valid values. In more complex algorithms, you need a way to

Re: D safety! New Feature?

2016-08-04 Thread Mark J Twain via Digitalmars-d
On Thursday, 4 August 2016 at 13:08:11 UTC, ag0aep6g wrote: On 08/03/2016 09:33 PM, Mark J Twain wrote: The built in array is mutable and exposes the same interface for the immutable copy. The only difference is that the immutable copy is marked immutable. I don't understand. An immutable

Re: Self Optimizing Code

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Thursday, 4 August 2016 at 01:54:57 UTC, Chris Wright wrote: On Wed, 03 Aug 2016 21:09:46 +, ikod wrote: This is not just profiling, but "Profile-Guided Optimization (PGO)" The person is talking about algorithms with tuning parameters (like array growth rate when appending) adjusting

Re: Running a D game in the browser

2016-08-03 Thread Mark J Twain via Digitalmars-d-announce
On Wednesday, 3 August 2016 at 20:26:23 UTC, Sebastien Alaiwan wrote: Hi, I finally managed to compile some D code to asm.js, using Emscripten. It had been done by one dude several years ago, but some changes in the inner workings of Emscripten (the introduction of fastcomp, also probably

Re: Passing refs with delegates

2016-08-03 Thread Mark J Twain via Digitalmars-d-learn
On Wednesday, 3 August 2016 at 08:12:00 UTC, Ali Çehreli wrote: On 08/02/2016 07:55 PM, Mark J Twain wrote: [...] I didn't know one could use 'auto ref' in this case but the following simple test works: auto foo(Func, Args...)(Func callback, auto ref Args args) { return callback(args);

Re: Self Optimizing Code

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Wednesday, 3 August 2016 at 21:09:46 UTC, ikod wrote: On Wednesday, 3 August 2016 at 19:25:08 UTC, Mark "J" Twain wrote: On Wednesday, 3 August 2016 at 18:18:51 UTC, ikod wrote: On Tuesday, 2 August 2016 at 22:06:38 UTC, Mark "J" Twain wrote: Another new D feature here! Self-Optimizing

Re: D safety! New Feature?

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Wednesday, 3 August 2016 at 08:09:41 UTC, qznc wrote: On Tuesday, 2 August 2016 at 21:48:58 UTC, Mark Twain wrote: global ImmutableArray!int Data; MutableArray!int DataCopy = Data.Copy; // Creates a mutable copy of Data. ... Do work with DataCopy ... Data.Replace(DataCopy); // Makes a

Re: D safety! New Feature?

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Wednesday, 3 August 2016 at 05:44:42 UTC, ag0aep6g wrote: On 08/02/2016 11:48 PM, Mark Twain wrote: global ImmutableArray!int Data; MutableArray!int DataCopy = Data.Copy; // Creates a mutable copy of Data. ... Do work with DataCopy ... Data.Replace(DataCopy); // Makes a copy of DataCopy.

Re: Self Optimizing Code

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Wednesday, 3 August 2016 at 18:18:51 UTC, ikod wrote: On Tuesday, 2 August 2016 at 22:06:38 UTC, Mark "J" Twain wrote: Another new D feature here! Self-Optimizing Code is a fantastic research area that can lead to greater improvements in code, make them more responsive to individual

Re: Self Optimizing Code

2016-08-03 Thread Mark J Twain via Digitalmars-d
On Wednesday, 3 August 2016 at 07:36:21 UTC, ketmar wrote: hello, you just invented JIT compiler. Um, no. JIT = Just in time compilation. The code is already compiled and in binary form. The only differnece is that hard coded values = literals in the binary, become variables. There is no

Passing refs with delegates

2016-08-02 Thread Mark J Twain via Digitalmars-d-learn
It's nice to be able to pass delegates and functions as callbacks. A nice feature is something like R foo(R,Args...)(R function(Args) callback, Args args) { return callback(args); } There are two problems with this. One is that type deduction doesn't work. I have to explicitly specify the

Error flabergastation

2016-08-02 Thread Mark J Twain via Digitalmars-d-learn
winmain.d(40): Error: found 'while' when expecting ';' following statement winmain.d(40): Error: unexpected ( in declarator winmain.d(40): Error: basic type expected, not & winmain.d(40): Error: found '&' when expecting ')' winmain.d(40): Error: found 'msg' when expecting ')' winmain.d(40):

Re: Cannot compare object.opEquals is not nogc

2016-08-02 Thread Mark J Twain via Digitalmars-d-learn
A hack is to create the gc code you in a function want to call, say does the "gc" opEquals. Then cast that function to a nogc version by first casting to a void*. This way you can call gc code from nogc code, by bypassing the compiler's ability to check. It will obviously break your code if

Re: D safety! New Feature?

2016-08-02 Thread Mark J Twain via Digitalmars-d
On Tuesday, 2 August 2016 at 21:48:58 UTC, Mark Twain wrote: [...] Another useful feature I forgot to mention is that we can cast between Immutable and Muttable types. class ImmutableTest { private MutableArray!int data; public ImmutableArray!int Data; this() { //

Self Optimizing Code

2016-08-02 Thread Mark J Twain via Digitalmars-d
Another new D feature here! Self-Optimizing Code is a fantastic research area that can lead to greater improvements in code, make them more responsive to individual applications, and requires very little effort. To demonstrate: In many programs, memory behavior is fixed to a large degree,