Re: static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
On 2015-02-25 20:45, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Feb 25, 2015 at 08:20:37PM -0600, captaindet via Digitalmars-d-learn wrote: [...] struct Stuff2Do{ static ubyte[1024*1024] buffer4speed = void; // even if untyped at this point // more } [...] Tangential note:

Re: static void arrays under garbage control?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 20:20:37 -0600, captaindet wrote: > On 2015-02-25 19:24, Adam D. Ruppe wrote: >>> does this warning only apply to dynamic void[] arrays but not to >>> static void[CTconstant] arrays? >> >> Both of those will be scanned for pointers. > > thanks, adam, > > so i should always us

Re: static void arrays under garbage control?

2015-02-25 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 25, 2015 at 08:20:37PM -0600, captaindet via Digitalmars-d-learn wrote: [...] > struct Stuff2Do{ > static ubyte[1024*1024] buffer4speed = void; // even if untyped at this > point > > // more > } [...] Tangential note: be careful with putting a large static array inside a str

Re: static void arrays under garbage control?

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
You don't have to do all that, if it is typed ubyte[] instead of void[], it shouldn't be scanned at all anyway.

Re: static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
On 2015-02-25 19:24, Adam D. Ruppe wrote: does this warning only apply to dynamic void[] arrays but not to static void[CTconstant] arrays? Both of those will be scanned for pointers. thanks, adam, so i should always use struct Stuff2Do{ static ubyte[1024*1024] buffer4speed = void; // e

Re: How to use Fiber?

2015-02-25 Thread FrankLike via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 14:47:37 UTC, Dejan Lekic wrote: On the "Articles" page on D Wiki ( http://wiki.dlang.org/Articles ) you have this link: http://octarineparrot.com/article/view/getting-more-fiber-in-your-diet It is probably the best article about using fibers in D that I h

Re: static void arrays under garbage control?

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 26 February 2015 at 01:15:37 UTC, captaindet wrote: pointers to static data." Keep in mind that this is pointers TO static data - that is, if the object itself is static, it is not to be collected. static int[5] foo = [1,2,3,4,5]; // foo will never be collected, even if there a

static void arrays under garbage control?

2015-02-25 Thread captaindet via Digitalmars-d-learn
if i understand correctly, static arrays are exempt from GC scanning for memory pointers http://dlang.org/garbage.html : "Pointers in D can be broadly divided into two categories: Those that point to garbage collected memory, and those that do not. Examples of the latter are pointers created by

Re: How can I do that in @nogc?

2015-02-25 Thread anonymous via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 20:36:33 UTC, Namespace wrote: On Wednesday, 25 February 2015 at 20:15:10 UTC, anonymous wrote: [...] It may be possible to hack through this limitation - NOT THOUGHT-OUT, NOT TESTED, NOT RECOMMENDED: --- void glCheck(scope lazy int thing) @nogc; pragma(mangle

Re: @trusted and return ref

2015-02-25 Thread anonymous via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 22:16:14 UTC, Ola Fosheim Grøstad wrote: My point was that there is no conceptual difference between having a named function trusted_malloc!int() and trusted_free() and wrapping them up individually unnamed. An ad-hoc declared @trusted malloc is just as unsafe

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 21:32:02 +, Namespace wrote: > Instead of some wise talk, you could simply explain it. ;) i can, but i certainly don't want to. many people are reading this forum, and i don't want to teach 'em something like this. signature.asc Description: PGP signature

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 21:32:02 +, Namespace wrote: > The code is only used for debugging purposes. the best way to make your program undebugable is to use "debugging code that will be turned off in production". this way you aren't debugging the code that will go into production, you debugging

Re: How can I do that in @nogc?

2015-02-25 Thread TheFlyingFiddle via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 19:32:50 UTC, Namespace wrote: How can I specify that 'func' is @nogc? Or can define the function otherwise? An alternative solution would be to use function templated on an alias. import std.traits; void glCheck(alias func)(string file = __FILE__,

Re: @trusted and return ref

2015-02-25 Thread via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 18:58:13 UTC, anonymous wrote: We can't make malloc and free actually memory-safe, can we? We must not mark public unsafe functions @safe/@trusted. My point was that there is no conceptual difference between having a named function trusted_malloc!int() and tru

Re: How can I do that in @nogc?

2015-02-25 Thread Namespace via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 20:46:32 UTC, ketmar wrote: On Wed, 25 Feb 2015 20:36:32 +, Namespace wrote: That last thing works. But I have no clue why. o.O Anyway, thanks a lot! this is a smart hack. that should be NEVER used in production code. anyway, it's good that you don't u

Re: module import rules

2015-02-25 Thread module via Digitalmars-d-learn
I see, that makes sense! thanks

Re: module import rules

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 21:14:17 UTC, module wrote: I was following the process of importing modules as described in TDPL and Ali's book and they both claim that "By default, the name of a module is the same as its filename without the .d" That's true but the key thing is it is the f

Re: module import rules

2015-02-25 Thread module via Digitalmars-d-learn
Thanks Adam for the prompt response; I was following the process of importing modules as described in TDPL and Ali's book and they both claim that "By default, the name of a module is the same as its filename without the .d" and continue on to describe how the compiler searches for modules. So

Re: module import rules

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
The module declaration at the top of the file is needed and must match the import. So in somepackage/somemodule.d, add at the top module somepackage.somemodule; and then it will all work. While the module declaration is technically optional, any file that is imported really should have it e

module import rules

2015-02-25 Thread module via Digitalmars-d-learn
Hello, I have a main.d file which looks like this; import somepackage.somemodule; void main() { printSomething(); } Next to maind.d I have a directory 'somepackage' with a file inside called 'somemodule.d' which looks like this; void printSomething() { import std.stdio : wr

Re: How can I do that in @nogc?

2015-02-25 Thread ketmar via Digitalmars-d-learn
On Wed, 25 Feb 2015 20:36:32 +, Namespace wrote: > That last thing works. But I have no clue why. o.O Anyway, thanks a lot! this is a smart hack. that should be NEVER used in production code. anyway, it's good that you don't understand it. your code will crash sooner or later, and you will

Re: How can I do that in @nogc?

2015-02-25 Thread Namespace via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 19:53:16 UTC, Ivan Timokhin wrote: On Wed, Feb 25, 2015 at 07:32:48PM +, Namespace wrote: void glCheck(lazy void func, string file = __FILE__, uint line = __LINE__) { func(); glCheckError(file, line); } How can I specify that 'fu

Re: How can I do that in @nogc?

2015-02-25 Thread Namespace via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 20:15:10 UTC, anonymous wrote: On Wednesday, 25 February 2015 at 19:32:50 UTC, Namespace wrote: void glCheck(lazy void func, string file = __FILE__, uint line = __LINE__) { func(); glCheckError(file, line); } How can I specify that '

Re: How can I do that in @nogc?

2015-02-25 Thread anonymous via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 19:32:50 UTC, Namespace wrote: void glCheck(lazy void func, string file = __FILE__, uint line = __LINE__) { func(); glCheckError(file, line); } How can I specify that 'func' is @nogc? Or can define the function otherwise? First of

Re: How can I do that in @nogc?

2015-02-25 Thread Ivan Timokhin via Digitalmars-d-learn
On Wed, Feb 25, 2015 at 07:32:48PM +, Namespace wrote: > > void glCheck(lazy void func, string file = __FILE__, uint line = > __LINE__) { > func(); > glCheckError(file, line); > } > > > How can I specify that 'func' is @nogc? Or can define the > function otherwise? Try

How can I do that in @nogc?

2015-02-25 Thread Namespace via Digitalmars-d-learn
void glCheck(lazy void func, string file = __FILE__, uint line = __LINE__) { func(); glCheckError(file, line); } How can I specify that 'func' is @nogc? Or can define the function otherwise?

Re: Opening temporary files for std.process.spawnProcess input/output

2015-02-25 Thread Ali Çehreli via Digitalmars-d-learn
On 02/25/2015 05:56 AM, wobbles wrote: > Hi, > Any reason why the following wont work? > > void main(string[] args) > { > auto pidIn = File.tmpfile(); > auto pidOut = File.tmpfile(); > auto pid = spawnProcess(["ls", "./"], pidIn, pidOut, > std.stdio.stdout, null, Config.newEnv); >

Re: @trusted and return ref

2015-02-25 Thread anonymous via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 07:07:00 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 25 February 2015 at 00:12:41 UTC, anonymous wrote: [...] That sounds more attractive than the provided example, but the right thing to do is to establish proper encapsulation. That means you need a protect

Re: Deprecation process documented?

2015-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-02-24 18:55, Jonathan M Davis via Digitalmars-d-learn wrote: Normally, the symbol is deprecated right away, because using a deprecated symbol just results in a message being printing, but if a new symbol is being introduced to replace the deprecated one at the same time that the old symb

Re: Dynamic scope in D

2015-02-25 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 16:04:54 UTC, Adam D. Ruppe wrote: No, D's variable scoping is always lexical. Thanks.

Re: Dynamic scope in D

2015-02-25 Thread Adam D. Ruppe via Digitalmars-d-learn
No, D's variable scoping is always lexical.

Dynamic scope in D

2015-02-25 Thread Dennis Ritchie via Digitalmars-d-learn
Good time of day. Tell me, please, does D dynamic scope? If there is, prevalite, please, an example of it's use, or give a link where you can read about dynamic scope.

Re: How to use Fiber?

2015-02-25 Thread Dejan Lekic via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 10:15:29 UTC, FrankLike wrote: There is a int[] ,how to use the Fiber execute it ? Such as : import std.stdio; import core.thread; class DerivedFiber : Fiber { this() { super( &run ); } private : void run() { printf( "Derived

Re: Opening temporary files for std.process.spawnProcess input/output

2015-02-25 Thread Tobias Pankrath via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 13:56:06 UTC, wobbles wrote: Hi, Any reason why the following wont work? void main(string[] args) { auto pidIn = File.tmpfile(); auto pidOut = File.tmpfile(); auto pid = spawnProcess(["ls", "./"], pidIn, pidOut, std.stdio.stdout, null, Config.newEnv

Opening temporary files for std.process.spawnProcess input/output

2015-02-25 Thread wobbles via Digitalmars-d-learn
Hi, Any reason why the following wont work? void main(string[] args) { auto pidIn = File.tmpfile(); auto pidOut = File.tmpfile(); auto pid = spawnProcess(["ls", "./"], pidIn, pidOut, std.stdio.stdout, null, Config.newEnv); if(wait(pid) == 0) writefln("%s", pidOut.readln

Re: @trusted and return ref

2015-02-25 Thread Kagamin via Digitalmars-d-learn
It improves things without tools. Tools are always welcome, e.g. dfix already does something.

Re: @trusted and return ref

2015-02-25 Thread via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 09:49:41 UTC, Kagamin wrote: It's not only code itself to manage here, but also its evolution: http://forum.dlang.org/post/mbaksa$1ers$1...@digitalmars.com That's why it was proposed to change trusted so that it won't allow implicit usage of system code. But

Re: How to use Fiber?

2015-02-25 Thread Kagamin via Digitalmars-d-learn
Huh? If you wanted to print an array, then --- void main() { int n=1; while(n<=10_001) { v~=n; n+=5000; } foreach(c;v) { writeln( " current n is ",c ); } } ---

Re: DList.Range magically becomes empty.

2015-02-25 Thread Ivan Timokhin via Digitalmars-d-learn
Tobias Pankrath wrote: > writefln("stack: %s", stack[]); //fine This call consumes all ranges stored in stack, so they're empty afterwards.

Re: DList.Range magically becomes empty.

2015-02-25 Thread sclytrack via Digitalmars-d-learn
On Wednesday, 25 February 2015 at 09:07:17 UTC, Tobias Pankrath wrote: import std.container; import std.stdio; void main() { DList!int list; Array!(DList!int.Range) stack; foreach(i; 0 .. 4) { list.stableInsertBack(i); stack.insertBack(list[]); } writefln("list: %

DList.Range magically becomes empty.

2015-02-25 Thread Tobias Pankrath via Digitalmars-d-learn
import std.container; import std.stdio; void main() { DList!int list; Array!(DList!int.Range) stack; foreach(i; 0 .. 4) { list.stableInsertBack(i); stack.insertBack(list[]); } writefln("list: %s", list[]); // fine writefln("stack: %s", stack[]); //fine forea