cyclic redundancy

2018-06-18 Thread Mr.Bingo via Digitalmars-d-learn
I have static this scattered throughout. Some are module static this and some are struct and class. In a test case I have reduced to a struct that uses a static this and I get a cycle... even though, of course, the static this does nothing accept internal things. It is very annoying to have

Re: scope(success) lowered to try-catch ?

2018-06-18 Thread Cauterite via Digitalmars-d-learn
On Monday, 18 June 2018 at 03:58:47 UTC, Neia Neutuladh wrote: ... yeah, at an AST level it makes sense why it was implemented like this. it's unfortunate that there's no straightforward way to express 'finally(success) {'.

Re: Debugging silent exit of threads in Phobos calls

2018-06-18 Thread Russel Winder via Digitalmars-d-learn
For anyone still interested in this problem: Steve's pull request fixing the problem is included in D 2.081.0. I can experiment as soon as DMD 2.081.0 is released but will have to wait till the fixes get into LDC to create production code. Moral of the story: silent, except during gdb debugging,

Re: cyclic redundancy

2018-06-18 Thread Mr.Bingo via Digitalmars-d-learn
I got tired of waiting for a solution and rolled my own: static this() { import std.meta, std.stdio; // Find all ___This functions linked to this module auto Iterate()() { string[string] s; void Iterate2(alias m, int depth = 0)()

how to determine of a module or any other symbol is visible?

2018-06-18 Thread Mr.Bingo via Digitalmars-d-learn
In the code I posted before about CRC, sometimes I get a visibility error for some modules. I would like to be able to filter those out using traits. Is there any way to determine if a module is visible/reachable in the current scope? The modules that are causing the problems are imported from

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread rikki cattermole via Digitalmars-d-learn
On 18/06/2018 9:03 PM, Mr.Bingo wrote: In the code I posted before about CRC, sometimes I get a visibility error for some modules. I would like to be able to filter those out using traits. Is there any way to determine if a module is visible/reachable in the current scope? The modules that ar

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Mr.Bingo via Digitalmars-d-learn
On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: On 18/06/2018 9:03 PM, Mr.Bingo wrote: In the code I posted before about CRC, sometimes I get a visibility error for some modules. I would like to be able to filter those out using traits. Is there any way to determine if a modul

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread rikki cattermole via Digitalmars-d-learn
On 18/06/2018 9:24 PM, Mr.Bingo wrote: On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: On 18/06/2018 9:03 PM, Mr.Bingo wrote: In the code I posted before about CRC, sometimes I get a visibility error for some modules. I would like to be able to filter those out using traits. I

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 18, 2018 21:28:00 rikki cattermole via Digitalmars-d-learn wrote: > On 18/06/2018 9:24 PM, Mr.Bingo wrote: > > On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: > >> On 18/06/2018 9:03 PM, Mr.Bingo wrote: > >>> In the code I posted before about CRC, sometimes I get a

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS does not work for nested functions, and was wondering whether that's intended, and what the rationale behind it is: I just had the same question. I can imagine that the context pointer of nested fun

Create a List or Dictionary.

2018-06-18 Thread Sunny via Digitalmars-d-learn
Hello, I'm having a problem, how can I create a List or Dictionary in D? In C #, I can create a tuple list, example: var musicList = new List <(string URL, string Artist, string Title, string Cover, string Duration)> (); In Google did not find anything, tell me please how to get out of this

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Cauterite via Digitalmars-d-learn
On Monday, 18 June 2018 at 09:28:00 UTC, rikki cattermole wrote: On 18/06/2018 9:24 PM, Mr.Bingo wrote: On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole wrote: This doesn't work with depreciation warnings. There won't be a way to check for those (I think). Easier to not worry about t

Re: Create a List or Dictionary.

2018-06-18 Thread rikki cattermole via Digitalmars-d-learn
On 18/06/2018 11:44 PM, Sunny wrote: Hello, I'm having a problem, how can I create a List or Dictionary in D? In C #, I can create a tuple list, example: var musicList = new List <(string URL, string Artist, string Title, string Cover, string Duration)> (); In Google did not find anything, t

Re: scope(success) lowered to try-catch ?

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/17/18 11:58 PM, Neia Neutuladh wrote: On Sunday, 17 June 2018 at 10:58:29 UTC, Cauterite wrote: Is there a reason scope(success) needs to set up for exception handling? Or is this a bug / potential enhancement ? If you had no exception handling in place, you'd need to duplicate code in t

Re: Create a List or Dictionary.

2018-06-18 Thread Cym13 via Digitalmars-d-learn
On Monday, 18 June 2018 at 11:44:43 UTC, Sunny wrote: Hello, I'm having a problem, how can I create a List or Dictionary in D? In C #, I can create a tuple list, example: var musicList = new List <(string URL, string Artist, string Title, string Cover, string Duration)> (); In Google did no

Re: cyclic redundancy

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 3:19 AM, Mr.Bingo wrote: I have static this scattered throughout. Some are module static this and some are struct and class. In a test case I have reduced to a struct that uses a static this and I get a cycle... even though, of course, the static this does nothing accept internal

Re: cyclic redundancy

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 4:45 AM, Mr.Bingo wrote: I got tired of waiting for a solution and rolled my own: static this() { import std.meta, std.stdio; // Find all ___This functions linked to this module auto Iterate()() {     string[string] s;     void Iterate2(alias m, int d

Re: UCFS does not work for nested functions?

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS does not work for nested functions, and was wondering whether that's intended, and what the rationale behind it is: I just had the same question. I can ima

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 can't throw a

Re: UCFS does not work for nested functions?

2018-06-18 Thread aliak via Digitalmars-d-learn
On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS does not work for nested functions, and was wondering whether that's intended, and what

Re: scope(success) lowered to try-catch ?

2018-06-18 Thread aliak via Digitalmars-d-learn
On Monday, 18 June 2018 at 12:48:46 UTC, Steven Schveighoffer wrote: On 6/17/18 11:58 PM, Neia Neutuladh wrote: [...] Yep, it's a good point. But also not the only way to do this. If you are returning void, just a goto would work: [...] I'm quite a noob when it comes to compiler stuff, an

Re: UCFS does not work for nested functions?

2018-06-18 Thread bauss via Digitalmars-d-learn
On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote: On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS does not work for nested functions

Re: UCFS does not work for nested functions?

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 1:25 PM, bauss wrote: On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote: On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS d

Re: how to determine of a module or any other symbol is visible?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 18, 2018 11:53:50 Cauterite via Digitalmars-d-learn wrote: > On Monday, 18 June 2018 at 09:28:00 UTC, rikki cattermole wrote: > > On 18/06/2018 9:24 PM, Mr.Bingo wrote: > >> On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole > >> wrote: > >> This doesn't work with depreciatio

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer wrote: On 6/18/18 1:25 PM, bauss wrote: On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote: On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at

Re: UCFS does not work for nested functions?

2018-06-18 Thread aliak via Digitalmars-d-learn
On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer wrote: What then can happen is that your local calls can get hijacked from outside the module, if someone happens to define something later that you happened to import. D tries to avoid such possibilities. There's not much preceden

Re: UCFS does not work for nested functions?

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 2:58 PM, aliak wrote: On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer wrote: What then can happen is that your local calls can get hijacked from outside the module, if someone happens to define something later that you happened to import. D tries to avoid such possibili

Re: UCFS does not work for nested functions?

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 2:57 PM, Bastiaan Veelo wrote: On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer wrote: On 6/18/18 1:25 PM, bauss wrote: On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote: On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastia

Re: What is the point of nothrow?

2018-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
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 being made to make more of them work. > > There's always going to be a

Nothrow std.conv.to with explicit default value

2018-06-18 Thread Per Nordlöw via Digitalmars-d-learn
I have a nothrow variant of std.conv.to defined as follows: T toDefaulted(T, S, U)(S value, /*lazy*/ U defaultValue) if (is(typeof(() { T r = defaultValue; }))) // TODO use std.traits.isAssignable!(T, U) ? { try { import std.conv : to; return value.to!T; } catch

Re: Nothrow std.conv.to with explicit default value

2018-06-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 June 2018 at 20:48:55 UTC, Per Nordlöw wrote: T toDefaulted(T, S, U)(S value, /*lazy*/ U defaultValue) if (is(typeof(() { T r = defaultValue; }))) // TODO use std.traits.isAssignable!(T, U) ? why not just make it T toDefaulted(T, S)(S value, T defaultValue) and forget U entirel

Re: Nothrow std.conv.to with explicit default value

2018-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/18/18 4:48 PM, Per Nordlöw wrote: The problem with this code is that throwing exceptions for the default case is costly at least with dmd. Is there another way to do this? Yes, have an internal implementation which doesn't throw, but rather returns an error code. Then you can call that an

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 18 June 2018 at 19:31:39 UTC, Steven Schveighoffer wrote: In other words, if UFCS meant that module-level symbols took precedent over local symbols, then it's backwards in terms of which place usually wins. Generally it's the local symbols. Ah, you mean it would have to be that way

Re: UCFS does not work for nested functions?

2018-06-18 Thread aliak via Digitalmars-d-learn
On Monday, 18 June 2018 at 19:26:47 UTC, Steven Schveighoffer wrote: On 6/18/18 2:58 PM, aliak wrote: [...] It's the same in the fact that your call is silently switched to a different call. However, in the current syntax, an external entity CANNOT override a local function. When you call t

Re: Create a List or Dictionary.

2018-06-18 Thread Sunny via Digitalmars-d-learn
On Monday, 18 June 2018 at 13:23:37 UTC, Cym13 wrote: Yes, this is what need, thank you very much for your help. :-) On Monday, 18 June 2018 at 11:44:43 UTC, Sunny wrote: [...] If I read you well it seems the simplest equivalent code would be: struct MusicItem { string URL;