Re: Comparing function pointers

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 3:40 AM, Freddy wrote: import std.stdio; auto test1(){ void testFunc(){ } return &testFunc; } auto test2(){ uint a; void testFunc(){ a=1; } return &testFunc; } void main(){ writeln(test1()==test1());//true writeln(test2()=

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:42 AM, ketmar wrote: this problem has very easy solition: we should stop calling class dtors "destructors", and rename them to "finalizers". Absolutely. So many people coming from C++ see "destructor" and want to use them as they did in C++. How often do we see people coming

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
Truth be told, D has no guideline for deterministic destruction of managed resources.

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 12, 2015 08:33:34 Kagamin via Digitalmars-d-learn wrote: > Truth be told, D has no guideline for deterministic destruction > of managed resources. Really what it comes down to is that if you want deterministic destruction, you _don't_ use managed resources. You use malloc and

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:14:49 UTC, Mike Parker wrote: On 2/12/2015 6:42 AM, ketmar wrote: this problem has very easy solition: we should stop calling class dtors "destructors", and rename them to "finalizers". Absolutely. So many people coming from C++ see "destructor" and wa

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do it in D beyond 'drop down to C level

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 08:55:43 UTC, Jonathan M Davis wrote: On Thursday, February 12, 2015 08:33:34 Kagamin via Digitalmars-d-learn wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. Really what it comes down to is that if you want determini

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: > That's a repetition of C++ atavism, that resource management == memory > management. IStream is a traditional example of a GC-managed object, > which needs deterministic destruction, and not because it consumes > memory, but because it encapsula

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: > That's a repetition of C++ atavism, that resource management == memory > management. IStream is a traditional example of a GC-managed object, > which needs deterministic destruction, and not because it consumes > memory, but because it encapsula

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: > http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors > > I've also made one for "D can't do real-time because it has a > stop-the-world GC" > http://p0nce.github.io/d-idioms/#The-impossible-real-time-thread > > And one for "D does

Is there an object on given memory address?

2015-02-12 Thread tcak via Digitalmars-d-learn
Is there any "reliable" way to determine whether there is a certain type of object in memory at a given address? I am going to send the memory address of an object to another program over pipes. Then after a while, other program will send that memory address, and main program will try to addre

Re: Is there an object on given memory address?

2015-02-12 Thread tcak via Digitalmars-d-learn
On Thursday, 12 February 2015 at 10:03:18 UTC, tcak wrote: Is there any "reliable" way to determine whether there is a certain type of object in memory at a given address? I am going to send the memory address of an object to another program over pipes. Then after a while, other program will s

Re: Is there an object on given memory address?

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 10:04:29 UTC, tcak wrote: BTW, I have already got the address of object into a "size_t" type variable and sent it. That is not the problem part. How reliable do you want? You would have to either "pin the object" by registering a root to it to prevent it from b

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Mike Parker via Digitalmars-d-learn
On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wondering why class destructors don't work when there's no _real_ way to do

Re: Cannot use the same template arguments on function as the ones on struct

2015-02-12 Thread MrSmith via Digitalmars-d-learn
Thanks, everyone.

Re: Is there an object on given memory address?

2015-02-12 Thread tcak via Digitalmars-d-learn
Or send a hash of the object along with the memory address, then query the GC wether the memory is still allocated. This part sounds interesnting. How does that GC querying thing works exactly?

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors I've also made one for "D can't do real-time because it has a stop-the-world GC" http://p0nce.github.io/d-idioms/#Th

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ponce via Digitalmars-d-learn
On Thursday, 12 February 2015 at 10:24:38 UTC, Mike Parker wrote: On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of managed resources. +1 don't complain about people wonderi

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 11:10:34 +, ponce wrote: > On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: >> On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: >> >>> http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors >>> >>> I've also made one for "D can't do real-time becau

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
OK. there is some example: // we're using an OpenGL class A { protected int m_tex; this() { // texture has been created in video memory. there is no GC resource. glGenTexture(1, &m_tex); glTexImage2D(); // texture in video memory

Starting a HTTPS session with D

2015-02-12 Thread Kadir Erdem Demir via Digitalmars-d-learn
Hi We have a network traffic logger module at office. We need to a tool which creates simple traffic with different protocols and test our product's output to see if we parse the headers correctly or not. And of course I proposed writing this tool with D!!! When it comes to create a HTTP ses

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:11:53 UTC, ponce wrote: On Thursday, 12 February 2015 at 10:24:38 UTC, Mike Parker wrote: On 2/12/2015 6:09 PM, weaselcat wrote: On Thursday, 12 February 2015 at 08:33:35 UTC, Kagamin wrote: Truth be told, D has no guideline for deterministic destruction of

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:10:22 UTC, Andrey Derzhavin wrote: OK. there is some example: // we're using an OpenGL class A { protected int m_tex; this() { // texture has been created in video memory. there is no GC resource. glGenTexture(1, &m_

Re: Starting a HTTPS session with D

2015-02-12 Thread Vladimir Panteleev via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:11:27 UTC, Kadir Erdem Demir wrote: Hi We have a network traffic logger module at office. We need to a tool which creates simple traffic with different protocols and test our product's output to see if we parse the headers correctly or not. And of course I

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 12:10:21 +, Andrey Derzhavin wrote: > if GC does not guarantee the calling of dtor we can't be sure that some > textures will be destroyed. > It will be followed by overflowing of the video memory. > And it is obvious, becouse we have no way to detect when the objects are >

Re: Starting a HTTPS session with D

2015-02-12 Thread Kadir Erdem Demir via Digitalmars-d-learn
get("https://dlang.org";, http); It works as I wanted, thanks a lot . Regards Erdem

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:29:47 UTC, Marc Schütz wrote: Exactly. That's why it's wrong to rely on the GC if you need deterministic resource management. It's simply the wrong tool for that. Unfortunately, the "right" tools are a bit awkward to use, for the time being. I still have h

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 12:52:02 +, Andrey Derzhavin wrote: > If we can't relay on GC wholly, there is no need for GC. > All of the objects, that I can create, I can destroy manually by myself, > without any doubtful GC destroying attempts. sure. but when it comes, for example, for big data struc

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Paulo Pinto via Digitalmars-d-learn
On Thursday, 12 February 2015 at 09:41:50 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: That's a repetition of C++ atavism, that resource management == memory management. IStream is a traditional example of a GC-managed object, which needs deterministic destruction, and

Re: How to write asia characters on console?

2015-02-12 Thread FrankLike via Digitalmars-d-learn
On Sunday, 8 February 2015 at 05:57:31 UTC, Lave Zhang wrote: Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = "hello你好"d; writeln(s1); } --- But the output is not corre

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Andrey Derzhavin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 13:11:48 UTC, ketmar wrote: sure. but when it comes, for example, for big data structures with complex cross-references, you'll inevitably found that you either leaking memory, or writing your own half-backed semi-working GC realization. ah, good luck doing ef

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 13:21:07 +, Paulo Pinto wrote: > On Thursday, 12 February 2015 at 09:41:50 UTC, ketmar wrote: >> On Thu, 12 Feb 2015 09:26:12 +, Kagamin wrote: >> >>> That's a repetition of C++ atavism, that resource management == memory >>> management. IStream is a traditional exampl

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 13:55:20 +, Andrey Derzhavin wrote: > On Thursday, 12 February 2015 at 13:11:48 UTC, ketmar wrote: >> sure. but when it comes, for example, for big data structures with >> complex cross-references, you'll inevitably found that you either >> leaking memory, or writing your o

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 12:52:03 UTC, Andrey Derzhavin wrote: If we can't relay on GC wholly, there is no need for GC. All of the objects, that I can create, I can destroy manually by myself, without any doubtful GC destroying attempts. Manual memory management should be possible in D

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Kagamin via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:10:35 UTC, ponce wrote: On Thursday, 12 February 2015 at 09:50:39 UTC, ketmar wrote: On Thu, 12 Feb 2015 09:04:27 +, ponce wrote: http://p0nce.github.io/d-idioms/#The-trouble-with-class-destructors I've also made one for "D can't do real-time because it

Re: Cannot use the same template arguments on function as the ones on struct

2015-02-12 Thread Kenji Hara via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 22:24:53 UTC, anonymous wrote: On Wednesday, 11 February 2015 at 22:14:44 UTC, MrSmith wrote: http://dpaste.dzfl.pl/5f1d5d5d9e19 Instead I need to use template constraint which is less compact. http://dpaste.dzfl.pl/571ae84d783e Why such behavior happens?

Re: Is there an object on given memory address?

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 10:16:49 UTC, Ola Fosheim Grøstad wrote: then query the GC wether the memory is still allocated. This is racy, though. Someone (or the GC) could have freed the object in the meantime, and a new object of potentially different type could have taken its place. Y

Re: Is there an object on given memory address?

2015-02-12 Thread Baz via Digitalmars-d-learn
On Thursday, 12 February 2015 at 11:14:05 UTC, tcak wrote: Or send a hash of the object along with the memory address, then query the GC wether the memory is still allocated. This part sounds interesnting. How does that GC querying thing works exactly? std [doc][1] is your friend but if you

Re: Is there an object on given memory address?

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 15:53:07 UTC, Marc Schütz wrote: On Thursday, 12 February 2015 at 10:16:49 UTC, Ola Fosheim Grøstad wrote: then query the GC wether the memory is still allocated. This is racy, though. Someone (or the GC) could have freed the object in the meantime, and a new

Re: Is there an object on given memory address?

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 16:27:21 UTC, Ola Fosheim Grøstad wrote: On Thursday, 12 February 2015 at 15:53:07 UTC, Marc Schütz wrote: On Thursday, 12 February 2015 at 10:16:49 UTC, Ola Fosheim Grøstad wrote: then query the GC wether the memory is still allocated. This is racy, though. S

Re: Is there an object on given memory address?

2015-02-12 Thread via Digitalmars-d-learn
On Thursday, 12 February 2015 at 16:56:24 UTC, Marc Schütz wrote: Whoaa, that's just horrible! *shudder* I know, but it works.

Re: GC has a "barbaric" destroyng model, I think

2015-02-12 Thread Foo via Digitalmars-d-learn
On Thursday, 12 February 2015 at 14:44:07 UTC, Kagamin wrote: On Thursday, 12 February 2015 at 12:52:03 UTC, Andrey Derzhavin wrote: If we can't relay on GC wholly, there is no need for GC. All of the objects, that I can create, I can destroy manually by myself, without any doubtful GC destroyi

Static convertability testing?

2015-02-12 Thread Chris Williams via Digitalmars-d-learn
I have a template function that gets values out of a tree of variant types. My goal is to be able to write code like; node.get!string("path", "to", "leaf"); Inside get(), I would like to use std.conv to dynamically convert (where able) to the target type (T) or, if that is not possible, to re

Re: Static convertability testing?

2015-02-12 Thread ketmar via Digitalmars-d-learn
On Thu, 12 Feb 2015 19:09:45 +, Chris Williams wrote: > Is there something like isConvertible() in the library somewhere? there is at least `std.traits.isImplicitlyConvertible`: http://dlang.org/phobos/std_traits.html#isImplicitlyConvertible signature.asc Description: PGP signature

Re: Static convertability testing?

2015-02-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 12, 2015 19:09:45 Chris Williams via Digitalmars-d-learn wrote: > I have a template function that gets values out of a tree of > variant types. My goal is to be able to write code like; > > node.get!string("path", "to", "leaf"); > > Inside get(), I would like to use std.conv

Re: Cannot use the same template arguments on function as the ones on struct

2015-02-12 Thread MrSmith via Digitalmars-d-learn
Thank you!

What is the Correct way to Malloc in @nogc section?

2015-02-12 Thread Kitt via Digitalmars-d-learn
I'm currently trying to write a personal Associate Array class that can be used in @nogc sections. Obviously, this means I'll want to use malloc/free, however I'm not sure what the "Correct" way to do this is. In a few places online I've seen code for custom "_new" and "_delete" functions simil

Re: What is the Correct way to Malloc in @nogc section?

2015-02-12 Thread Kitt via Digitalmars-d-learn
I realized the above "_new" has an issue with emplace depending on whether it's a class (reference type) or not. Class c = emplace() works, but something like string s = emplace() does not. Is doing string s = *emplace() safe and okay? Or is there a better way to handle the differences between

Re: What is the Correct way to Malloc in @nogc section?

2015-02-12 Thread Foo via Digitalmars-d-learn
On Thursday, 12 February 2015 at 23:27:51 UTC, Kitt wrote: I'm currently trying to write a personal Associate Array class that can be used in @nogc sections. Obviously, this means I'll want to use malloc/free, however I'm not sure what the "Correct" way to do this is. In a few places online I'v

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
finally ,I write a orm tool to replace hibernated, it is simple, and it is easy to use, and every thing in control. It is free to copy ,improve. module mysqlormutil; import vibe.d; import std.stdio; import mysql.connection; import mysql.db; struct NotNull { } struct Auto { } struct Index

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
how to update table schema automatically: this() { mdb = new MysqlDB(connStr); auto conn = mdb.lockConnection(); scope(exit) conn.close(); MysqlOrmUtil.updateTableSchema!(Customer)(conn); MysqlOrmUtil.updateT

Re: Why hibernated does not create tables automatically?

2015-02-12 Thread zhmt via Digitalmars-d-learn
here is how to use: @UniqueIndex("id",["id"]) class Card { @NotNull() @Auto() long id; string pwd; long agentId; bool valid; long rmb; long createDate; long soldDate; long chargeDate; } public Card[] getAllCa

Derelict OpenGL basic program does not work but OpenGL does not say anything is wrong?

2015-02-12 Thread Bennet via Digitalmars-d-learn
I've begun writing some basic OpenGL code using DerelictGL3 but I've hit a wall. I've managed to open a window (with DerelictSDL2) and call basic OpenGL functions such as glClear(). Still I can not get a basic triangle up and running. glError() does not return anything and when compiling, linki

Re: What is the Correct way to Malloc in @nogc section?

2015-02-12 Thread Jakob Ovrum via Digitalmars-d-learn
On Thursday, 12 February 2015 at 23:27:51 UTC, Kitt wrote: The Exception obviously uses the GC, and would need to be replaced with a printf or something; however, emplace doesn't have a @nogc replacement that I know of. What I'd like to know, from people much more knowledgeable about the ins an