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?
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
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
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
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
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
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
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
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
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
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
{
// .
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
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
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.
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
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.
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
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
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.
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.
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
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
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
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
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 ;)
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.
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
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
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
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)
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
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]
[...]
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.
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
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
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]
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
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
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
"
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
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
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
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
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
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
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
46 matches
Mail list logo