Greedy memory handling

2013-09-11 Thread monarch_dodra
I have a function that will *massively* benefit from having a persistent internal buffer it can re-use (and grow) from call to call, instead of re-allocating on every call. What I don't want is either of: 1. To set a fixed limitation of size, if the user ends up making repeated calls to someth

Re: Greedy memory handling

2013-09-11 Thread Gary Willoughby
On Wednesday, 11 September 2013 at 08:06:37 UTC, monarch_dodra wrote: I have a function that will *massively* benefit from having a persistent internal buffer it can re-use (and grow) from call to call, instead of re-allocating on every call. What I don't want is either of: 1. To set a fixed l

Re: Greedy memory handling

2013-09-11 Thread monarch_dodra
On Wednesday, 11 September 2013 at 10:28:37 UTC, Gary Willoughby wrote: You can then let the GC handle it or free it yourself with GC.free(*buffer). But if the buffer is stored in a static variable, the GC will never collect it. I *could* also free it myself, but why/when would I do that? D

Re: Greedy memory handling

2013-09-11 Thread Joseph Rushton Wakeling
On 11/09/13 12:34, monarch_dodra wrote: But if the buffer is stored in a static variable, the GC will never collect it. I *could* also free it myself, but why/when would I do that? Did you just just let your buffer grow, and never let it get collected? Is there a way to do something like "I'm u

Re: Greedy memory handling

2013-09-11 Thread Joseph Rushton Wakeling
On 11/09/13 13:14, Joseph Rushton Wakeling wrote: On 11/09/13 12:34, monarch_dodra wrote: But if the buffer is stored in a static variable, the GC will never collect it. I *could* also free it myself, but why/when would I do that? Did you just just let your buffer grow, and never let it get col

Re: Greedy memory handling

2013-09-11 Thread Namespace
On Wednesday, 11 September 2013 at 08:06:37 UTC, monarch_dodra wrote: I have a function that will *massively* benefit from having a persistent internal buffer it can re-use (and grow) from call to call, instead of re-allocating on every call. What I don't want is either of: 1. To set a fixed l

Re: Greedy memory handling

2013-09-11 Thread Dmitry Olshansky
11-Sep-2013 14:34, monarch_dodra пишет: On Wednesday, 11 September 2013 at 10:28:37 UTC, Gary Willoughby wrote: You can then let the GC handle it or free it yourself with GC.free(*buffer). But if the buffer is stored in a static variable, the GC will never collect it. I *could* also free it my

Re: Greedy memory handling

2013-09-11 Thread monarch_dodra
On Wednesday, 11 September 2013 at 11:19:27 UTC, Joseph Rushton Wakeling wrote: On 11/09/13 13:14, Joseph Rushton Wakeling wrote: On 11/09/13 12:34, monarch_dodra wrote: But if the buffer is stored in a static variable, the GC will never collect it. I *could* also free it myself, but why/when

Re: Greedy memory handling

2013-09-11 Thread Joseph Rushton Wakeling
On 11/09/13 15:13, monarch_dodra wrote: That's somewhat better, as it would allow the GC to collect my buffer, if it wants to, but I wouldn't actually know about it afterwards which leaves me screwed. Just to clarify, is this buffer meant only for internal use in your function or is it meant

Re: Greedy memory handling

2013-09-11 Thread Dmitry Olshansky
11-Sep-2013 17:33, Joseph Rushton Wakeling пишет: On 11/09/13 15:13, monarch_dodra wrote: That's somewhat better, as it would allow the GC to collect my buffer, if it wants to, but I wouldn't actually know about it afterwards which leaves me screwed. Just to clarify, is this buffer meant only

Re: Greedy memory handling

2013-09-11 Thread Joseph Rushton Wakeling
On 11/09/13 15:45, Dmitry Olshansky wrote: Problem is - said GC-freed memory could be then reused in some way. I can't imagine how you'd test that the block that is allocated is *still your old* block. Ahh, nasty. I'd assumed that the buffer would have been reset to null in the event that th

Re: Greedy memory handling

2013-09-11 Thread monarch_dodra
On Wednesday, 11 September 2013 at 13:33:23 UTC, Joseph Rushton Wakeling wrote: On 11/09/13 15:13, monarch_dodra wrote: That's somewhat better, as it would allow the GC to collect my buffer, if it wants to, but I wouldn't actually know about it afterwards which leaves me screwed. Just to clar

VisualD import

2013-09-11 Thread Lemonfiend
Now that VisualD has been officially accepted onto the d-programming-language github, I decided to give it a try. And failed. Say I want to import derelict, how would I go about it? Thanks.

Re: VisualD import

2013-09-11 Thread Lemonfiend
Oops, I forgot to say what I actually did. I added derelict to Compiler->General->Additional Imports. The code is just this: module main; import std.stdio; import derelict.opengl3.gl3; void main() { writeln("Hello D-World!"); } And the build output is a symbol undefined linker issue

Re: Why is the rex.w prefix not generated for certain instructions in inline assembler blocks?

2013-09-11 Thread Brad Roberts
On 9/11/13 9:59 AM, Joseph Cassman wrote: On Monday, 9 September 2013 at 20:37:47 UTC, Joseph Cassman wrote: So I'm out of ideas on where the error is coming from. Anyone got any ideas on what's going on here? Still not sure what is going on but I found a work-around that somebody else might

Re: Why is the rex.w prefix not generated for certain instructions in inline assembler blocks?

2013-09-11 Thread Joseph Cassman
On Monday, 9 September 2013 at 20:37:47 UTC, Joseph Cassman wrote: So I'm out of ideas on where the error is coming from. Anyone got any ideas on what's going on here? Still not sure what is going on but I found a work-around that somebody else might find useful. The mov instruction is able

Re: Any idea for a solution to handle overloads when dynamically implementing methods?

2013-09-11 Thread H. S. Teoh
On Mon, Sep 09, 2013 at 10:16:42PM +0200, Gary Willoughby wrote: > Just wondered if i could pick you brains for a nice solution to > dynamically add methods to a class, paying particular attention to > overloads. I'm currently writing a mocking framework and > everything's coming along nicely and i

Re: VisualD import

2013-09-11 Thread Rainer Schuetze
On 11.09.2013 18:13, Lemonfiend wrote: Oops, I forgot to say what I actually did. I added derelict to Compiler->General->Additional Imports. The code is just this: module main; import std.stdio; import derelict.opengl3.gl3; void main() { writeln("Hello D-World!"); } And the build ou

Re: Adding libraries to an executable

2013-09-11 Thread Anton Alexeev
On Tuesday, 10 September 2013 at 11:06:04 UTC, Jacob Carlborg wrote: On 2013-09-10 11:04, Anton Alexeev wrote: Can be but not libphobos2 Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d The point is: http://pastebin.com/0VkYgFix

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread Timothee Cour
actually that doesn't work: assert(!isNumeric(`j`)); //ok assert(!isNumeric(`i`)); //fails ; i is treated as a complex number but that's not good behavior as we can't write auto a=i; assert(isNumeric(`1e2`)); // fails even though we can write auto a=1e2; In contrast, what I had worked (passes tho

Re: VisualD import

2013-09-11 Thread Lemonfiend
On Wednesday, 11 September 2013 at 20:36:39 UTC, Rainer Schuetze wrote: On 11.09.2013 18:13, Lemonfiend wrote: Oops, I forgot to say what I actually did. I added derelict to Compiler->General->Additional Imports. The code is just this: module main; import std.stdio; import derelict.opengl3

Re: VisualD import

2013-09-11 Thread Rainer Schuetze
On 11.09.2013 23:42, Lemonfiend wrote: On Wednesday, 11 September 2013 at 20:36:39 UTC, Rainer Schuetze wrote: On 11.09.2013 18:13, Lemonfiend wrote: Oops, I forgot to say what I actually did. I added derelict to Compiler->General->Additional Imports. The code is just this: module main;

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread H. S. Teoh
On Wed, Sep 11, 2013 at 02:10:32PM -0700, Timothee Cour wrote: > actually that doesn't work: > > assert(!isNumeric(`j`)); //ok > assert(!isNumeric(`i`)); //fails ; i is treated as a complex number but > that's not good behavior as we can't write auto a=i; Yikes! This makes me *extremely* glad bu

Re: Adding libraries to an executable

2013-09-11 Thread Mike Parker
On 9/12/2013 6:20 AM, Anton Alexeev wrote: On Tuesday, 10 September 2013 at 11:06:04 UTC, Jacob Carlborg wrote: On 2013-09-10 11:04, Anton Alexeev wrote: Can be but not libphobos2 Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d The point is: http:

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread Timothee Cour
anyways, isNumeric sounds buggy, isn't it? On Wed, Sep 11, 2013 at 4:03 PM, H. S. Teoh wrote: > On Wed, Sep 11, 2013 at 02:10:32PM -0700, Timothee Cour wrote: > > actually that doesn't work: > > > > assert(!isNumeric(`j`)); //ok > > assert(!isNumeric(`i`)); //fails ; i is treated as a complex n

Re: Why is the rex.w prefix not generated for certain instructions in inline assembler blocks?

2013-09-11 Thread Joseph Cassman
On Wednesday, 11 September 2013 at 17:09:12 UTC, Brad Roberts wrote: Please file a bug for this. http://d.puremagic.com/issues/ You got it. Joseph

Re: nothrow function to tell if a string can be converted to a number?

2013-09-11 Thread H. S. Teoh
On Wed, Sep 11, 2013 at 08:15:26PM -0700, Timothee Cour wrote: > anyways, isNumeric sounds buggy, isn't it? Yeah, I'd file a bug. I can't see how "i" can possibly be numeric. I thought the compiler rejected that anyway? > On Wed, Sep 11, 2013 at 4:03 PM, H. S. Teoh wrote: > > > On Wed, Sep 11,

may gc free malloced memory?

2013-09-11 Thread Alexandr Druzhinin
Some C function malloc-ed memory. This memory should be freeed much later. I don't want to manually call C function to free this memory in some point later, so may I in some way ask gc to free this memory using something like addRoot(for instance) or else or the true way is to copy malloc-ed me

Re: may gc free malloced memory?

2013-09-11 Thread monarch_dodra
On Thursday, 12 September 2013 at 05:36:31 UTC, Alexandr Druzhinin wrote: Some C function malloc-ed memory. This memory should be freeed much later. I don't want to manually call C function to free this memory in some point later, so may I in some way ask gc to free this memory using something

Re: Greedy memory handling

2013-09-11 Thread Jacob Carlborg
On 2013-09-11 10:06, monarch_dodra wrote: I have a function that will *massively* benefit from having a persistent internal buffer it can re-use (and grow) from call to call, instead of re-allocating on every call. What I don't want is either of: 1. To set a fixed limitation of size, if the user