On Saturday, 30 January 2016 at 05:50:33 UTC, Dsby wrote:
Ok.Thank you.
and i want to know how to know when the GC start runing?
For the current implementation, any time you allocate memory
through the GC it will determine if a collection cycle is needed,
but it will not run otherwise.
On Saturday, 30 January 2016 at 06:33:55 UTC, Enjoys Math wrote:
I'm able to get the mouse click positions with
event.button().x/y
But what .x/y do you query inside of an onMotionNotify event
handler?
Thanks!
I see now:
bool onMouseMove(GdkEventMotion* eventMotion, Widget widget) {
I'm able to get the mouse click positions with event.button().x/y
But what .x/y do you query inside of an onMotionNotify event
handler?
Thanks!
On Saturday, 30 January 2016 at 05:57:20 UTC, asdf wrote:
No I've fixed it now
All I was asking for anyway was a little bit of help as to how
threads work, which "variables declared "static" or at global
scope in D are actually thread-local by default" definitely
satisfies. I wasn't really ask
On Saturday, 30 January 2016 at 05:57:34 UTC, H. S. Teoh wrote:
A common idiom that we use is to write an attributed unittest
to verify that the function itself is @safe/etc.. This way, if
instantiated with safe/etc. types, the template will also be
safe/etc., but if instantiated with an unsafe
On Sat, Jan 30, 2016 at 05:37:07AM +, Matt Elkins via Digitalmars-d-learn
wrote:
> On Saturday, 30 January 2016 at 05:25:49 UTC, Rikki Cattermole wrote:
> >On 30/01/16 6:17 PM, Matt Elkins wrote:
> >>[...]
> >
> >templated functions have attribute inference. Meaning if it can be
> >nothrow it
On Saturday, 30 January 2016 at 05:41:10 UTC, tsbockman wrote:
On Saturday, 30 January 2016 at 05:15:58 UTC, asdf wrote:
Okay so it turns out putting something in another thread is
like throwing it into an alternate universe where only my
functions exist, and instead of telling me my data doesn
Ok.Thank you.
and i want to know how to know when the GC start runing?
On Saturday, 30 January 2016 at 05:18:08 UTC, Steven
Schveighoffer wrote:
https://issues.dlang.org/enter_bug.cgi
-Steve
Added!
https://issues.dlang.org/show_bug.cgi?id=15627
Thanks for the help.
On Saturday, 30 January 2016 at 05:15:58 UTC, asdf wrote:
Okay so it turns out putting something in another thread is
like throwing it into an alternate universe where only my
functions exist, and instead of telling me my data doesn't
exist, it just silently behaves as if it's all empty
Are y
On Saturday, 30 January 2016 at 05:25:49 UTC, Rikki Cattermole
wrote:
On 30/01/16 6:17 PM, Matt Elkins wrote:
[...]
templated functions have attribute inference. Meaning if it can
be nothrow it will be.
Regarding your real use case, again struct if templated so it
should be inferred.
Conve
On 30/01/16 6:17 PM, Matt Elkins wrote:
Is there any way to specify that a generic function is conditionally
nothrow (or other function decorators), based on whether the template
instantiation is nothrow? I'm looking for something akin to C++'s
noexcept(noexcept()), e.g.:
template void foo() no
On 1/29/16 11:53 PM, Matt Elkins wrote:
Title says it; I get an access violation in code marked @safe. Here's a
minimal example:
[code]
@safe:
struct Foo(alias Callback)
{
~this() {Callback();}
}
unittest
{
uint stackVar;
alias FooType = Foo!((){++stackVar;});
FooType[1] f
Is there any way to specify that a generic function is
conditionally nothrow (or other function decorators), based on
whether the template instantiation is nothrow? I'm looking for
something akin to C++'s noexcept(noexcept()), e.g.:
template void foo() noexcept(noexcept(T())) {}
I don't see
Okay so it turns out putting something in another thread is like
throwing it into an alternate universe where only my functions
exist, and instead of telling me my data doesn't exist, it just
silently behaves as if it's all empty
Man, threads are weird. I'll just pass the data in as an argumen
On Saturday, 30 January 2016 at 04:49:39 UTC, Taylor Hillegeist
wrote:
On Saturday, 30 January 2016 at 04:35:29 UTC, Taylor Hillegeist
wrote:
On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker
wrote:
[...]
Now I'm wishing that was the problem. Interestingly enough
when i link to a C s
Okay it somehow just got even stranger
that condition 'tokenIsAnOperator' in that code is a function to
test whether the token is contained within the array ["+", "-",
"*", "/"]
It seems that sometimes it returns true for "*", and sometimes
false, but only when I have "parallel" in that fore
Title says it; I get an access violation in code marked @safe.
Here's a minimal example:
[code]
@safe:
struct Foo(alias Callback)
{
~this() {Callback();}
}
unittest
{
uint stackVar;
alias FooType = Foo!((){++stackVar;});
FooType[1] foos;
foos[0] = FooType.init;
}
[/code]
On Saturday, 30 January 2016 at 04:35:29 UTC, Taylor Hillegeist
wrote:
On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker wrote:
[...]
Now I'm wishing that was the problem. Interestingly enough when
i link to a C shared library it works... but also it isn't show
in the needed shared l
On Saturday, 30 January 2016 at 04:13:09 UTC, Enjoys Math wrote:
I want to use std.algorithm.min/max,
how would I apply that to a slice of doubles and not a tuple of
args?
Thanks.
Oh I got it:
import std.algorithm;
reduce!(max)(slice);
I'ma D wizard!
On Saturday, 30 January 2016 at 04:11:07 UTC, Mike Parker wrote:
On Saturday, 30 January 2016 at 03:43:59 UTC, Taylor Hillegeist
wrote:
Working through a simple example. I tried the cdecl option but
for some reason i can compile but when i run my Gethello it
cant find the shared library in th
On Saturday, 30 January 2016 at 04:13:09 UTC, Enjoys Math wrote:
I want to use std.algorithm.min/max,
how would I apply that to a slice of doubles and not a tuple of
args?
Thanks.
Combine it with reduce:
import std.algorithm;
void main() {
double[] arr = [1.0, 2.1, 3.2, 4.
I'm writing a program to parse and evaluate mathematical
expressions
the parse tree is in the format:
struct node
{
string token;
node*[] children;
}
it is parsed such that for the input 1*(2+3)-4*(5+6), the tree
ends up looking like
-
* *
1 + 4 +
On Saturday, 30 January 2016 at 03:43:59 UTC, Taylor Hillegeist
wrote:
Working through a simple example. I tried the cdecl option but
for some reason i can compile but when i run my Gethello it
cant find the shared library in the same folder?
taylor@taylor-NE510:~/Projects/PASCAL$ nm libhell
I want to use std.algorithm.min/max,
how would I apply that to a slice of doubles and not a tuple of
args?
Thanks.
On Friday, 29 January 2016 at 01:47:11 UTC, Mike Parker wrote:
On Thursday, 28 January 2016 at 19:49:22 UTC, Taylor Hillegeist
wrote:
On Thursday, 28 January 2016 at 19:33:22 UTC, bearophile wrote:
FreeSlave:
On Thursday, 28 January 2016 at 08:15:38 UTC, FreeSlave wrote:
Not directly. You can
On 1/29/16 10:13 PM, Matt Elkins wrote:
On Saturday, 30 January 2016 at 03:00:11 UTC, Steven Schveighoffer wrote:
There are some really smart people who frequent these forums, if you
post your actual use case, you may get an answer that you hadn't
thought of.
Yeah, I tried that first (on the g
On Saturday, 30 January 2016 at 03:00:11 UTC, Steven
Schveighoffer wrote:
There are some really smart people who frequent these forums,
if you post your actual use case, you may get an answer that
you hadn't thought of.
Yeah, I tried that first (on the general forum, since at the time
I didn'
On 1/29/16 9:35 PM, Matt Elkins wrote:
On Saturday, 30 January 2016 at 02:09:55 UTC, Steven Schveighoffer wrote:
I figured out a way to have them. You just have to guarantee you don't
copy the actual "pointer" out of the struct:
https://forum.dlang.org/post/mk5k4l$s5r$1...@digitalmars.com
Unf
On Saturday, 30 January 2016 at 02:09:55 UTC, Steven
Schveighoffer wrote:
I figured out a way to have them. You just have to guarantee
you don't copy the actual "pointer" out of the struct:
https://forum.dlang.org/post/mk5k4l$s5r$1...@digitalmars.com
Unfortunately, that won't work for what I
On 1/29/16 8:07 PM, Matt Elkins wrote:
[snip]
on D and came across a section in TDPL which said internal pointers are
verboten because objects must be relocatable. Does this mean my example
is invalid (e.g., the invariant will not hold in all circumstances)? If
it is invalid, does that mean there
On Friday, 29 January 2016 at 12:00:25 UTC, Pavel wrote:
Hello!
Is there any debuging support for Intelij Idea's D plugin?
Thanks!
I can't say for certain, but the website
(https://github.com/kingsleyh/DLanguage) lists this as an
upcoming feature by the end of 2016, so I think there probabl
On Saturday, 30 January 2016 at 01:28:54 UTC, H. S. Teoh wrote:
On Sat, Jan 30, 2016 at 01:21:27AM +, Matt Elkins via
Digitalmars-d-learn wrote:
On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli
wrote:
>Definitely so. Rvalues are moved around all the time. The
>following program has
On Sat, Jan 30, 2016 at 01:21:27AM +, Matt Elkins via Digitalmars-d-learn
wrote:
> On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli wrote:
> >Definitely so. Rvalues are moved around all the time. The following
> >program has two rvalue moves without calling post-blits or
> >destructor
On Saturday, 30 January 2016 at 01:18:33 UTC, Ali Çehreli wrote:
Definitely so. Rvalues are moved around all the time. The
following program has two rvalue moves without calling
post-blits or destructors.
Oi, that makes life tough. Ok, I'll figure something else out,
then...
Thanks for the
On Saturday, 30 January 2016 at 01:17:13 UTC, Mike Parker wrote:
Hopefully one day dub will have the ability to pull down
library dependencies on demand, or based on the current
platform and architecture by default, then this problem goes
away.
I should say "precompiled library dependencies
On Friday, 29 January 2016 at 19:46:40 UTC, Johannes Pfau wrote:
Now on windows, things are more complicated. First of all, I
can't seem
to simply use "libs": ["foo"] as the linker won't find the C
import .lib file. Then apparently there's no way to add a
library search
path with the MSVC lin
On 01/29/2016 05:07 PM, Matt Elkins wrote:
> this(/* arguments to populate stuff */)
> {
> m_this = &this;
> /* ... populate stuff ... */
> }
> a section in TDPL which said internal pointers are
> verboten because objects must be relocatable. Does this mean my ex
On Saturday, 30 January 2016 at 01:17:13 UTC, Mike Parker wrote:
There's an issue for this at [1]. Until support for -m32mscoff
is baked in, distributing any libraries with a dub project will
be problematic.
[1] https://github.com/D-Programming-Language/dub/issues/628
Hi all, I'm a C++ programmer trying to decide whether to switch
my main focus to D, and so I'm working on a pet project using it.
So far I really like some of the practical aspects of the
language (built-in contracts are great, the metaprogramming is
very accessible, and I can't enough of these
On Fri, 29 Jan 2016 23:35:35 +, Basile B. wrote:
> You can implement an input range and annotate all the primitives as
> @safe.
I hadn't realized that if front() returns a tuple, it's automatically
expanded. Works for me.
On 01/29/2016 09:01 AM, Adrian Matoga wrote:
> Oh, there's more:
> // this should fail:
> static assert(is(CallsFoo!NoFoo));
> // this should fail too:
> static assert(is(typeof({ alias Baz = CallsFoo!NoFoo; return Baz.init;
> }(;
> // and this:
> static assert(__traits(compiles, { alias Baz
Am Fri, 29 Jan 2016 18:58:17 -0500
schrieb Steven Schveighoffer :
> On 1/29/16 6:03 PM, Marek Janukowicz wrote:
> > On Fri, 29 Jan 2016 17:43:26 -0500, Steven Schveighoffer wrote:
> >>> Is there anything I should know about UTF endianess?
> >>
> >> It's not any different from other endianness.
On 1/29/16 6:48 PM, Enjoys Math wrote:
I want to compute the points of a regular polygon in a loop:
float r = 1.0;
for (uint k=0; k < numVerts; k++) {
vertlist ~= Vec2D(r * cos(k/n * 2 * PI), ...)
}
How do I make sure k/n is a float or double?
uint is promoted to float/double with a bina
On 1/29/16 6:44 PM, Basile B. wrote:
Haven't you seen my answer about constraint ?
If you put a constraint on your function template then invalid
instantiations are rejected. I mean... this language feature is not just
ornamental...
What do you think constraints are used for otherwise ^^
A c
On 1/29/16 6:03 PM, Marek Janukowicz wrote:
On Fri, 29 Jan 2016 17:43:26 -0500, Steven Schveighoffer wrote:
Is there anything I should know about UTF endianess?
It's not any different from other endianness.
In other words, a UTF16 code unit is expected to be in the endianness of
the platform
I want to compute the points of a regular polygon in a loop:
float r = 1.0;
for (uint k=0; k < numVerts; k++) {
vertlist ~= Vec2D(r * cos(k/n * 2 * PI), ...)
}
How do I make sure k/n is a float or double?
On Friday, 29 January 2016 at 17:01:46 UTC, Adrian Matoga wrote:
On Friday, 29 January 2016 at 16:36:01 UTC, Steven
Schveighoffer wrote:
On 1/29/16 10:28 AM, Adrian Matoga wrote:
[...]
is(T) is supposed to be false if T is not a valid type.
I would agree with you that the static assert shoul
On Friday, 29 January 2016 at 17:44:34 UTC, Chris Wright wrote:
I want to create an opApply for a type.
I've marked my code @safe, because everything I wrote was
@safe. The body of opApply is @safe, but it calls a delegate
that may or may not be @safe.
How do I make it so I can iterate throu
On Fri, 29 Jan 2016 17:43:26 -0500, Steven Schveighoffer wrote:
>> Is there anything I should know about UTF endianess?
>
> It's not any different from other endianness.
>
> In other words, a UTF16 code unit is expected to be in the endianness of
> the platform you are running on.
>
> If you are o
On 1/29/16 5:36 PM, Marek Janukowicz wrote:
I have trouble understanding how endianess works for UTF-16.
For example UTF-16 code for 'ł' character is 0x0142. But this program shows
otherwise:
import std.stdio;
public void main () {
ubyte[] properOrder = [0x01, 0x42];
ubyte[] reverse
On Friday, 29 January 2016 at 22:36:37 UTC, Marek Janukowicz
wrote:
I have trouble understanding how endianess works for UTF-16.
UTF-16 (as well as UTF-32) comes in both little-endian and
big-endian variants. A byte-order marker in the file can help you
detect which one it is in.
See t his
I have trouble understanding how endianess works for UTF-16.
For example UTF-16 code for 'ł' character is 0x0142. But this program shows
otherwise:
import std.stdio;
public void main () {
ubyte[] properOrder = [0x01, 0x42];
ubyte[] reverseOrder = [0x42, 0x01];
writefln( "proper
On 1/29/16 3:08 PM, Chris Wright wrote:
On Fri, 29 Jan 2016 14:00:08 -0500, Steven Schveighoffer wrote:
On 1/29/16 12:44 PM, Chris Wright wrote:
I want to create an opApply for a type.
I've marked my code @safe, because everything I wrote was @safe. The
body of opApply is @safe, but it calls
On Friday, 29 January 2016 at 20:04:59 UTC, Igor wrote:
Suppose I create a model in D and would like it to support a
gui written in another language such as Qt C++ or WPF .NET.
Can anyone think of an efficient and very easy way to hook up
the "bindings"? The gui doesn't need to be updated more
On Fri, 29 Jan 2016 14:00:08 -0500, Steven Schveighoffer wrote:
> On 1/29/16 12:44 PM, Chris Wright wrote:
>> I want to create an opApply for a type.
>>
>> I've marked my code @safe, because everything I wrote was @safe. The
>> body of opApply is @safe, but it calls a delegate that may or may not
Suppose I create a model in D and would like it to support a gui
written in another language such as Qt C++ or WPF .NET.
Can anyone think of an efficient and very easy way to hook up the
"bindings"? The gui doesn't need to be updated more than about 30
times a second and it should run in it's
Am Fri, 29 Jan 2016 20:46:40 +0100
schrieb Johannes Pfau :
> DFLAGS="-m32mscoff" doesn't work with dub test as the dub test
> command ignores the DFLAGS variable. I'd have to check whether it
> works for applications, but then there's still no way to use the
> correct cairo import library
I want to add proper windows support to the cairoD dub package. cairoD
is a wrapper for the [cairo](http://cairographics.org/) C library. As
it can be difficult to obtain cairo DLLs on windows I want to ship
these DLLs with cairoD. It is also possible to enable or disable
additional cairo features.
On 1/29/16 12:44 PM, Chris Wright wrote:
I want to create an opApply for a type.
I've marked my code @safe, because everything I wrote was @safe. The body
of opApply is @safe, but it calls a delegate that may or may not be @safe.
How do I make it so I can iterate through this type safely and sy
On Friday, 29 January 2016 at 18:27:50 UTC, Tofu Ninja wrote:
where link.exe
C:\D\dmd2\windows\bin\link.exe
-m64 needs a different link.exe. It uses the Microsoft linker so
you've gotta be sure that one is installed and the path of the VS
bin is in there too.
The dmd install exe will do al
For some reason it complains that link.exe is missing. Anyone
know what's up?
dmd test.d
dmd test.d -m64
Can't run '\bin\link.exe', check PATH
On Friday, 29 January 2016 at 18:26:15 UTC, Tofu Ninja wrote:
For some reason it complains that link.exe is missing. Anyone
know what's up?
dmd test.d
dmd test.d -m64
Can't run '\bin\link.exe', check PATH
link.exe is definitely on PATH...
where link.exe
C:\D\dmd2\windows\bin\link.exe
I want to create an opApply for a type.
I've marked my code @safe, because everything I wrote was @safe. The body
of opApply is @safe, but it calls a delegate that may or may not be @safe.
How do I make it so I can iterate through this type safely and systemly?
I want to support iteration like:
On Friday, 29 January 2016 at 16:36:01 UTC, Steven Schveighoffer
wrote:
On 1/29/16 10:28 AM, Adrian Matoga wrote:
Code:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T) {
T t;
void bar() { t.foo(); }
}
static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo!
On Thursday, 28 January 2016 at 18:33:19 UTC, Nordlöw wrote:
Thanks, I'm aware of these tools.
But it's easier to use the stacktrace...if I only get one. The
function where the assert() is called is, in turn, called in
hundreds of places.
Which platform are you on? Are all your binaries com
On 1/29/16 10:28 AM, Adrian Matoga wrote:
Code:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T) {
T t;
void bar() { t.foo(); }
}
static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo!HasFoo;
static assert(is(CallsFoo!NoFoo)); // (1)
//alias Baz = CallsFoo
On Friday, 29 January 2016 at 15:28:29 UTC, Adrian Matoga wrote:
How can I reliably test if CallsFoo can be instantiated?
You can use a constraint to prevent invalid instantiation:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T)
if (__traits(hasMember, T, "foo"))
{
On Friday, 29 January 2016 at 15:13:45 UTC, Mike Parker wrote:
The first implementation is fine because you're overriding the
implementation in the base class (Object). However, the second
one fails because it's a template. Templates are non-virtual
and cannot override anything. Even if you cou
On Friday, 29 January 2016 at 08:06:14 UTC, glathoud wrote:
Thanks. I am glad be wrong on that one.
I had a look at map & filter in the source code ; pleased to
see they're lazily implemented!
map
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm/iteration.d#L425
fil
Code:
struct HasFoo { void foo() {} }
struct NoFoo {}
struct CallsFoo(T) {
T t;
void bar() { t.foo(); }
}
static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo!HasFoo;
static assert(is(CallsFoo!NoFoo)); // (1)
//alias Baz = CallsFoo!NoFoo; // (2)
This compil
Getting this error, could someone explain why?
void main(string[] args) {
InSituRegion!(1024) stackAlloc;
IAllocator alloc = allocatorObject(stackAlloc);
}
..\src\phobos\std\conv.d(5055):
Error: static assert "Don't know how to initialize an object of
type CAllocatorImpl!(InSit
On Friday, 29 January 2016 at 15:00:59 UTC, pineapple wrote:
With this bit of code, the first method seems to work fine -
things go as expected. But I get a compile error with the
second method, and I'm not sure how else to write this.
override bool opEquals(Object value) const{
re
It also occurred to me to do something like this, but it isn't
accepted either.
override bool opEquals(T)(T value){
return this.equals(value);
}
With this bit of code, the first method seems to work fine -
things go as expected. But I get a compile error with the second
method, and I'm not sure how else to write this.
override bool opEquals(Object value) const{
return this.equals(cast(typeof(this)) value);
}
override
On Friday, 29 January 2016 at 13:22:07 UTC, Mike Parker wrote:
Your problem is probably that you are calling GC.free in the
destructor. Don't do this. You don't need to call GC.free at
all. The GC will collect both your object instance and the
memory you allocated with new. Never, ever, manipu
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote:
the Code:
~this(){
GC.free(by.ptr);
by = null;
writeln("free");
}
Your problem is probably that you are calling GC.free in the
destructor. Don't do this. You don't need to
On Friday, 29 January 2016 at 12:43:53 UTC, Dsby wrote:
the Code:
class MyClass
{
this(){
by = new ubyte[1];
++i;
}
~this(){
GC.free(by.ptr);
by = null;
writeln("free");
}
v
the Code:
class MyClass
{
this(){
by = new ubyte[1];
++i;
}
~this(){
GC.free(by.ptr);
by = null;
writeln("free");
}
void show(){
writeln(i);
};
privat
Hello!
Is there any debuging support for Intelij Idea's D plugin?
Thanks!
Thanks. I am glad be wrong on that one.
I had a look at map & filter in the source code ; pleased to see
they're lazily implemented!
map
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm/iteration.d#L425
filter
https://github.com/D-Programming-Language/phobos/blob/mas
81 matches
Mail list logo