Store any callable in an array

2018-05-04 Thread wjoe via Digitalmars-d-learn
I have a class that I want to be able to register callbacks and I'd like to be able to register any callable - functions, delegates, lambdas, anything. Is there another way to do it besides converting those toDelegate, which states a bug with @safe functions? Or better store each type in

Re: Windows to Linux Porting - timeCreated and timeLastAccessed

2018-05-04 Thread wjoe via Digitalmars-d-learn
On Friday, 4 May 2018 at 15:30:26 UTC, Vino wrote: On Friday, 4 May 2018 at 15:16:23 UTC, wjoe wrote: [...] Hi Wjoe, Thank you very much, but what i am expecting is something like OS switch, based of OS type switch the funciton eg: If OS is windows use the funciton timeCreated else if

Re: Windows to Linux Porting - timeCreated and timeLastAccessed

2018-05-04 Thread wjoe via Digitalmars-d-learn
On Friday, 4 May 2018 at 14:24:36 UTC, Vino wrote: On Friday, 4 May 2018 at 14:02:24 UTC, Jonathan M Davis wrote: On Friday, May 04, 2018 13:17:36 Vino via Digitalmars-d-learn wrote: On Friday, 4 May 2018 at 12:38:07 UTC, Adam D. Ruppe wrote: > What are you actually trying to do with it? These

Re: Store any callable in an array

2018-05-06 Thread wjoe via Digitalmars-d-learn
Thanks for replying. On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote: On 05/04/2018 06:33 PM, Neia Neutuladh wrote: auto asDelegate(TFunc)(TFunc func) @trusted {     import std.functional : toDelegate;     return toDelegate(func); } The "@trusted" means that you promise this thing is

Re: Store any callable in an array

2018-05-06 Thread wjoe via Digitalmars-d-learn
Thanks for replying. On Saturday, 5 May 2018 at 00:30:35 UTC, Neia Neutuladh wrote: On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote: [...] If it's a user-defined type with opCall, that's something to pay attention to, but it's beyond the scope of the original question. Actually it's

Re: Store any callable in an array

2018-05-07 Thread wjoe via Digitalmars-d-learn
On Monday, 7 May 2018 at 10:20:22 UTC, ag0aep6g wrote: On 05/07/2018 04:41 AM, wjoe wrote: Could you elaborate on the unsafe destructor please? If TFunc has an unsafe destructor, asDelegate is also not safe and can't be @trusted. An example of how that can break safety: auto

Re: Windows to Linux Porting - timeCreated and timeLastAccessed

2018-05-07 Thread wjoe via Digitalmars-d-learn
On Friday, 4 May 2018 at 15:42:56 UTC, wjoe wrote: I think that's not possible. You can't query information that hasn't been stored. I stand corrected. As Russel Winder points out there are file systems that store this information and since Linux 4.11 you can query it via statx(2).

Re: What is the point of nothrow?

2018-06-18 Thread wjoe via Digitalmars-d-learn
On Saturday, 16 June 2018 at 21:25:01 UTC, Jonathan M Davis wrote: On Saturday, June 16, 2018 18:45:53 wjoe via Digitalmars-d-learn wrote: What you said earlier: On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > [...] > > 2. If the compiler knows that a function ca

Re: What is the point of nothrow?

2018-06-12 Thread wjoe via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 18:41:07 UTC, Jonathan M Davis wrote: On Tuesday, June 12, 2018 17:38:07 wjoe via Digitalmars-d-learn wrote: On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > On Sunday, June 10, 2018 23:59:17 Bauss via > Digitalmars-d-learn > wrote:

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 03:14:33 UTC, Jonathan M Davis wrote: Most programs do not handle the case where they run out of memory and cannot continue at that point. For better or worse, D's GC was designed with that in mind, and it treats failed allocations as an Error. In the vast

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 13:05:44 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 10:56:41 UTC, wjoe wrote: I understand the idea that an Error is not supposed to be caught but why would such a 'feature' be desirable? Where's the benefit if nothing can be relied upon ? It's a

Re: What is the point of nothrow?

2018-06-13 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 12:59:27 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 02:02:54 UTC, wjoe wrote: it is possible to install a signal handler for almost every signal on POSIX, including segfault. The only signal you can't catch is signal 9 - sigkill if memory serves. So I could

Re: What is the point of nothrow?

2018-06-12 Thread wjoe via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:48:58 UTC, Bauss wrote: Ex. int a = array[400]; Could yield a warning stating a possible a out of bounds error. Where: int a = array.length >= 401 ? array[400] : 0; looks to me like a crash guard. Similar to something like this void fn(Foo* foo) { if

Re: What is the point of nothrow?

2018-06-12 Thread wjoe via Digitalmars-d-learn
On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: On Sunday, June 10, 2018 23:59:17 Bauss via Digitalmars-d-learn wrote: Errors are supposed to kill the program, not get caught. As such, why does it matter if it can throw an Error? Now, personally, I'm increasingly of the

Re: What is the point of nothrow?

2018-06-14 Thread wjoe via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 20:08:06 UTC, Jonathan M Davis wrote: On Wednesday, June 13, 2018 10:56:41 wjoe via Digitalmars-d-learn wrote: On Wednesday, 13 June 2018 at 03:14:33 UTC, Jonathan M Davis > regardless of whether the decision to treat failed memory > allocations as an

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a database. No, you can't. Once the Error was thrown the program is in invalid state and you can't assume

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 June 2018 at 17:27:13 UTC, bauss wrote: On Friday, 15 June 2018 at 17:25:18 UTC, wjoe wrote: On Thursday, 14 June 2018 at 22:27:42 UTC, bauss wrote: On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: So in case of a thrown Error, you can catch it and log it to a

Re: What is the point of nothrow?

2018-06-15 Thread wjoe via Digitalmars-d-learn
On Friday, 15 June 2018 at 08:13:44 UTC, Kagamin wrote: On Wednesday, 13 June 2018 at 17:08:26 UTC, wjoe wrote: My question was more like what's the benefit of having thrown Errors corrupt your program state rendering it useless for debugging ? D allows various levels of performance and

Re: What is the point of nothrow?

2018-06-16 Thread wjoe via Digitalmars-d-learn
On Thursday, 14 June 2018 at 19:06:07 UTC, Jonathan M Davis wrote: On Thursday, June 14, 2018 18:11:20 wjoe via Digitalmars-d-learn wrote: On Wednesday, 13 June 2018 at 20:08:06 UTC, Jonathan M Davis wrote: > On Wednesday, June 13, 2018 10:56:41 wjoe via > The idea is that because your p

How to force DUB to make and use a dynamic library

2018-06-12 Thread wjoe via Digitalmars-d-learn
Hello, I'm not sure if this belongs here, so, sorry if it doesn't. The problem I have is this as follows: given... ...a C library, let's call it libfoo, which implements an API ...a D library, libbar, which wraps the libfoo API and provides some additional convenience functions; in the DUB

Re: What is the point of nothrow?

2018-06-23 Thread wjoe via Digitalmars-d-learn
On Thursday, 21 June 2018 at 19:52:25 UTC, Jonathan M Davis wrote: On Thursday, June 21, 2018 13:16:28 wjoe via Digitalmars-d-learn wrote: On Wednesday, 20 June 2018 at 12:22:33 UTC, Kagamin wrote: > Do you know how to extract information from it on an > unfamiliar OS? Reading stack

Re: What is the point of nothrow?

2018-06-19 Thread wjoe via Digitalmars-d-learn
On Tuesday, 19 June 2018 at 12:26:15 UTC, Kagamin wrote: On Friday, 15 June 2018 at 17:46:02 UTC, wjoe wrote: D allows various levels of performance and safety. Though I'd say Errors not working in debug mode is not intended, the Intention matters not. By definition all program state is

Re: What is the point of nothrow?

2018-06-21 Thread wjoe via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 12:22:33 UTC, Kagamin wrote: On Tuesday, 19 June 2018 at 15:03:49 UTC, wjoe wrote: But maybe I missed something else and the only purpose of D is to make console applications for *NIX like OSs and expect users to be professional enough to save that stack trace

Re: What is the point of nothrow?

2018-06-19 Thread wjoe via Digitalmars-d-learn
On Monday, 18 June 2018 at 20:23:48 UTC, Jonathan M Davis wrote: On Monday, June 18, 2018 15:22:48 wjoe via Digitalmars-d-learn wrote: On Saturday, 16 June 2018 at 21:25:01 UTC, Jonathan M Davis wrote: > every feature that you can't use in betterC is considered a > loss, and efforts are

DUB conditional subPackage possible?

2019-04-11 Thread wjoe via Digitalmars-d-learn
I want to include subPackages depending either on the presence of command line options, or the availability of dependencies; think Gentoo USE flags. As far as I can tell it's not possible to specify configurations in a modular way, e.g. dub --config=withGUI --config=supportGTK

Re: What Does @ Mean?

2019-04-12 Thread wjoe via Digitalmars-d-learn
On Monday, 8 April 2019 at 12:16:13 UTC, Adam D. Ruppe wrote: On Monday, 8 April 2019 at 11:58:49 UTC, Ron Tarrant wrote: And while I'm asking, does an underscore have special meaning when used either at the beginning or end of a variable name? Nothing special there, you are allowed to use

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-27 Thread wjoe via Digitalmars-d-learn
On Thursday, 16 May 2019 at 15:52:05 UTC, Steven Schveighoffer wrote: On 5/16/19 4:27 PM, Vladimir Panteleev wrote: On Thursday, 16 May 2019 at 15:19:03 UTC, Alex wrote: What's an hnsec anyways? Hecto-nano-second, the smallest representable unit of time in SysTime and Duration. The

Re: [windows] Can't delete a closed file?

2019-05-10 Thread wjoe via Digitalmars-d-learn
On Thursday, 9 May 2019 at 10:09:23 UTC, Cym13 wrote: Hi, this is likely not related to D itself but hopefully someone can help me with this since I'm rather new to windows programming, I mainly work on linux. I'm trying to bundle a DLL in a binary, write it in a temp folder, use it and

Re: Setting default values for Main function's args Array

2019-06-27 Thread wjoe via Digitalmars-d-learn
On Thursday, 27 June 2019 at 17:05:05 UTC, Vaidas wrote: Is it possible to set the default values for the Main function's arguments? It seems that I'm getting Range error. import std.stdio : writeln; void main(string[] args = ["asdsfasdf", "asdklfajsdk", "asdfasdfasd"]){ writeln("",

Re: Abstract classes vs interfaces, casting from void*

2019-08-14 Thread wjoe via Digitalmars-d-learn
On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class? (Other than multiple inheritance). I'm such a noob at

can DDOC generate files names including the full path ?

2019-08-14 Thread wjoe via Digitalmars-d-learn
For example if the source tree looks like this: source/ foo/ baz.d bar/ baz.d and generating the docs with something like this: dmd -D -Dd=docs foo/baz.d bar/baz.d the output looks like this: docs/ baz.html one baz overwrites the other. I'd like to have something like

Re: Desktop app with vibe.d

2019-08-14 Thread wjoe via Digitalmars-d-learn
On Monday, 12 August 2019 at 10:41:57 UTC, GreatSam4sure wrote: Pls I want to know if it is possible to build desktop app with vibe.d just like nodejs. I am not satisfy with the GUI of Dlang such as dlangui and gtkd. I don't think they have good styling capabilities like HTML and CSS. I will

Re: can DDOC generate files names including the full path ?

2019-08-19 Thread wjoe via Digitalmars-d-learn
On Monday, 19 August 2019 at 04:23:48 UTC, Jonathan M Davis wrote: [...] Thanks for the explanation. I'm in quite a dilemma now as I can't decide on which to choose :)