Re: how to allocate class without gc?

2016-01-26 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? This is more or less the same answer as you've get previously except that I don't use emplace

Re: How do you draw in gtkD? Simple example overriding Widget.draw() doesn't compile.

2016-01-26 Thread Gerald via Digitalmars-d-learn
Generally don't override methods in GtkD, use event handlers like addOnDraw. Because GtkD wraps GTK functions an overriden D method of GtkD will never get called by GTK since it is working with the underlying C functions directly.

Re: How do you draw in gtkD? Simple example overriding Widget.draw() doesn't compile.

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 01:54:53 UTC, Enjoys Math wrote: import gtk.MainWindow; import gtk.Main; import gtk.DrawingArea; import cairo.Context; import std.stdio; void main(string[] args) { Main.init(args); auto win = new MainWindow("Hello World"); win.setDefaultSize(200, 100)

How do you draw in gtkD? Simple example overriding Widget.draw() doesn't compile.

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
import gtk.MainWindow; import gtk.Main; import gtk.DrawingArea; import cairo.Context; import std.stdio; void main(string[] args) { Main.init(args); auto win = new MainWindow("Hello World"); win.setDefaultSize(200, 100); win.add(new MyDrawingArea()); win.showAll(); Main.run

Re: gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 22:30:24 UTC, Enjoys Math wrote: On Tuesday, 26 January 2016 at 22:10:42 UTC, Enjoys Math wrote: I get this message either compiling at command line -or- in VisualD. At command line when I add -m64, I get another error: C:\MyProjects\___LIGHTSHOWAPP\___LIGHTSHO

Re: gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 01:20:49 UTC, Mike Parker wrote: has no connection library files has no relationship with library files What I mean is it is not used to specify libraries.

Re: Not getting expected behavior from compile-time conditional

2016-01-26 Thread pineapple via Digitalmars-d-learn
On Wednesday, 27 January 2016 at 00:17:18 UTC, Ali Çehreli wrote: Remove the extra is: :) Huh, I swear I tried that. Thanks!

Re: free causes exception

2016-01-26 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: um? Memory manager? I am doing it manually C++ style so I don't have to worry about the god forsaken memory manager. Why is it so difficult? I create the object and release it when I need to. He's talking about *your* memory manager,

Re: Not getting expected behavior from compile-time conditional

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 04:12 PM, pineapple wrote: > Here's a simple programming showing where I'm tripping up - > > void test(T)(in T value){ > import std.traits; > static if(is(T == char)){ > writeln("char"); > }else static if(is(isNumeric!(T))){ Remove the extra is: :) }else

Not getting expected behavior from compile-time conditional

2016-01-26 Thread pineapple via Digitalmars-d-learn
Here's a simple programming showing where I'm tripping up - void test(T)(in T value){ import std.traits; static if(is(T == char)){ writeln("char"); }else static if(is(isNumeric!(T))){ writeln("number"); } writeln("hi"); } public void main(){ test('g');

attributes and properties lookup order

2016-01-26 Thread ikod via Digitalmars-d-learn
Hello $ cat t.d import std.net.curl: get; void main() { string[string] x; string y = x.get("",""); } $ dmd t.d t.d(6): Error: template std.net.curl.get cannot deduce function from argument types !()(string[string], string, string), candidates are: /usr/include/dmd/phobos/std/net/curl

Re: Speed of csvReader

2016-01-26 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 26, 2016 at 08:54:34PM +, Chris Wright via Digitalmars-d-learn wrote: > On Tue, 26 Jan 2016 18:16:28 +, Gerald Jansen wrote: > > > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: > >> > >> While this is no fancy range-based code, and one might say it's > >> mor

Re: free causes exception

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 01:21 PM, Igor wrote: > I allocate in a static method called New once. I then deallocate in the > destructor. Basically just as one would do in C++. I would never do that in even C++. I don't know any C++ idiom that warrants 'delete this' where superior alternatives cannot be used

Re: gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 22:10:42 UTC, Enjoys Math wrote: I get this message either compiling at command line -or- in VisualD. At command line when I add -m64, I get another error: C:\MyProjects\___LIGHTSHOWAPP\___LIGHTSHOWAPP>dmd -m64 main.d -L+gtkd LINK : fatal error LNK1181: cannot

gtkd.lib: Error 43: Not a Valid Library File

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
I get this message either compiling at command line -or- in VisualD. At command line when I add -m64, I get another error: C:\MyProjects\___LIGHTSHOWAPP\___LIGHTSHOWAPP>dmd -m64 main.d -L+gtkd LINK : fatal error LNK1181: cannot open input file '+gtkd.obj' --- errorlevel 1181

Re: nogc Array

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 03:03:40 UTC, Igor wrote: Is there a GC-less array that we can use out of the box or do I have to create my own? If you want containers, use: http://code.dlang.org/packages/emsi_containers If you just need an array, use: http://dlang.org/phobos/std_experimental_

Re: Speed of csvReader

2016-01-26 Thread Gerald Jansen via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 20:54:34 UTC, Chris Wright wrote: On Tue, 26 Jan 2016 18:16:28 +, Gerald Jansen wrote: On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: While this is no fancy range-based code, and one might say it's more hackish and C-like than idiomatic D, t

Re: How do you link with GtkD in VisualD?

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 22:04:55 UTC, Enjoys Math wrote: [...] Okay, fixed by changing 'gtkd' setting to 'gtkd.lib'.

Re: free causes exception

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: [...] Don't do it in the destructor. I can only imagine that you are triggering the destructor with destroy? In this case, destro

How do you link with GtkD in VisualD?

2016-01-26 Thread Enjoys Math via Digitalmars-d-learn
I'm getting: SeverityCodeDescription Project FileLine Error Error 42: Symbol Undefined _D3gtk4Main12__ModuleInfoZ C:\MyProjects\___LIGHTSHOWAPP\WindowsApp1\ Error Error 42: Symbol Undefined _D3gtk5Label5Label7__ClassZ C:\MyProjects\___LIGHTSHOWAPP\WindowsApp1\ Error E

Re: free causes exception

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 21:23:28 UTC, Igor wrote: On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~t

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 19:34:22 UTC, Ali Çehreli wrote: On 01/26/2016 06:20 AM, Igor wrote: > I have successfully malloc'ed an object but when I go to free it in the > destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.fr

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 20:17:20 UTC, Steven Schveighoffer wrote: On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&

Re: Speed of csvReader

2016-01-26 Thread Chris Wright via Digitalmars-d-learn
On Tue, 26 Jan 2016 18:16:28 +, Gerald Jansen wrote: > On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: >> >> While this is no fancy range-based code, and one might say it's more >> hackish and C-like than idiomatic D, the problem is that current D >> compilers can't quite optim

Re: free causes exception

2016-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/26/16 9:20 AM, Igor wrote: I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&this); } auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize

Re: Defining event handlers for function, method, or shared method

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 11:42 AM, tcak wrote: >> struct S { >> void memberFunction() { >> } >> } >> auto s = S(); >> >> auto memberClosure(ref S s) { >> return () => s.memberFunction(); >> } >> >> events ~= new ConcreteEvent!(() => memberClosure(s), >>

Re: Defining event handlers for function, method, or shared method

2016-01-26 Thread tcak via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 19:22:58 UTC, Ali Çehreli wrote: On 01/26/2016 10:41 AM, tcak wrote: > I need/want this class to be able to bind > a function, a method, or a shared method. From the perspective of class > design, there shouldn't be any > difference. Its purpose is to let know about

Re: Defining event handlers for function, method, or shared method

2016-01-26 Thread tcak via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 19:42:42 UTC, tcak wrote: On Tuesday, 26 January 2016 at 19:22:58 UTC, Ali Çehreli wrote: [...] Hmm. Your example works fine for functions, but I can't pass a method instead of function as alias. Check my example: [...] Edit: ... "I guess because it is runti

Re: free causes exception

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 06:20 AM, Igor wrote: > I have successfully malloc'ed an object but when I go to free it in the > destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.free(&this); > } That design suggests a complexity regarding objec

Re: Defining event handlers for function, method, or shared method

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
What a lousy copy+paste mistake that was. I am glad no credit card number leaked there. :p On 01/26/2016 11:22 AM, Ali Çehreli wrote: > class ConcreteEvent(alias onStart, alias onStop, alias onItemAdded) : > void itemAdded(size_t itemIndex) { > itemAdded(itemIndex); > } That

Re: Defining event handlers for function, method, or shared method

2016-01-26 Thread Ali Çehreli via Digitalmars-d-learn
On 01/26/2016 10:41 AM, tcak wrote: > I need/want this class to be able to bind > a function, a method, or a shared method. From the perspective of class > design, there shouldn't be any > difference. Its purpose is to let know about the event, not to care > about how the event > handler is design

Re: Improving CSV parsing performance, Episode 2 (Was: Re: Speed of csvReader)

2016-01-26 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 06:27:49 UTC, H. S. Teoh wrote: On Sun, Jan 24, 2016 at 06:07:41AM +, Jesse Phillips via Digitalmars-d-learn wrote: [...] My suggestion is to take the unittests used in std.csv and try to get your code working with them. As fastcsv limitations would prevent re

Defining event handlers for function, method, or shared method

2016-01-26 Thread tcak via Digitalmars-d-learn
In many multi threading module designs of mine, I generally design a base class, and this class have some events. Exempli gratia: void eventOnStart(); void eventOnStop(); void eventOnItemAdded( size_t itemIndex ); There is this problem though. I need/want this class to be able to bind a functi

Re: Dense multidimensional std.container.array?

2016-01-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 18:07:40 UTC, ZombineDev wrote: [snip] Cool example.

Re: Speed of csvReader

2016-01-26 Thread Gerald Jansen via Digitalmars-d-learn
On Thursday, 21 January 2016 at 21:24:49 UTC, H. S. Teoh wrote: While this is no fancy range-based code, and one might say it's more hackish and C-like than idiomatic D, the problem is that current D compilers can't quite optimize range-based code to this extent yet. Perhaps in the future opt

Re: Dense multidimensional std.container.array?

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 14:55:53 UTC, Wilson wrote: Just wondering how to create a dense multidimensional array with the GC free array container? I don't want to use an array of arrays but I do want the array[0][0] notation. I suggest using std.experimental.ndslice [1] for multidimensio

Re: traits getOverload of a template method

2016-01-26 Thread ZombineDev via Digitalmars-d-learn
On Thursday, 6 February 2014 at 23:06:03 UTC, QAston wrote: How do i get aliases to overloads of a template method like Class A { int a(T)(T tq,T tw); int a(T)(T tq); } __traits(getOverloads, A, "a(int)")doesnt work Bump. I also have a similar problem. I have a module with two functio

Re: Types as keys

2016-01-26 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 15:54:14 UTC, Voitech wrote: How to handle this correctly? Make BaseParser the value type of the AA. Parser!Foo and Parser!Bar are subtypes of BaseParser. Unlike Java, just `Parser` is not a type but a template. It must be instantiated to create a type. Java i

Types as keys

2016-01-26 Thread Voitech via Digitalmars-d-learn
Hello, I'm having problem with converting from Java style coding to D, probably doing wrong something. I want to have a map (associative array) which will return specific object depending on provided key. Key is a type of other object. Let say i want to hold single instances of some kind of par

Re: free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 14:48:48 UTC, Daniel Kozak wrote: V Tue, 26 Jan 2016 14:20:29 + Igor via Digitalmars-d-learn napsáno: [...] core.stdc.stdlib.free(cast(void *)this); I still get an exception: Exception thrown at 0x7FF6C7CA3700 in test.exe: 0xC005: Access violati

Re: free causes exception

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 15:24:00 + Igor via Digitalmars-d-learn napsáno: > On Tuesday, 26 January 2016 at 14:48:48 UTC, Daniel Kozak wrote: > > V Tue, 26 Jan 2016 14:20:29 + > > Igor via Digitalmars-d-learn > > napsáno: > > > >> [...] > > > > core.stdc.stdlib.free(cast(void *)this); >

Re: how to allocate class without gc?

2016-01-26 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 13:56:39 UTC, Igor wrote: //ubyte[__traits(classInstanceSize, App)] buffer; auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize, App))[0..__traits(classInstanceSize, App)]; works, so it is the ubyte line. Make sure the buffer out

Re: how to allocate class without gc?

2016-01-26 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 13:56:39 UTC, Igor wrote: //ubyte[__traits(classInstanceSize, App)] buffer; auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize, App))[0..__traits(classInstanceSize, App)]; works, so it is the ubyte line. Can you please post the f

Dense multidimensional std.container.array?

2016-01-26 Thread Wilson via Digitalmars-d-learn
Just wondering how to create a dense multidimensional array with the GC free array container? I don't want to use an array of arrays but I do want the array[0][0] notation.

Re: free causes exception

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 14:20:29 + Igor via Digitalmars-d-learn napsáno: > I have successfully malloc'ed an object but when I go to free it > in the destructor I get an exception. The destructor simply has > > ~this() // destructor for Foo > { > core.stdc.stdlib.free(&this); > } > > > aut

Re: how to allocate class without gc?

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 13:56:39 + Igor via Digitalmars-d-learn napsáno: > On Tuesday, 26 January 2016 at 09:32:06 UTC, Daniel Kozak wrote: > > V Tue, 26 Jan 2016 05:47:42 + > > Igor via Digitalmars-d-learn > > napsáno: > > > >> On Tuesday, 26 January 2016 at 05:11:54 UTC, Mike Parker wrote

free causes exception

2016-01-26 Thread Igor via Digitalmars-d-learn
I have successfully malloc'ed an object but when I go to free it in the destructor I get an exception. The destructor simply has ~this() // destructor for Foo { core.stdc.stdlib.free(&this); } auto buffer = core.stdc.stdlib.malloc(__traits(classInstanceSize, App))[0..__traits(classInstanc

Re: how to allocate class without gc?

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 09:32:06 UTC, Daniel Kozak wrote: V Tue, 26 Jan 2016 05:47:42 + Igor via Digitalmars-d-learn napsáno: On Tuesday, 26 January 2016 at 05:11:54 UTC, Mike Parker wrote: > [...] Can you try it with GC.disable()? //ubyte[__traits(classInstanceSize, App)] buffe

Re: how to allocate class without gc?

2016-01-26 Thread Igor via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 09:32:06 UTC, Daniel Kozak wrote: V Tue, 26 Jan 2016 05:47:42 + Igor via Digitalmars-d-learn napsáno: [...] Can you try it with GC.disable()? Didn't change anything.

Re: D Dll's usefulness

2016-01-26 Thread Benjamin Thaut via Digitalmars-d-learn
On Monday, 25 January 2016 at 19:45:21 UTC, Igor wrote: Am I off target here? Dlls are currently not properly supported in D, I would strongly advice against using them. Just link everything statically and be happy for now. Kind Regards Benjamin Thaut

Re: Improving CSV parsing performance, Episode 2 (Was: Re: Speed of csvReader)

2016-01-26 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 06:27:49 UTC, H. S. Teoh wrote: My thought is to integrate the fastcsv code into std.csv, such that the current std.csv code will serve as fallback in the cases where fastcsv's limitations would prevent it from being used, with fastcsv being chosen where possible.

Re: how to allocate class without gc?

2016-01-26 Thread Mike via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? There are a number of different patterns discussed and illustrated with examples at http://wi

Re: how to allocate class without gc?

2016-01-26 Thread Adrian Matoga via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: Is there any examples that shows how to properly allocate an object of a class type with the new allocators and then release it when desired? There's an example of class object allocation in the std.experimental.allocator docs: // Dyn

Re: how to allocate class without gc?

2016-01-26 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 26 Jan 2016 05:47:42 + Igor via Digitalmars-d-learn napsáno: > On Tuesday, 26 January 2016 at 05:11:54 UTC, Mike Parker wrote: > > On Tuesday, 26 January 2016 at 01:09:50 UTC, Igor wrote: > >> Is there any examples that shows how to properly allocate an > >> object of a class type w

Re: nogc Array

2016-01-26 Thread Olivier Pisano via Digitalmars-d-learn
On Tuesday, 26 January 2016 at 05:53:29 UTC, Igor wrote: On Tuesday, 26 January 2016 at 04:38:13 UTC, Adam D. Ruppe wrote: On Tuesday, 26 January 2016 at 04:31:07 UTC, Igor wrote: then std.algorithm.find!("a.myInt == b")(classes, 3) Try std.algorithm.find!("a.myInt == b")(classes[], 3) noti