implicit or module-wide @nogc

2018-06-12 Thread Gokhhy via Digitalmars-d-learn
Is there a way to define an entire module as @nogc or otherwise make it so I don't have to qualify every single function as @nogc?

Re: remove not callable for char[]

2018-06-12 Thread Flaze07 via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:08:25 UTC, Steven Schveighoffer wrote: On 6/12/18 2:33 AM, Flaze07 wrote: well, not really, it just cannot auto deduce, the problem is, I don't know what to put in, I know that I can put in SwapStrategy.stable for the first one, but what about the Range, I don't

returning to thrown

2018-06-12 Thread DigitalDesigns via Digitalmars-d-learn
I have to modify preexisting code. As of now, the code fails and throws an exception at some point. I need to prevent the code from throwing(easy) but signal to the user of the code some notification(hard). It would be cool if I could throw an exception as if the code yielded and it could be

Re: What is the point of nothrow?

2018-06-12 Thread Neia Neutuladh via Digitalmars-d-learn
On Wednesday, 13 June 2018 at 00:38:55 UTC, Jonathan M Davis wrote: It's possible to write programs that check and handle running out of memory, but most programs don't, and usually, if a program runs out of memory, it can't do anything about it and can't function properly at that point. Simu

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 13, 2018 02:02:54 wjoe via Digitalmars-d-learn wrote: > 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 > >> > >> wr

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: > Errors are su

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 12, 2018 23:32:55 Neia Neutuladh via Digitalmars-d-learn wrote: > On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: > > Why do you care about detecting code that can throw an Error? > > Errors are supposed to kill the program, not get caught. As > > such, why does i

Re: Orange check failling all of a sudden

2018-06-12 Thread DigitalDesigns via Digitalmars-d-learn
Also, is there any way to have a field as optional? Right now when I update a filed in a serialized type the app crashes because it can't find the field in the serialized data(since it was just added in the code). This requires either regenerating the data or manually adding the serialized fiel

Re: What is the point of nothrow?

2018-06-12 Thread Neia Neutuladh via Digitalmars-d-learn
On Monday, 11 June 2018 at 00:47:27 UTC, Jonathan M Davis wrote: Why do you care about detecting code that can throw an Error? Errors are supposed to kill the program, not get caught. As such, why does it matter if it can throw an Error? Error is currently used for three different things: * Th

Re: How can I enforce an parameter to be constant know at compile time?

2018-06-12 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 18:27:17 UTC, Dr.No wrote: I'd like help of compiler to check this: consider this: int f(int n) { m_n = n; } f(10); // ok f(myTampleteFunction!(compileTimeParameter)); // ok enum n = 10; f(n); // I won't use this, but should also be ok int x = 10; f(x); // error i

Re: class X has forward references

2018-06-12 Thread Ali Çehreli via Digitalmars-d-learn
On 06/12/2018 01:14 PM, bauss wrote: > What could cause that error? Could be this point apparently during semantic analysis: https://github.com/dlang/dmd/blob/4e35f945e3245467c7ae0abe60fc3ec896c8b45f/src/dmd/semantic2.d#L576 private extern(C++) final class Semantic2Visitor : Visitor { // .

Re: class X has forward references

2018-06-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 20:30:22 UTC, Steven Schveighoffer wrote: On 6/12/18 4:14 PM, bauss wrote: What could cause that error? I cannot find anything in the documentation nor does the error message itself give much information. A forward reference that can't be figured out by the compil

Re: class X has forward references

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 4:14 PM, bauss wrote: What could cause that error? I cannot find anything in the documentation nor does the error message itself give much information. A forward reference that can't be figured out by the compiler. This is one of the DMD front end's real weak spots. I can't real

class X has forward references

2018-06-12 Thread bauss via Digitalmars-d-learn
What could cause that error? I cannot find anything in the documentation nor does the error message itself give much information. I can't really give a good example, but I can tell as much as I have a few inheritances of classes using templates. I just don't think that would be the issue.

Re: What is the point of nothrow?

2018-06-12 Thread Jonathan M Davis via Digitalmars-d-learn
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: > > Errors are supposed to kill the program, not get caught. As > > such, why does

Re: How can I enforce an parameter to be constant know at compile time?

2018-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 18:27:17 UTC, Dr.No wrote: How can I enforce that? Only way is to make it a compile time (template) param.

How can I enforce an parameter to be constant know at compile time?

2018-06-12 Thread Dr.No via Digitalmars-d-learn
I'd like help of compiler to check this: consider this: int f(int n) { m_n = n; } f(10); // ok f(myTampleteFunction!(compileTimeParameter)); // ok enum n = 10; f(n); // I won't use this, but should also be ok int x = 10; f(x); // error int g() { return 20; } f(g); // error How can I enforce

Re: LDC: Where is this supposed to link to?

2018-06-12 Thread Dukc via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 17:41:46 UTC, Adam D. Ruppe wrote: No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory. And, just in case somebody at a later date has the same question, I found

Re: LDC: Where is this supposed to link to?

2018-06-12 Thread Dukc via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 17:41:46 UTC, Adam D. Ruppe wrote: No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory. That explains it. Well, back to exploring. Thank you.

Re: LDC: Where is this supposed to link to?

2018-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 17:37:30 UTC, Dukc wrote: All DRuntime code the compiler can invoke directly is in object.d, is that right? No, actually very little of it is there. Most the code the compiler calls into is found in the compiled druntime lib, like in the druntime/src/rt directory.

LDC: Where is this supposed to link to?

2018-06-12 Thread Dukc via Digitalmars-d-learn
I have just managed to include a bit D code in a C# project compiled to Javascript. I am already looking at extending LDC runtime to open more possibilites, but something seems fishy. All DRuntime code the compiler can invoke directly is in object.d, is that right? When I try to copy a slice

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 opinio

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 (foo

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 conf

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 16:27:50 UTC, SrMordred wrote: On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad. Well, not anymore ;)

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad.

Re: What is the point of nothrow?

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 11:48 AM, Bauss wrote: On Tuesday, 12 June 2018 at 14:19:42 UTC, Steven Schveighoffer wrote: On 6/10/18 7:59 PM, Bauss wrote: What is the point of nothrow if it can only detect when Exception is thrown and not when Error is thrown? It seems like the attribute is useless because you

Re: What is the point of nothrow?

2018-06-12 Thread Bauss via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:19:42 UTC, Steven Schveighoffer wrote: On 6/10/18 7:59 PM, Bauss wrote: What is the point of nothrow if it can only detect when Exception is thrown and not when Error is thrown? It seems like the attribute is useless because you can't really use it as protection

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:57 AM, Guillaume Piolat wrote: On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: Note to ponce, please update your idioms, this is NOT safe, even within the same function. Just because it does work, doesn't mean it will always work. The language makes no guar

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:54 AM, Seb wrote: On Tuesday, 12 June 2018 at 14:35:33 UTC, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits)

Re: How to sort byCodeUnit.permutations.filter(...)

2018-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:16:25 UTC, Uknown wrote: I solved the problem by piping the output to `sort` that works but is probably less efficient since sorting the whole thing just to get the one element is more work but eh. I'll submit a bug report on this ASAP. I really don't think

Re: How to sort byCodeUnit.permutations.filter(...)

2018-06-12 Thread Uknown via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:21:48 UTC, Adam D. Ruppe wrote: On Monday, 11 June 2018 at 04:39:54 UTC, Uknown wrote: Why are the strings getting modified? I'm guessing it reuses a buffer as it iterates. "123".byCodeUnit.permutations.writeln;//[123, 213, 312, 132, 231, 321] [...]

Is there a suffix tree or suffix array implementations in D

2018-06-12 Thread eastanon via Digitalmars-d-learn
Maybe I have not searched well, but I am wondering whether there are suffix tree or suffix array implementations in D. I have seen a couple from other programming languages and before I translate one to D, there could be a something existing already.

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: What you are being told is that your memory is not being kept around. Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Don't do that anymore! And a reminder that t

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Guillaume Piolat via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:44:12 UTC, Steven Schveighoffer wrote: Note to ponce, please update your idioms, this is NOT safe, even within the same function. Just because it does work, doesn't mean it will always work. The language makes no guarantees once the lifetime is over. -Steve

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Seb via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 14:35:33 UTC, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n]

Re: Static Array Idiom not working anymore.

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 10:35 AM, SrMordred wrote: this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n] array) pure nothro

Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc @safe { return array; } void

Re: How to sort byCodeUnit.permutations.filter(...)

2018-06-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 11 June 2018 at 04:39:54 UTC, Uknown wrote: Why are the strings getting modified? I'm guessing it reuses a buffer as it iterates. "123".byCodeUnit.permutations.writeln;//[123, 213, 312, 132, 231, 321] so here, it switches them, prints, switches, prints, switches, prints,e tc "

Re: What is the point of nothrow?

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/10/18 7:59 PM, Bauss wrote: What is the point of nothrow if it can only detect when Exception is thrown and not when Error is thrown? It seems like the attribute is useless because you can't really use it as protection to write bugless, safe code since the nasty bugs will pass by just fi

Re: What is the point of nothrow?

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/11/18 5:23 PM, Jonathan M Davis wrote: On Monday, June 11, 2018 20:45:52 Dave Jones via Digitalmars-d-learn wrote: So the only solution I could figure is to catch throwable in the callback function, dump the message, and then PostQuitMessage(0). It just seems retarded that Throwables can st

Re: remove not callable for char[]

2018-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/12/18 2:33 AM, Flaze07 wrote: well, not really, it just cannot auto deduce, the problem is, I don't know what to put in, I know that I can put in SwapStrategy.stable for the first one, but what about the Range, I don't know what to put in E.g int[] i = [ 1, 2 ]; i = i.remove( 1 );//able to

Re: What is the point of nothrow?

2018-06-12 Thread Kagamin via Digitalmars-d-learn
On Sunday, 10 June 2018 at 23:59:17 UTC, Bauss wrote: To me it would be so much more useful if you could detect code that could possibly throw Error. Such things are usually done by formal verification systems like F*, and I suppose Ada 2012 has it to some extent too. Though I suspect it's no

Re: Is there a better way to do this? (Using class at compile-time)

2018-06-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 11:18:00 UTC, Simen Kjærås wrote: On Tuesday, 12 June 2018 at 11:04:40 UTC, bauss wrote: [snip] void test(T)() { pragma(msg, (getBar!T).baz()); pragma(msg, (getBar!T).helloworld()); import std.stdio; mixin((getBar!T).baz()); mixin((getBar!T).hell

Re: Is there a better way to do this? (Using class at compile-time)

2018-06-12 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 11:04:40 UTC, bauss wrote: [snip] void test(T)() { pragma(msg, (getBar!T).baz()); pragma(msg, (getBar!T).helloworld()); import std.stdio; mixin((getBar!T).baz()); mixin((getBar!T).helloworld()); } [snip] Is there a way to avoid having to write "g

Is there a better way to do this? (Using class at compile-time)

2018-06-12 Thread bauss via Digitalmars-d-learn
Let's say I have something like the following: abstract class Foo { abstract string baz(); abstract string helloworld(); } final class Bar(T) : Foo { override string baz() { return "writeln(\"Hello " ~ T.stringof ~ "!\");"; } override string helloworld() { return "writeln(\"Hell