How to delete dynamic array ?

2013-12-29 Thread Ilya Yaroshenko
case 1: delete ar; case 2: ar.destroy(); case 3: GC.free(ar.ptr); case 4: ar = null;// (assumed that ar is only one pointer to the same array) What is the difference? How to free memory to the system immediately? ___ Thank You & Best Regards, Ilya

Re: GtkD icon theme issue

2013-12-29 Thread Benjamin Thaut
Am 30.12.2013 00:24, schrieb Mike Wey: The normal version works on Windows, i'll include these in the installer. As for installing the themes separately you'll need auomake and GnuMake. I don't know if you have these installed, but i've created a zip http://gtkd.org/Downloads/gtk-icon-theme.zip

Possible bug - should the following code cause an access violation exception?

2013-12-29 Thread Afshin
module test; class Foo { public static ulong next = 0; public static ulong getNext() { return next++; } } void main() { Foo.getNext(); } /* The next++ is the culprit. Using a ++next does not throw an exception. */

Re: Custom binary operators

2013-12-29 Thread H. S. Teoh
On Mon, Dec 30, 2013 at 05:34:10AM +0100, Marco Leise wrote: > Am Sat, 28 Dec 2013 15:24:31 + > schrieb "Dicebot" : > > > AFAIK it is intentionally banned to constrain operator > > overloading abuse. > > That and it makes the compiler faster. [...] And discourages writing unreadable code li

Re: style question on structs

2013-12-29 Thread Ali Çehreli
On 12/29/2013 10:58 AM, Jonathan wrote: > Given a struct > > struct Foo{ >enum INT_C {Yes, No} >INT_C a; > } [...] > The second choice is: do we qualify by the struct name: > > this(int y) > { >//option 1 >a = Foo.INT_C.Yes; That's what I do without thinking much about it. >

Re: boilerplate generation

2013-12-29 Thread Dicebot
On Sunday, 29 December 2013 at 22:28:00 UTC, Carl Sturtivant wrote: Very nice. Only one problem: when I use dmd/win32 to build the DLL, and analyze the resulting export, it's _D5mixin43__T7ExternCS28_D5mixin1X3fffFkPS5mixin1AZiZ3fffUkPS5mixin1AZi and not _fff or similar. So somehow the extern(C)

Re: Custom binary operators

2013-12-29 Thread Marco Leise
Am Sat, 28 Dec 2013 15:24:31 + schrieb "Dicebot" : > AFAIK it is intentionally banned to constrain operator > overloading abuse. That and it makes the compiler faster. -- Marco

Re: Ultra-pure map()?

2013-12-29 Thread Timon Gehr
On 12/29/2013 11:11 PM, David Held wrote: On 12/28/2013 5:13 AM, Timon Gehr wrote: [...] I wouldn't call this an 'eager map'. It's a shallow wrapper around a foreach loop. The point being that foreach loops aren't composable. Dave Wrapping it will not change that.

Re: lexer/parser library for D

2013-12-29 Thread Mike Parker
On 12/30/2013 5:36 AM, FreeSlave wrote: Also you may read http://www.gamedev.net/blog/1140/entry-2254003-binding-d-to-c/ Better to go to [1], where I combined that series of posts into a single article and updated a few things, too. [1] http://www.gamedev.net/page/resources/_/technical/ga

Re: lexer/parser library for D

2013-12-29 Thread Casper Færgemand
If you like Parser Expression Grammar there's Pegged: https://github.com/PhilippeSigaud/Pegged

Re: GtkD icon theme issue

2013-12-29 Thread Mike Wey
On 12/29/2013 06:26 PM, Benjamin Thaut wrote: I'm currently working with a file chooser. Whenever I open a folder that actually contains file I get the following error message: Assertion file 'gtk' line 0: Could not find the icon 'gtk-file'. The 'hicolor' theme was not found either, perhaps you

Re: When is a class's destructor called?

2013-12-29 Thread Mike
On Sunday, 29 December 2013 at 14:24:05 UTC, bearophile wrote: Ali Çehreli: On 12/29/2013 04:00 AM, Mike: Do you happen to know of any clever technique to make object, and everything that inherits from it, a referenced counted object? There is std.typecons.RefCounted: http://dlang.org/pho

Re: ref type versus ptr type on input

2013-12-29 Thread anonymous
On Sunday, 29 December 2013 at 22:11:22 UTC, monarch_dodra wrote: On Sunday, 29 December 2013 at 21:47:52 UTC, Namespace wrote: Well, a ref *can't* be null. In terms of default value, both can have them, in terms of referencing a static object though. The only functional difference I know of i

Re: boilerplate generation

2013-12-29 Thread Carl Sturtivant
On Sunday, 29 December 2013 at 22:01:19 UTC, Dicebot wrote: Does this look clean enough? (Not sure I have completely understood the question) /* export extern(C) int f( uint argc, A* argv) { return Wrapper!f( argc, argv); } */ struct A {} int Wrapper(alias func, T...)(T args) { return 42; }

Re: Ultra-pure map()?

2013-12-29 Thread Ali Çehreli
On 12/29/2013 02:11 PM, David Held wrote:> On 12/28/2013 5:13 AM, Timon Gehr wrote: >> [...] >> I wouldn't call this an 'eager map'. It's a shallow wrapper around a >> foreach loop. > > The point being that foreach loops aren't composable. Agreed. However, if they were composable they would have

Re: ref type versus ptr type on input

2013-12-29 Thread monarch_dodra
On Sunday, 29 December 2013 at 21:47:52 UTC, Namespace wrote: On Sunday, 29 December 2013 at 19:42:39 UTC, Jonathan wrote: If I want to write a function that operates on a struct struct S { } What are the differences between: void(S* s) void(ref S s) You cannot set a default value (like nu

Re: Ultra-pure map()?

2013-12-29 Thread David Held
On 12/28/2013 2:07 AM, FreeSlave wrote: [...] If you want to get result just now, then use 'array' function from std.array module. map!fun(range).array; or array(map!fun(range)); Syntactically compact and slightly better expression of intent, but much less efficient than just calling reduce

Re: Ultra-pure map()?

2013-12-29 Thread David Held
On 12/28/2013 5:13 AM, Timon Gehr wrote: [...] I wouldn't call this an 'eager map'. It's a shallow wrapper around a foreach loop. The point being that foreach loops aren't composable. Dave

Re: boilerplate generation

2013-12-29 Thread Dicebot
Does this look clean enough? (Not sure I have completely understood the question) /* export extern(C) int f( uint argc, A* argv) { return Wrapper!f( argc, argv); } */ struct A {} int Wrapper(alias func, T...)(T args) { return 42; } template ExternC(alias existingFunc) { import std.str

Re: ref type versus ptr type on input

2013-12-29 Thread Namespace
On Sunday, 29 December 2013 at 19:42:39 UTC, Jonathan wrote: If I want to write a function that operates on a struct struct S { } What are the differences between: void(S* s) void(ref S s) You cannot set a default value (like null) for ref parameters, but you can for pointer.

boilerplate generation

2013-12-29 Thread Carl Sturtivant
I want to be able to define a number of extern(C) functions that will define a C API in a DLL, varying only in their names, each as follows. export extern(C) int f( uint argc, A* argv) { return Wrapper!f( argc, argv); } Here Wrapper!f is a wrapper around a D function named f that does the

Re: lexer/parser library for D

2013-12-29 Thread FreeSlave
On Sunday, 29 December 2013 at 19:25:46 UTC, Jonathan wrote: Are there any good lexer and parser libraries (like flex/bison) for D? If not, how much work would be involved in using flex and bison and wrapping it to D? How straightforward is it to pass a struct from C to D (the documentation

Re: lexer/parser library for D

2013-12-29 Thread FreeSlave
There is also http://www.semitwist.com/goldie/ but I did not use it.

Re: Do assertions provide a mechanism for subtyping? If not are they composable?

2013-12-29 Thread bearophile
Jonathan: I would like to know if D tries to statically check these assertions. Currently D doesn't statically verify them. I have an enhancement request in the works for something related, but it's not powerful enough for your use case. Bye, bearophile

Re: ref type versus ptr type on input

2013-12-29 Thread John Colvin
On Sunday, 29 December 2013 at 19:42:39 UTC, Jonathan wrote: If I want to write a function that operates on a struct struct S { } What are the differences between: void(S* s) s is a pointer to an instance of S, in the raw C sense. void(ref S s) s can be used as a normal S, but changes ar

Re: lexer/parser library for D

2013-12-29 Thread John Colvin
On Sunday, 29 December 2013 at 19:25:46 UTC, Jonathan wrote: Are there any good lexer and parser libraries (like flex/bison) for D? If not, how much work would be involved in using flex and bison and wrapping it to D? How straightforward is it to pass a struct from C to D (the documentation

Re: style question on structs

2013-12-29 Thread John Colvin
On Sunday, 29 December 2013 at 18:58:07 UTC, Jonathan wrote: Given a struct struct Foo{ enum INT_C {Yes, No} INT_C a; } -- we wish to make a constructor. We want to set the answer to Yes if we construct the struct with an integer. There are some stylistic choices to be made. The first

ref type versus ptr type on input

2013-12-29 Thread Jonathan
If I want to write a function that operates on a struct struct S { } What are the differences between: void(S* s) void(ref S s) Also, for my general knowledge, is there a way to set default function parameters, such as scope or lazy?

lexer/parser library for D

2013-12-29 Thread Jonathan
Are there any good lexer and parser libraries (like flex/bison) for D? If not, how much work would be involved in using flex and bison and wrapping it to D? How straightforward is it to pass a struct from C to D (the documentation http://dlang.org/struct.html just says that D structs go direc

Do assertions provide a mechanism for subtyping? If not are they composable?

2013-12-29 Thread Jonathan
D allows inputs and outputs to have assertions placed on them. i.e. int f(int x){ in{ assert(even(x)); } out{ assert(odd(x));; } } I would like to know if D tries to statically check these assertions. If so that would give a subtyping mechanism which would be kind of neat.

style question on structs

2013-12-29 Thread Jonathan
Given a struct struct Foo{ enum INT_C {Yes, No} INT_C a; } -- we wish to make a constructor. We want to set the answer to Yes if we construct the struct with an integer. There are some stylistic choices to be made. The first choice is: do we use this (I seem to recall being told in Ja

GtkD icon theme issue

2013-12-29 Thread Benjamin Thaut
I'm currently working with a file chooser. Whenever I open a folder that actually contains file I get the following error message: Assertion file 'gtk' line 0: Could not find the icon 'gtk-file'. The 'hicolor' theme was not found either, perhaps you need to install it. You can get a copy from:

Re: Shared library ld issue?

2013-12-29 Thread Mineko
On Sunday, 29 December 2013 at 16:06:51 UTC, Dicebot wrote: AFAIK shared libraries are not yet supported by GDC / LDC, at least not as supported as in DMD. Thank you, at least now I know I mainly wasted my time, and can now move on to other ideas. Although I got some interesting stuff workin

Re: extern(C) function declarations and extra keywords.

2013-12-29 Thread Jakob Ovrum
On Sunday, 29 December 2013 at 14:50:52 UTC, H. S. Teoh wrote: Yes, since C code will not throw D exceptions (C doesn't know anything about D exceptions). Unless you pass in a function pointer to a D function that does throw an exception... but that case doesn't work for other reasons, so it ge

Re: Shared library ld issue?

2013-12-29 Thread Dicebot
AFAIK shared libraries are not yet supported by GDC / LDC, at least not as supported as in DMD.

Re: Shared library ld issue?

2013-12-29 Thread Mineko
I also get another strange error I can't solve, whenever I compile something with GDC without the standard library (-nostdlib) I get this whenever I try to access the shared library. (like the above but without libgphobos, with nostdlib instead) undefined symbol: _Dmodule_ref Any ideas?

Re: extern(C) function declarations and extra keywords.

2013-12-29 Thread H. S. Teoh
On Sat, Dec 28, 2013 at 09:57:06PM +, ponce wrote: [...] > >I noticed that in Deimos and Derelict that most(if not all) C > >function declarations are marked as nothrow. What are the > >speed/safety benefits of including this? > > No speed or safety benefit, but it allows to call these C funct