Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
https://d.puremagic.com/issues/show_bug.cgi?id=3882 Bye, bearophile Did you set this as WONTFIX because of too many warnings from functions that may throw or just do asserts such as unittests? If so does anyone see any way to restrict warnings even further for example by checking if a funct

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:40:27 UTC, evilrat wrote: On Friday, 28 February 2014 at 06:36:02 UTC, Tolga Cakiroglu wrote: On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that

Re: undefined symbol: rt_finalize

2014-02-27 Thread evilrat
On Friday, 28 February 2014 at 06:36:02 UTC, Tolga Cakiroglu wrote: On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes wi

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:28:10 UTC, Tolga Cakiroglu wrote: Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that. Even Walter Bright's code doesn't use export, and goes with extern only. http://dlang.org/dll-linux.html#dso10

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
rt_finalize is defined in lifetime.d (https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d). Its part of the D runtime. It just forwards to rt_finalize2. I don't know why you are getting an undefined symbol, though. Is the signature different? I made some chan

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
Whops! Hold on a sec. I saw that I defined `foo` as `extern` instead of `export`. Testing with that.

Re: undefined symbol: rt_finalize

2014-02-27 Thread Mike
On Thursday, 27 February 2014 at 06:25:45 UTC, Tolga Cakiroglu wrote: I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
On Friday, 28 February 2014 at 06:02:30 UTC, Mike wrote: On Friday, 28 February 2014 at 05:59:23 UTC, Mike wrote: On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. Nope. No chance. I have removed all imports. All `destroy`s are replaced with `clean`, and still same. I have deleted all executables and compiled again and again. ./app: symbol

Re: undefined symbol: rt_finalize

2014-02-27 Thread Mike
On Friday, 28 February 2014 at 05:59:23 UTC, Mike wrote: On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I believe delete() and clear() are deprecated and destroy()

Re: undefined symbol: rt_finalize

2014-02-27 Thread Mike
On Friday, 28 February 2014 at 05:46:03 UTC, evilrat wrote: that finalize i guess is for finalizing objects. but destroy itself is deprecated. use clear() to do this instead. I believe delete() and clear() are deprecated and destroy() is the correct method. I recently read it somewhere, I'l

Re: undefined symbol: rt_finalize

2014-02-27 Thread evilrat
On Friday, 28 February 2014 at 05:41:04 UTC, Tolga Cakiroglu wrote: because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30 I looked at the `/usr/include/dmd/druntime` folder with `grep finalize -r`,

Re: undefined symbol: rt_finalize

2014-02-27 Thread Tolga Cakiroglu
because there is no finalize. rt_init/rt_term is what you need https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L30 I looked at the `/usr/include/dmd/druntime` folder with `grep finalize -r`, and it brought me only one file, that is `object.di`. When I chec

Re: Contribution for Newcomers

2014-02-27 Thread Michael
Thanks Mike, I'll give it a shot! On Friday, 28 February 2014 at 04:14:44 UTC, Mike wrote: On Friday, 28 February 2014 at 03:54:27 UTC, Michael wrote: Hello all! I've been programming in D for my school projects for a while and would like to contribute to the community if possible. Can anyone

Re: undefined symbol: rt_finalize

2014-02-27 Thread evilrat
On Thursday, 27 February 2014 at 06:25:45 UTC, Tolga Cakiroglu wrote: I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[

Re: Colons and brackets

2014-02-27 Thread evilrat
On Friday, 28 February 2014 at 04:19:47 UTC, Etienne Cimon wrote: Hi all, I'm a little perplexed b/c I can't seem to find anything that could tell me where this ends: version(something): code code code \eof How do you stop statements from belonging to the specific version of code without us

Colons and brackets

2014-02-27 Thread Etienne Cimon
Hi all, I'm a little perplexed b/c I can't seem to find anything that could tell me where this ends: version(something): code code code \eof How do you stop statements from belonging to the specific version of code without using brackets? Thanks!

Re: Contribution for Newcomers

2014-02-27 Thread Mike
On Friday, 28 February 2014 at 03:54:27 UTC, Michael wrote: Hello all! I've been programming in D for my school projects for a while and would like to contribute to the community if possible. Can anyone give me any pointers as to where I might be able to start? I tried searching for so-trivial

Contribution for Newcomers

2014-02-27 Thread Michael
Hello all! I've been programming in D for my school projects for a while and would like to contribute to the community if possible. Can anyone give me any pointers as to where I might be able to start? I tried searching for so-trivial-give-to-new-people tag but didn't find any :o) I don't have

Re: @disable this for structs

2014-02-27 Thread bearophile
Mike Parker: Ideally, I'd love for the compiler to pick up on this idiom and not generate any typeinfo in this situation. Is this in Bugzilla somewhere? If it's a good idea then it could and should go in Bugzilla. Bye, bearophile

Re: @disable this for structs

2014-02-27 Thread Namespace
On Friday, 28 February 2014 at 01:16:41 UTC, Mike Parker wrote: On 2/28/2014 3:10 AM, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves D. Where does it fit in relative to 42? ;=( Steve I use it for namespaces. struct Fo

Re: @disable this for structs

2014-02-27 Thread Mike Parker
On 2/28/2014 3:10 AM, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves D. Where does it fit in relative to 42? ;=( Steve I use it for namespaces. struct Foo { @disable this(); @disable this( this ); private stat

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Timon Gehr
On 02/28/2014 12:38 AM, "Nordlöw" wrote: Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm not familiar with the DMD source code, but a good way to proceed is usually to grep for existing error messages that are somehow relate

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread bearophile
Nordlöw: Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm trying to figure out how to implement automatic detection of unused return values from calls to strictly pure functions. The closest I have come is the function fun

Re: Sorting a zipped range

2014-02-27 Thread bearophile
Ben Jones: auto sorter = (Tuple x, Tuple y) => x.get(0) < y.get(0); sort!sorter(zip(a,b)); You can write that as (untested): zip(a, b).sort!((x, y) => x[0] < y[0]); Or even just: a.zip(b).sort!q{ a[0] < b[0] }; Bye, bearophile

Re: Sorting a zipped range

2014-02-27 Thread Timon Gehr
On 02/27/2014 10:09 PM, Ben Jones wrote: My question is: which features of the D range abstraction allow zip to work the way we expect? Assignable elements of a range do not need to be addressable. What C++isms were left behind to make this work? In C++, iterators should implement operato

DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm trying to figure out how to implement automatic detection of unused return values from calls to strictly pure functions. The closest I have come is the function functionParame

Re: DMD Source Guidance: Unused Return Values of Strictly Pure Function Calls

2014-02-27 Thread Nordlöw
On Thursday, 27 February 2014 at 23:38:34 UTC, Nordlöw wrote: Does anybody know where in the DMD source I can figure out if the return value of a function call is used or not? I'm trying to figure out how to implement automatic detection of unused return values from calls to strictly pure func

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread DS6
On Thursday, 27 February 2014 at 23:12:16 UTC, Ali Çehreli wrote: Because this is actually a newsgroup (i.e. NNTP), pretending to be a forum. :) I could kinda tell from both the URL and the "Posting to digitalmars.D.learn" line. I've never used a newsgroup before, cool.

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread Ali Çehreli
On 02/27/2014 03:09 PM, DS6 wrote: Also *3: Not having to make an account to post here is also nice. I don't really like signing up for things. Because this is actually a newsgroup (i.e. NNTP), pretending to be a forum. :) Ali

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread DS6
Also *3: Not having to make an account to post here is also nice. I don't really like signing up for things.

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread DS6
On Thursday, 27 February 2014 at 22:58:40 UTC, Ali Çehreli wrote: But of course: :) Yeah I found that out already; I have schoolwork to do but D is really interesting and stuff and argh. I think one of the things I also like about D so far is the community. Most Java communities, when I asked

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread Ali Çehreli
On 02/27/2014 02:40 PM, DS6 wrote: > What exactly is the difference between C and D headers? D code that needs to use a C library must use "D bindings" of that C library. Here is Deimos, a collection of D bindings of many C libraries: https://github.com/D-Programming-Deimos More informatio

Re: Replace exception handler?

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 22:24:23 UTC, Ali Çehreli wrote: On 02/27/2014 05:24 AM, Remo wrote: > Unfortunately I can not find a way to replace exception handler in D2. > Is there a way to do this? I think you mean the unhandled exception handler. Otherwise, try+catch is the way to provi

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread Simon Bürger
What exactly is the difference between C and D headers? D itself does not use headers at all. But you will need "D headers", if you want to call a C library from D. The translation is mostly syntatic and straight forward like: * replace #define-constants with enums * replace macros with (templa

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread Jeremy DeHaan
On Thursday, 27 February 2014 at 22:40:36 UTC, DS6 wrote: What exactly is the difference between C and D headers? D does not have any separation between header and code files like C or C++. There are files with the .di extension which are similar, but not quite the same. What he meant is that

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread DS6
On Thursday, 27 February 2014 at 10:52:51 UTC, John Colvin wrote: It's a flexible, well designed language. Many things that are complex and/or slow in other languages can be written in a readable and performant manner, with fewer nasty surprises. I find I usually run into some "nasty surprises

Re: Documenting unit tests?

2014-02-27 Thread Jeremy DeHaan
On Thursday, 27 February 2014 at 22:31:11 UTC, Jeremy DeHaan wrote: I was looking some things up today, and saw this: A unittest which is not documented, or is marked as private will not be used to generate code samples. I have not once put any kind of documentation in front of unit tests,

Documenting unit tests?

2014-02-27 Thread Jeremy DeHaan
I was looking some things up today, and saw this: A unittest which is not documented, or is marked as private will not be used to generate code samples. I have not once put any kind of documentation in front of unit tests, but they still run when using the -unittest switch. I haven't tested

Re: custom memory management

2014-02-27 Thread Steven Schveighoffer
On Thu, 27 Feb 2014 16:46:15 -0500, Simon Bürger wrote: I know the suggested way in D is to not deallocate the buffer at all, but rely on the gc to collect it eventually. But it still puzzles me that it seems to be impossible to do. Anybody have an idea how I could make it work? Unfort

Re: custom memory management

2014-02-27 Thread Simon Bürger
On Thursday, 27 February 2014 at 22:15:41 UTC, Steven Schveighoffer wrote: On Thu, 27 Feb 2014 16:46:15 -0500, Simon Bürger [...] More and more, I think a thread-local flag of "I'm in the GC collection cycle" would be hugely advantageous -- if it doesn't already exist... I don't think it does

Re: Replace exception handler?

2014-02-27 Thread Ali Çehreli
On 02/27/2014 05:24 AM, Remo wrote: > Unfortunately I can not find a way to replace exception handler in D2. > Is there a way to do this? I think you mean the unhandled exception handler. Otherwise, try+catch is the way to provide a handler. ;) I think that would not be the solution as it woul

Re: custom memory management

2014-02-27 Thread Simon Bürger
On Thursday, 27 February 2014 at 22:04:50 UTC, Namespace wrote: A struct is a value type. So it is passed by value and is placed on the stack. { S s; } S DTor is called at the end of the scope. So you can rely on RAII as long as you use structs. On the stack yes. But not on the heap:

Re: custom memory management

2014-02-27 Thread Namespace
A struct is a value type. So it is passed by value and is placed on the stack. { S s; } S DTor is called at the end of the scope. So you can rely on RAII as long as you use structs.

Re: What is format of "dmd -deps ..." output?

2014-02-27 Thread Simon Bürger
On Wednesday, 26 February 2014 at 13:38:55 UTC, Cooler wrote: Is there any official/unofficial documentation about -deps command line option output? This does not answer your question directly, but if you want to create dependency files for use with make, you can use "rdmd --makedepend".

Re: Dynamically calling external libraries.

2014-02-27 Thread Setra
By returns I ment what it wrote to the screen. I realise now that that was a bad word to use... Every time I run it I get the value 134515512. Here is my compile script (Note I edited my code to use the same method of printing that you did and got the same result): dmd -c dll.d -fPIC dmd -ofl

custom memory management

2014-02-27 Thread Simon Bürger
I am trying to implement a structure with value semantics which uses an internal buffer. The first approach looks like this: struct S { byte[] buf; this(int size) { buf = new byte[size]; } this(this) { buf = buf.dup; } ~this(this) { delete buf; } } T

Re: Sorting a zipped range

2014-02-27 Thread Ben Jones
On Thursday, 27 February 2014 at 21:24:20 UTC, Tobias Pankrath wrote: On Thursday, 27 February 2014 at 21:09:45 UTC, Ben Jones wrote: My question is: which features of the D range abstraction allow zip to work the way we expect? What C++isms were left behind to make this work? Many items i

Re: Sorting a zipped range

2014-02-27 Thread Tobias Pankrath
On Thursday, 27 February 2014 at 21:09:45 UTC, Ben Jones wrote: My question is: which features of the D range abstraction allow zip to work the way we expect? What C++isms were left behind to make this work? Many items in std.algorithm / std.range make use of static if to provide the most

Sorting a zipped range

2014-02-27 Thread Ben Jones
One of the cool features of D that I've attempted before in c++ is to sort a set of ranges in lockstep like (not syntactically correct): auto a = [5,4,3,2,1] auto b = [1,2,3,4,5] auto sorter = (Tuple x, Tuple y) => x.get(0) < y.get(0); sort!sorter(zip(a,b)); -> a = [1,2,3,4,5], b = [5,4,3,2,

Re: Dynamically calling external libraries.

2014-02-27 Thread Marc Schütz
On Thursday, 27 February 2014 at 14:38:11 UTC, Setra wrote: I am compiling it the way to guide recomends it. It compiles however for some reason when it runs the value returned by the dll is incorrect? Does anyone know why? It always returns the same value even when I change the parameter. Wh

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:39:48 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;) Or in VC2013, but if you can use Intel compiler then it is bett

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 15:09:39 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and fea

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : h

Re: @disable this for structs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 18:26:10 UTC, Steve Teale wrote: On Thursday, 27 February 2014 at 18:13:43 UTC, Namespace wrote: On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;)

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/concurrency.d#L281 (Isolated!T) Priceless for message passin

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 15:56:26 UTC, Remo wrote: On Thursday, 27 February 2014 at 15:39:48 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 15:36:02 UTC, Remo wrote: What do you mean by Microsoft's dialect? I mean half-implemented buggy version of C++11 in VC2012 ;) Or

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:58:50 UTC, bearophile wrote: Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amount of D code (perhaps 200_000 lines or more), I still use Python a lo

@disable this for structs

2014-02-27 Thread Steve Teale
Could someone please explain what you would use this for to an old man rooted in C++, but who loves D. Where does it fit in relative to 42? ;=( Steve

Re: @disable this for structs

2014-02-27 Thread Steve Teale
On Thursday, 27 February 2014 at 18:13:43 UTC, Namespace wrote: On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves D. Where does it fit in relative to 42? ;=( Steve It's for e

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:49:48 UTC, Szymon Gatner wrote: You can disable postblit to make entity non-copyable: http://dlang.org/struct.html#StructPostblit How can I then use it as a function return value? Or store in a container? Actually if postblit had a bool param saying that t

Re: GC for noobs

2014-02-27 Thread Dicebot
There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/concurrency.d#L281 (Isolated!T) Priceless for message passing concurrency.

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:15:06 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:58:50 UTC, bearophile wrote: Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amoun

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:41:27 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. For exam

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 16:10:34 UTC, Adam D. Ruppe wrote: On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. st

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. For example in C++ I can create a function that returns a Texture clas

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 15:09:39 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:56:22 UTC, Namespace wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and fea

Re: @disable this for structs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves D. Where does it fit in relative to 42? ;=( Steve It's for explicit initialization: struct Foo { } Foo f; // no problem st

Re: @disable this for structs

2014-02-27 Thread John Colvin
On Thursday, 27 February 2014 at 18:26:10 UTC, Steve Teale wrote: On Thursday, 27 February 2014 at 18:13:43 UTC, Namespace wrote: On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale wrote: Could someone please explain what you would use this for to an old man rooted in C++, but who loves

Re: GC for noobs

2014-02-27 Thread Adam D. Ruppe
On Thursday, 27 February 2014 at 17:31:57 UTC, Dicebot wrote: Isn't it exactly what Phobos RefCounted does? Yes, though knowing how the implementation works is good for stuff like interfacing with C where you might need different acquire/free/add count/release functions than phobos uses. ht

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 18:06:58 UTC, John Colvin wrote: On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig :

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:29:05 UTC, Szymon Gatner wrote: Explicit call to init() / terminate() are so C :/ It is much better than C because of `scope(exit) terminate()` though :) Also you can use struct destructors same as in C++ Worst part is there is no even standard shared/weak

Re: GC for noobs

2014-02-27 Thread John Colvin
On Thursday, 27 February 2014 at 14:52:00 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 14:42:43 UTC, Dicebot wrote: There is also one complex and feature-reach implementation of uniqueness concept by Sonke Ludwig : https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe

Re: @disable this for structs

2014-02-27 Thread Adam D. Ruppe
Basically, disabling the default constructor just forces the user to think about what they want there to initialize it, which also gives you a chance to check their values or funnel them toward a particular constructor/factory method. They can still choose to explicitly leave it unitialized wi

Re: GC for noobs

2014-02-27 Thread bearophile
Szymon Gatner: Tbh it only looks worse and worse to me :( Perhaps for your use case it's better for you to stick with C++11? While I have written a good amount of D code (perhaps 200_000 lines or more), I still use Python a lot, etc. Bye, bearophile

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 16:10:34 UTC, Adam D. Ruppe wrote: struct RefCountingStruct { private struct Impl { // implementation here int refcount; } Impl* payload; alias payload this; Isn't it exactly what Phobos RefCounted does?

Re: GC for noobs

2014-02-27 Thread Adam D. Ruppe
On Thursday, 27 February 2014 at 14:37:14 UTC, Szymon Gatner wrote: They actually don't have all the necessary features in D afaiu. They do have value semantics but can't represent uniqueness because of missing move d-tor. struct MovingStruct { @disable this(this); typeof(this) release

Re: Dynamically calling external libraries.

2014-02-27 Thread Setra
I have found the Dlang wiki article on how to do it. http://dlang.org/dll-linux.html I am using the following code. [code] import core.stdc.stdio; import core.stdc.stdlib; import core.sys.posix.dlfcn; extern (C) int dll(); int main() { printf("+main()\n"); void *lh = dlopen("libdll.so",

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 14:18:47 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 14:14:43 UTC, Namespace wrote: Why not? Overhead? No RAII support? Simply no reason to use classes, structs have all features I need for cases when polymorphism is not necessary (95%+). Being value

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else i

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 14:14:43 UTC, Namespace wrote: Why not? Overhead? No RAII support? Simply no reason to use classes, structs have all features I need for cases when polymorphism is not necessary (95%+). Being value type is also convenient as it leaves more control to the prog

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 13:44:11 UTC, Namespace wrote: On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via inte

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 14:12:58 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:44:11 UTC, Namespace wrote: On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all th

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 13:31:45 UTC, Dicebot wrote: On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else i

Re: GC for noobs

2014-02-27 Thread Dicebot
On Thursday, 27 February 2014 at 13:18:51 UTC, Remo wrote: Then the question is why not use structs all the time? Key class feature is run-time polymorphism (via interfaces/inheritance). I tend to use structs for everything else in my personal code.

Replace exception handler?

2014-02-27 Thread Remo
There is a way to replace assertHandler and it helped me to resolve a couple of problem. Unfortunately I can not find a way to replace exception handler in D2. Is there a way to do this? The problem is that I load a Dll coded in D from Application coded in C++. If this Dll throw and exceptio

Re: GC for noobs

2014-02-27 Thread Remo
On Thursday, 27 February 2014 at 13:07:37 UTC, Mike Parker wrote: On 2/27/2014 9:25 PM, Szymon Gatner wrote: This is just an example but I would think that it is something rather important to have... What about child objects un-registering themselves in d-tors from a list that parent object

Re: GC for noobs

2014-02-27 Thread Mike Parker
On 2/27/2014 10:00 PM, Szymon Gatner wrote: Still, this feels like working around a language issue, if c-tor order is defined why d-tor isn't? I am ok with non-deterministic time of execution of d-tors/finalizers but not-having parent-child d-tor order defined? That is weird. I've never seen

Re: GC for noobs

2014-02-27 Thread Mike Parker
On 2/27/2014 9:25 PM, Szymon Gatner wrote: This is just an example but I would think that it is something rather important to have... What about child objects un-registering themselves in d-tors from a list that parent object holds and parent is destroyed first? What about asynchronous completi

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 13:04:17 UTC, Namespace wrote: I use this solution especially because I have to finalize the data before I call SDL_Quit. And therefore I cannot trust the non-deterministic execution of the Dtor. I fully understand that ;) I will take a look at DGame too for

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 12:32:36 UTC, Namespace wrote: On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 13:00:27 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 12:32:36 UTC, Namespace wrote: On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want

Re: GC for noobs

2014-02-27 Thread Namespace
On Thursday, 27 February 2014 at 12:25:49 UTC, Szymon Gatner wrote: On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better.

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 11:13:17 UTC, bearophile wrote: Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile In my specific example I am creating OpenGL Rend

Re: GC for noobs

2014-02-27 Thread bearophile
Szymon Gatner: I just want them to do their cleanup first as they should. Why? Perhaps if you explain what's behind your needs better, people can help better. Bye, bearophile

Re: Switching from Java to D: Beginner questions, multiplatform issues, etc.

2014-02-27 Thread John Colvin
On Thursday, 27 February 2014 at 10:23:40 UTC, DS6 wrote: Okay, down to the questions I have about D: - Why should I use D over another language? What general benefits does it provide me, in relation to the points I made about it above? Is it a solid base to build off of, but still simple in

Re: GC for noobs

2014-02-27 Thread Szymon Gatner
On Thursday, 27 February 2014 at 10:40:15 UTC, Tobias Pankrath wrote: Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory manage

Re: GC for noobs

2014-02-27 Thread Tobias Pankrath
Szymon Gatner wrote: Parent-child in the sense of object graph. I did read the spec when I started to notice crashes. I must say that it really terrified me to my very bones. I always though that higher-level memory management environments would give more and not less guarantees. Anyway, I

  1   2   >