On Sunday, 31 January 2016 at 20:10:03 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:07:26 UTC, Steven
Schveighoffer wrote:
What is likely happening is that ptr is already collected, and
you are invalidly attempting to re-free it.
The GC can collect this memory even though there is
On Sunday, 31 January 2016 at 20:07:26 UTC, Steven Schveighoffer
wrote:
What is likely happening is that ptr is already collected, and
you are invalidly attempting to re-free it.
The GC can collect this memory even though there is still an
outstanding root-reachable pointer to it?
On Sunday, 31 January 2016 at 20:20:52 UTC, Steven Schveighoffer
wrote:
On 1/31/16 3:15 PM, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:11:07 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:10:03 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:07:26 UTC, Steven
On Sunday, 31 January 2016 at 20:20:52 UTC, Steven Schveighoffer
wrote:
Oh, nevermind. This is actually simpler.
You can't do memory operations inside a destructor during
collection. I forgot about that.
But the rule I stated is still in force.
-Steve
So this implies that the UniquePtr
On 1/31/16 4:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively tested it.
There's probably a simpler way but this is the first thing I could come
up with that works.
Thanks! I was surprised this is not straightforward.
-Steve
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer
wrote:
On 1/31/16 4:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively
tested it.
There's probably a simpler way but this is the first thing I
could come
up with that works.
Thanks! I was
On Sunday, 31 January 2016 at 19:51:34 UTC, Enjoys Math wrote:
On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote:
This weird exception keeps occuring and visual D is not
bringing me to the place in my code that might be calling it.
[...]
The exception is not listed in the
Hi!
I need to read bad-formed json files in type-tolerant mode, and
my idea is to make JSONValue-specific 'to' method which will
convert it to target type if applicable, else throw exception.
Like this:
import std.json;
unittest
{
JSONValue s="123";
JSONValue i=123;
JSONValue
I know I can mark an argument ref to require lvalues, so I'm
wondering whether there is an equivalent for rvalues; that is, is
there a way to specify that an argument to a function MUST be an
rvalue?
For example, in C++ I can do this:
[code]
void foo(int && x) {...}
foo(5); // Works fine
int
On Sunday, 31 January 2016 at 17:42:19 UTC, anonymous wrote:
On 31.01.2016 18:21, Matt Elkins wrote:
I know I can mark an argument ref to require lvalues, so I'm
wondering
whether there is an equivalent for rvalues; that is, is there
a way to
specify that an argument to a function MUST be an
Errr, ignore the makeFoo() line. Left that in by accident, has no
bearing on the issue.
On Sunday, 31 January 2016 at 19:34:43 UTC, maik klein wrote:
I recently asked a question about ownership semantics in D
https://stackoverflow.com/questions/35115702/how-do-i-express-ownership-semantics-in-d
But a few minutes ago I found an answer on SO that could
potentially explain a lot.
On Sunday, 31 January 2016 at 18:02:19 UTC, Matt Elkins wrote:
Here is the one I am using right now:
Actually, here is the whole module in case you are interested in
the unittests/usage:
[code]
import std.algorithm;
import std.traits;
struct ResourceHandle(T, alias Deleter, T Default =
I have:
class OperatorV(T) : Value {
T impl;
this(T impl) {
this.impl = impl;
}
...
and use it like this: makeOperator((IntV a, IntV b) => new IntV(a.num +
b.num));
Now I want to do: opWord.get() returns a Value
OperatorV *op = cast(OperatorV*)(opWord.get());
and get: Error: class
This weird exception keeps occuring and visual D is not bringing
me to the place in my code that might be calling it.
Message:
First-chance exception: std.format.FormatException Unterminated
format specifier: "%" at
C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(830)
I've gotten rid
On 1/31/16 2:34 PM, maik klein wrote:
I recently asked a question about ownership semantics in D
https://stackoverflow.com/questions/35115702/how-do-i-express-ownership-semantics-in-d
But a few minutes ago I found an answer on SO that could potentially
explain a lot.
struct S
{
int x;
ref int y() { return x; }
int z() { return 1; }
}
What can I use, given S, to determine that x and y yield lvalues, while
z yields an rvalue?
I was expecting something like isLvalue somewhere, but cannot find it.
__traits(isRef, ...) doesn't work.
-Steve
On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote:
This weird exception keeps occuring and visual D is not
bringing me to the place in my code that might be calling it.
[...]
The exception is not listed in the Exception Settings checkable
list. I will try commenting out the D
On 1/31/16 3:15 PM, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:11:07 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:10:03 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:07:26 UTC, Steven Schveighoffer wrote:
What is likely happening is that ptr is already
Hello all,
I'm having a *really* weird problem (at least I think so). I
have a function on a struct that converts it into JSON.
Everything works, no big deal. But when I try to turn that
JSONValue into a string, I get a UTF-8 Error. What makes it even
weirder, is that if I call toJSON
On Sunday, 31 January 2016 at 17:21:54 UTC, Matt Elkins wrote:
I know I can mark an argument ref to require lvalues, so I'm
wondering whether there is an equivalent for rvalues; that is,
is there a way to specify that an argument to a function MUST
be an rvalue?
For example, in C++ I can do
On Sunday, 31 January 2016 at 20:11:07 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:10:03 UTC, Matt Elkins wrote:
On Sunday, 31 January 2016 at 20:07:26 UTC, Steven
Schveighoffer wrote:
What is likely happening is that ptr is already collected,
and you are invalidly attempting to
On Sunday, 31 January 2016 at 02:58:28 UTC, Andrew Edwards wrote:
If I understand correctly, this piece of code:
enum NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) );
} while(0)
can be converted to the following in D:
void notUsed(T)(T v) { return cast(void)0; };
since it
Hi,
we start with the following code snippet, which works.
import std.algorithm;
import std.range;
import std.stdio;
class A { int val; }
class B : A { this() { val = 3; } }
class C : A { this() { val = 4; } }
B[] b = [new B(), new B()];
C[] c = [new C(),
On 31.01.2016 18:21, Matt Elkins wrote:
I know I can mark an argument ref to require lvalues, so I'm wondering
whether there is an equivalent for rvalues; that is, is there a way to
specify that an argument to a function MUST be an rvalue?
For example, in C++ I can do this:
[code]
void foo(int
On Sunday, 31 January 2016 at 17:42:19 UTC, anonymous wrote:
I don't know if this works in all cases, but it passes that
simple test:
@disable void foo(ref int x);
void foo(int x) {}
void main()
{
foo(5); /* works */
int y = 5;
foo(y); /* error */
}
My fault, I should
I would like to get a view of the amount of memory that my
application requires over time, but this does not seem to be
trivial in D.
1) I assume the garbage collector could keep around memory that
my application is no longer using. If this is the case then no
external memory profiler is
On Sunday, 31 January 2016 at 17:55:53 UTC, Matt Elkins wrote:
Errr, ignore the makeFoo() line. Left that in by accident, has
no bearing on the issue.
I have found an interesting SO answer
http://stackoverflow.com/a/35114945/944430
This would explain everything that we would need. I am just
On Sunday, 31 January 2016 at 17:48:53 UTC, maik klein wrote:
The problem is that x will be copied afaik which is not what
you want if you want to deal with ownership.
I think that can be solved by wrapping the resource in a struct
that deals with passing the ownership. Here is the one I am
On Sunday, 31 January 2016 at 17:55:53 UTC, Matt Elkins wrote:
Errr, ignore the makeFoo() line. Left that in by accident, has
no bearing on the issue.
Ok, I think I understand why this doesn't work, at least. The Foo
passed into bar() is, of course, an lvalue itself.
So I can achieve this
I recently asked a question about ownership semantics in D
https://stackoverflow.com/questions/35115702/how-do-i-express-ownership-semantics-in-d
But a few minutes ago I found an answer on SO that could
potentially explain a lot.
http://stackoverflow.com/a/35114945/944430
Sadly it has some
On Sun, 31 Jan 2016 19:59:01 +0100, Robert M. Münch wrote:
> I have:
>
> class OperatorV(T) : Value {
> T impl;
>
> this(T impl) {
> this.impl = impl;
> }
> ...
This expands to:
template OperatorV(T) {
class OperatorV {
...
}
}
If you're just typing `OperatorV` with no
On Sunday, 31 January 2016 at 20:49:43 UTC, Steven Schveighoffer
wrote:
struct S
{
int x;
ref int y() { return x; }
int z() { return 1; }
}
What can I use, given S, to determine that x and y yield
lvalues, while z yields an rvalue?
I was expecting something like isLvalue somewhere, but
On 01/31/2016 02:52 PM, Alex Herrmann wrote:
> Note that I am running 2.070.0.
Then it's probably a bug related to this change:
http://dlang.org/changelog/2.070.0.html#json-encode-control-characters
Ali
On Monday, 1 February 2016 at 07:41:33 UTC, Namal wrote:
I understand that I cannot pass a variable to the static array
like in C++, and have to use dynamic arrays. But how can I set
the length for them without using a loop?
I mean std::vector in C++, not array.
On Monday, 1 February 2016 at 07:42:56 UTC, Namal wrote:
On Monday, 1 February 2016 at 07:41:33 UTC, Namal wrote:
I understand that I cannot pass a variable to the static array
like in C++, and have to use dynamic arrays. But how can I set
the length for them without using a loop?
I mean
Just out of curiosity, does anyone have an octree implementation
for D laying around? Just looking to save some time.
On Sunday, January 31, 2016 17:48:53 maik klein via Digitalmars-d-learn wrote:
> On Sunday, 31 January 2016 at 17:42:19 UTC, anonymous wrote:
> > On 31.01.2016 18:21, Matt Elkins wrote:
> > I don't know if this works in all cases, but it passes that
> > simple test:
> >
> >
> > @disable void
On Monday, 1 February 2016 at 00:24:06 UTC, Ali Çehreli wrote:
On 01/31/2016 02:52 PM, Alex Herrmann wrote:
> Note that I am running 2.070.0.
Then it's probably a bug related to this change:
http://dlang.org/changelog/2.070.0.html#json-encode-control-characters
Ali
This problem is
On Sunday, 31 January 2016 at 21:22:06 UTC, SimonN wrote:
Hi,
we start with the following code snippet, which works.
import std.algorithm;
import std.range;
import std.stdio;
class A { int val; }
class B : A { this() { val = 3; } }
class C : A { this() { val = 4; }
On 01/31/2016 01:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively tested it.
There is hasLvalueElements() as well. Its implementation my be similar
or give other ideas:
https://dlang.org/phobos/std_range_primitives.html#hasLvalueElements
Ali
On 01.02.2016 01:29, Alex Herrmann wrote:
This problem is solved! Sorry for not updating the question.
It was actually a problem with me not iduping it, and the memory being
reclaimed or something similar. I did also change to stdx.data.json
(std_data_json on dub).
You don't seem to be clear
On Monday, 1 February 2016 at 00:20:00 UTC, Ali Çehreli wrote:
On 01/31/2016 01:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively
tested it.
There is hasLvalueElements() as well. Its implementation my be
similar or give other ideas:
I hope that here I will get answer faster then on
https://github.com/buggins/ddbc/issues/18
I am using ddbc diver for access to mysql. I need to return
result of request to struct. My code is next:
import std.stdio;
import ddbc.all;
import std.stdio;
import std.conv;
void main()
{
I am getting runtime error:
core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure
if LEN equals to 3, 5, 7, 9, ...
void main(string[] args) {
ubyte[1024] memory;
auto stackAlloc = Region!NullAllocator(memory);
IAllocator
45 matches
Mail list logo