Re: What is shared functions?

2011-10-24 Thread Jacob Carlborg
On 2011-10-23 20:14, Jonathan M Davis wrote: On Sunday, October 23, 2011 14:32:34 simendsjo wrote: What does shared for functions mean? I thought it was supposed to automatically synchronize access, but this doesn't seem to be the case. void f() shared { // no synchronization } void f() {

Re: Looking for documentation of D's lower-level aspects.

2011-10-24 Thread Dmitry Olshansky
On 24.10.2011 5:57, Sean Silva wrote: == Quote from Dmitry Olshansky (dmitry.o...@gmail.com)'s article Less efficient is a moot point. When you do iteration and other stuff you'd use range, like you'd use iterators in c++. Range gets stack/register allocated pointers directly to data (or

Re: gtkD problems and general gui question.

2011-10-24 Thread Nick Sabalausky
%u f...@bar.com wrote in message news:j7k3c7$25jg$1...@digitalmars.com... Finally, is gtkD the way to go when it comes to learning gui with D? Which gui is the most popular with D? Which one has a future? And which is the easiest to learn? IMO, GTK itself (ie, not just gtkD) is terrbile

Re: Looking for documentation of D's lower-level aspects.

2011-10-24 Thread bearophile
Sean Silva: in some cases, std::vector causes too much heap traffic so they have SmallVector which preallocates a certain amount of storage *inside* of the object itself in order to avoid heap traffic if the number of elements doesn't exceed some predetermined amount. I expect Phobos to

Re: gtkD problems and general gui question.

2011-10-24 Thread Andrej Mitrovic
On 10/24/11, Nick Sabalausky a@a.a wrote: (ie, garbage non-native controls) In reality you don't even need to use native controls to create a true native look. In fact using true native controls is expensive, and even IE/Office use custom-drawn widgets that only appear native. There are theming

Re: Random, not so random?

2011-10-24 Thread Kagamin
Jesse Phillips Wrote: void main() { auto arr = [1,2,3,4]; auto gen = Random(unpredictableSeed); assert(randomCover(arr,gen) != randomCover(arr,gen)); auto result1 = randomCover(arr,gen); auto result2 = randomCover(arr,gen); assert(result1 != result2); these

Re: Bug? aliasing member of instance

2011-10-24 Thread Steven Schveighoffer
On Sat, 22 Oct 2011 03:28:53 -0400, Nick Sabalausky a@a.a wrote: Is this a compiler bug? struct Foo { int a; } Foo foo; alias foo.a b; void main() { b = 5; // -- Error } dmd test.d test.d(11): Error: need 'this' to

Re: What is shared functions?

2011-10-24 Thread Steven Schveighoffer
On Sun, 23 Oct 2011 08:32:34 -0400, simendsjo simend...@gmail.com wrote: What does shared for functions mean? I thought it was supposed to automatically synchronize access, but this doesn't seem to be the case. void f() shared { // no synchronization } void f() { synchronized { //

Re: linker errors after upgrade to Ubuntu 11.10

2011-10-24 Thread Steven Schveighoffer
On Sun, 23 Oct 2011 21:36:10 -0400, Sean Silva chisophu...@gmail.com wrote: I just upgraded to Ubuntu 11.10 (from 11.04). I have attached the error message. It looks like it is a problem with a reference to `clock_gettime`. Any suggestions? It's a bug fixed in the upcoming compiler

Re: Get current date and time with std.datetime

2011-10-24 Thread Jonathan M Davis
On Friday, October 07, 2011 19:58:12 Joel Christensen wrote: http://d-programming-language.org/intro-to-datetime.html Thanks Jonathan, that helped I think, (haven't read it all, though). But I've got errors with some of the date times not being able to change them with int's values.

Re: Implicit cast to immutable

2011-10-24 Thread Steven Schveighoffer
On Fri, 21 Oct 2011 11:20:01 -0400, Christophe trav...@phare.normalesup.org wrote: Daniel Murphy , dans le message (digitalmars.D.learn:30139), a écrit : bearophile bearophileh...@lycos.com wrote in message news:j7jepi$prp$1...@digitalmars.com... Daniel Murphy: 2) immutable(int[]) fun() {

Re: Chars sorting and copies

2011-10-24 Thread Steven Schveighoffer
On Sat, 22 Oct 2011 23:01:17 -0400, bearophile bearophileh...@lycos.com wrote: Thanks for all the answers. Steven Schveighoffer: a ~ b should technically be assignable to char[], since it's alread new memory. We may yet get there with pure functions being able to implicit cast to

Re: What is shared functions?

2011-10-24 Thread simendsjo
On 24.10.2011 17:23, Steven Schveighoffer wrote: On Sun, 23 Oct 2011 08:32:34 -0400, simendsjo simend...@gmail.com wrote: What does shared for functions mean? I thought it was supposed to automatically synchronize access, but this doesn't seem to be the case. void f() shared { // no

Re: What is shared functions?

2011-10-24 Thread Steven Schveighoffer
On Mon, 24 Oct 2011 12:01:07 -0400, simendsjo simend...@gmail.com wrote: On 24.10.2011 17:23, Steven Schveighoffer wrote: On Sun, 23 Oct 2011 08:32:34 -0400, simendsjo simend...@gmail.com wrote: What does shared for functions mean? I thought it was supposed to automatically synchronize

Re: Random, not so random?

2011-10-24 Thread Jesse Phillips
Kagamin Wrote: these fail because Random is a struct an its state is precisely replicated on copy, so two calls to randomCover accept gen in the same state, so their outputs are identical. All arr1, arr2, str1 and str2 are equivalent. Yes, I found that. But the question remains, is it a

Re: Random, not so random?

2011-10-24 Thread bearophile
Jesse Phillips: Kagamin Wrote: these fail because Random is a struct an its state is precisely replicated on copy, so two calls to randomCover accept gen in the same state, so their outputs are identical. All arr1, arr2, str1 and str2 are equivalent. Yes, I found that. But the

removing an item from a dynamic array

2011-10-24 Thread maarten van damme
I've stumbled in an annoying error while trying to remove an item from a dynamic array. It's an array of Loc and a Loc is a simple struct of two integers. when I used remove from std.algorithm I get C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(5948): Error: incompatible types for ((pos)

Re: gtkD problems and general gui question.

2011-10-24 Thread Nick Sabalausky
Andrej Mitrovic andrej.mitrov...@gmail.com wrote in message news:mailman.367.1319465270.24802.digitalmars-d-le...@puremagic.com... On 10/24/11, Nick Sabalausky a@a.a wrote: (ie, garbage non-native controls) In reality you don't even need to use native controls to create a true native look.

Re: removing an item from a dynamic array

2011-10-24 Thread simendsjo
On 24.10.2011 23:55, maarten van damme wrote: I've stumbled in an annoying error while trying to remove an item from a dynamic array. It's an array of Loc and a Loc is a simple struct of two integers. when I used remove from std.algorithm I get

Re: What is shared functions?

2011-10-24 Thread simendsjo
On 24.10.2011 21:41, Steven Schveighoffer wrote: So you cannot create a function to be called on both shared and unshared instances? For mutable/immutable there's const, but there is no maybeShared. No. There isn't a hybrid that works as well as const does. I suspect one could be created,

Re: Only one signal per object?

2011-10-24 Thread Andrej Mitrovic
It seems neither std.signal nor the new signals module support ref parameters, which is a shame because I've found a very good use for them. The std.signal won't compile for handlers with ref parameters, the new one compiles but throws an access violation at runtime. Example usage: If you have a

Re: Only one signal per object?

2011-10-24 Thread Andrej Mitrovic
I think I know what's going on, getCallable() doesn't check for the storage class of a function, and does a cast based on the parameters and the return type when it's adding a new handler. The handler is later casted to a function type with no ref parameters, and this is where things probably

Re: Only one signal per object?

2011-10-24 Thread Andrej Mitrovic
Yeah, if I change the two function types in Signal to this: alias bool delegate(ref Types) slot_t; alias void delegate(ref Types) void_slot_t; then I can connect functions with ref arguments. But then I'll get exceptions thrown if the functions have non-ref arguments. This seems

Re: removing an item from a dynamic array

2011-10-24 Thread maarten van damme
import std.algorithm; struct Loc { uint row; uint col; } void main(){ Loc[] testArray; Loc a={3,2}; Loc b={5,3}; testArray~=a; testArray~=b; remove(testArray,a); } gives the same error