Re: Linking with .dylibs on OSX?

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 22:30:42 UTC, Jeremy DeHaan wrote: On Friday, 19 July 2013 at 19:52:49 UTC, Jeremy DeHaan wrote: On Friday, 19 July 2013 at 18:29:12 UTC, evilrat wrote: On Friday, 19 July 2013 at 18:19:20 UTC, Jeremy DeHaan wrote: I was just curious if DMD supported linking with .dyl

Re: How to require operator overloading in interface

2013-07-19 Thread Jesse Phillips
The relevant blog post: http://3d.benjamin-thaut.de/?p=94 What you should understand is template functions are not/can not be virtual. They do not exist until they are instantiated. Thus you can not require that they be overloaded.

Re: Linking with .dylibs on OSX?

2013-07-19 Thread Jeremy DeHaan
On Friday, 19 July 2013 at 19:52:49 UTC, Jeremy DeHaan wrote: On Friday, 19 July 2013 at 18:29:12 UTC, evilrat wrote: On Friday, 19 July 2013 at 18:19:20 UTC, Jeremy DeHaan wrote: I was just curious if DMD supported linking with .dylib files on OSX. Would one simply do something like this? "

Re: Why does this template not have the desired result?

2013-07-19 Thread JS
On Friday, 19 July 2013 at 20:26:36 UTC, Gary Willoughby wrote: Why does this template not have the desired result? I honestly though it would return true. import std.stdio; template inBounds(size_t size, T) { enum result = (size >= T.min && size <= T.max); } void main(string[] args)

Re: Why does this template not have the desired result?

2013-07-19 Thread H. S. Teoh
On Fri, Jul 19, 2013 at 10:42:54PM +0200, Adam D. Ruppe wrote: > On Friday, 19 July 2013 at 20:26:36 UTC, Gary Willoughby wrote: > >Why does this template not have the desired result? I honestly > >though it would return true. > > It is because size_t is an unsigned type. Comparisons between signe

Re: Why does this template not have the desired result?

2013-07-19 Thread Adam D. Ruppe
On Friday, 19 July 2013 at 20:26:36 UTC, Gary Willoughby wrote: Why does this template not have the desired result? I honestly though it would return true. It is because size_t is an unsigned type. Comparisons between signed and unsigned numbers can be surprising because if either of the item

Re: Why does this template not have the desired result?

2013-07-19 Thread Gary Willoughby
The way I'd do the inBounds is to just use T size instead of size_t size. template inBounds(T, T size) { snip same stuff } then writefln("%s", inBounds!(int, 10).result); // true as expected The problem with that though is that with size arguments > int.max will wrap when being cast

Re: GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Johannes Pfau
Am Fri, 19 Jul 2013 12:38:45 +0200 schrieb Marco Leise : > It turns out that what Walter explained is the > key here, too. All my libraries are compiled without frame > pointers, so the simple stack unwinding that D uses fails > there. I recompiled glib and gtk+ with -fno-omit-frame-pointer > spec

Why does this template not have the desired result?

2013-07-19 Thread Gary Willoughby
Why does this template not have the desired result? I honestly though it would return true. import std.stdio; template inBounds(size_t size, T) { enum result = (size >= T.min && size <= T.max); } void main(string[] args) { writefln("%s", inBounds!(10, int).result); // false! eh

Re: Linking with .dylibs on OSX?

2013-07-19 Thread Jeremy DeHaan
On Friday, 19 July 2013 at 18:29:12 UTC, evilrat wrote: On Friday, 19 July 2013 at 18:19:20 UTC, Jeremy DeHaan wrote: I was just curious if DMD supported linking with .dylib files on OSX. Would one simply do something like this? "dmd main.d somelib.dylib" Thanks! i don't remember exactly,

Re: concurrency problem with pointers

2013-07-19 Thread Ali Çehreli
On 07/19/2013 11:39 AM, evilrat wrote: > i think problem is that with a struct we can't just generate code for > this methods(toHash,opCmp,etc) by comparing its address That would be wrong. Yes the compiler needs the definition of the struct to generate toHash, opCmp, and toString but note that

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 18:25:26 UTC, Ali Çehreli wrote: On 07/19/2013 11:07 AM, evilrat wrote: > i don't think this is compiler bug, it's just how it works. But what code needs toHash and others for the struct type even though we are just passing a pointer around? > yet this is > another

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 17:14:10 UTC, Ali Çehreli wrote: On 07/19/2013 09:00 AM, evilrat wrote: > i think this is because GLFWwindow is (pre)defined as struct instead alias > void :( Further reduced: import std.concurrency; struct S; void main() { receive((S * p){}); } Error Ali

Re: Issue with char and string overlap

2013-07-19 Thread anonymous
On Friday, 19 July 2013 at 17:18:00 UTC, JS wrote: both functions work separately but when i uncomment the string version I get an error about the string version shadowing. import std.stdio, std.cstream; string[] split(T)(string s, T d) if (is(T == char) || is(T == string)) { int i =

Re: concurrency problem with pointers

2013-07-19 Thread Ali Çehreli
On 07/19/2013 11:07 AM, evilrat wrote: > i don't think this is compiler bug, it's just how it works. But what code needs toHash and others for the struct type even though we are just passing a pointer around? > yet this is > another thing one must remember when writing library - never use str

Re: Linking with .dylibs on OSX?

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 18:19:20 UTC, Jeremy DeHaan wrote: I was just curious if DMD supported linking with .dylib files on OSX. Would one simply do something like this? "dmd main.d somelib.dylib" Thanks! i don't remember exactly, but if this not work for you try something like this dm

Re: Issue with char and string overlap

2013-07-19 Thread monarch_dodra
On Friday, 19 July 2013 at 17:25:34 UTC, JS wrote: BTW, I'd like to have a default value for d. That or efficiently allow for variadic d, which then the default delim could easily be tested for. To answer your previous question about shadowing, you are probably experiencing an old bug where you

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread Jonathan M Davis
On Friday, July 19, 2013 19:23:50 JS wrote: > On Friday, 19 July 2013 at 15:32:25 UTC, Jonathan M Davis wrote: > > On Friday, July 19, 2013 11:06:26 JS wrote: > >> I would like to pass to all my templates the file and module > >> locations where they are used(this goes into a debugging > >> system

Re: Issue with char and string overlap

2013-07-19 Thread H. S. Teoh
On Fri, Jul 19, 2013 at 07:17:57PM +0200, JS wrote: [...] > string[] split(T)(string s, T d) if (is(T == char) || is(T == > string)) > { > int i = 0, oldj = 0; bool ok = true; > string[] r; > foreach(j, c; s) > { > static if (is(T == char)) > { >

Linking with .dylibs on OSX?

2013-07-19 Thread Jeremy DeHaan
I was just curious if DMD supported linking with .dylib files on OSX. Would one simply do something like this? "dmd main.d somelib.dylib" Thanks!

Re: Issue with char and string overlap

2013-07-19 Thread Ali Çehreli
On 07/19/2013 10:40 AM, anonymous wrote: > On Friday, 19 July 2013 at 17:18:00 UTC, JS wrote: >> for(int j = 0; j < s.length - d.length; j++) > > This j would shadow the one above. Just choose another name. Even better: foreach (k; 0 .. s.length - d.length) or: foreach (k

Re: Issue with char and string overlap

2013-07-19 Thread monarch_dodra
On Friday, 19 July 2013 at 17:18:00 UTC, JS wrote: I'm trying to create a split function that can handle both char and string delims. I initially created two separate functions but this doesn't work for default parameters since the compiler doesn't know which one to choose(but in this case both

Re: Issue with char and string overlap

2013-07-19 Thread JS
On Friday, 19 July 2013 at 17:18:00 UTC, JS wrote: I'm trying to create a split function that can handle both char and string delims. I initially created two separate functions but this doesn't work for default parameters since the compiler doesn't know which one to choose(but in this case both

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread JS
On Friday, 19 July 2013 at 15:32:25 UTC, Jonathan M Davis wrote: On Friday, July 19, 2013 11:06:26 JS wrote: I would like to pass to all my templates the file and module locations where they are used(this goes into a debugging system I have come up with). The problem is, with varadic types be

Re: concurrency problem with pointers

2013-07-19 Thread Ali Çehreli
On 07/19/2013 09:00 AM, evilrat wrote: > i think this is because GLFWwindow is (pre)defined as struct instead alias > void :( Further reduced: import std.concurrency; struct S; void main() { receive((S * p){}); } Error: struct deneme.S is forward referenced when looking for 'toHash' Er

Issue with char and string overlap

2013-07-19 Thread JS
I'm trying to create a split function that can handle both char and string delims. I initially created two separate functions but this doesn't work for default parameters since the compiler doesn't know which one to choose(but in this case both would work fine and it would be nice to inform the

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 15:35:27 UTC, John Colvin wrote: On Friday, 19 July 2013 at 15:16:23 UTC, evilrat wrote: here is reduced example without platform-specific stuff, requires derelict3 and glfw. http://pastebin.com/rhB14YNs I can't get that to compile, I keep getting Derelict3/import

Re: concurrency problem with pointers

2013-07-19 Thread Ali Çehreli
On 07/19/2013 08:16 AM, evilrat wrote: > here is reduced example without platform-specific stuff, requires > derelict3 and glfw. > http://pastebin.com/rhB14YNs Further reduced by removing the need for derelict3 and glfw: import std.stdio; import std.concurrency; import core.thread; alias GLFWw

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Friday, 19 July 2013 at 15:36:33 UTC, Ali Çehreli wrote: Error: static assert "Aliases to mutable thread-local data not allowed." instantiated from here: send!(void*) Is that the problem? (If so, why don't you say so? ;)) Then there are two solutions: a) Make _wnd a shared(GLFWwi

Re: concurrency problem with pointers

2013-07-19 Thread John Colvin
On Friday, 19 July 2013 at 15:16:23 UTC, evilrat wrote: On Thursday, 18 July 2013 at 17:23:20 UTC, Ali Çehreli wrote: On 07/18/2013 08:29 AM, evilrat wrote: > i hate asking for help Please do so. Otherwise we can't learn from others' issues. :) that's who i am. long story, but in short, peopl

Re: Passing a class instance to a thread via spawn()

2013-07-19 Thread Joseph Rushton Wakeling
On Thursday, 18 July 2013 at 23:54:22 UTC, Ali Çehreli wrote: On 07/18/2013 04:23 PM, Joseph Rushton Wakeling wrote: > Hello all, > > I have a data structure which is a final class. Once created, the contents of > the class will not be mutated (only its const methods will be called). > > Is the

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Thursday, 18 July 2013 at 23:36:34 UTC, Sean Kelly wrote: In short, you're trying to send a pointer via std.concurrency. The easiest way is to cast it to/from shared. Otherwise, you'd need to make it an opaque type like a size_t rather than a type D can tell is a reference. sure cast to

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread Jonathan M Davis
On Friday, July 19, 2013 11:06:26 JS wrote: > I would like to pass to all my templates the file and module > locations where they are used(this goes into a debugging system I > have come up with). > > The problem is, with varadic types being passed I can't do this: > > template T!(T..., string fi

Re: Passing a class instance to a thread via spawn()

2013-07-19 Thread Joseph Rushton Wakeling
On Thursday, 18 July 2013 at 23:39:19 UTC, Sean Kelly wrote: I'd like to add move semantics of a sort which would work via something very like assumeUnique. That would be great. For now, cast the class to shared before sending, and cast away shared on receipt. The only other option would be

Re: How to require operator overloading in interface

2013-07-19 Thread H. S. Teoh
On Fri, Jul 19, 2013 at 04:28:42PM +0200, Adam D. Ruppe wrote: > You can't have templates in interfaces unless they are final, > otherwise it won't work right. > > The way I'd do it is is make the op template final, and have it > forward to another normal virtual function: > > interface Addable {

Re: stringof alias

2013-07-19 Thread Ali Çehreli
On 07/19/2013 02:02 AM, JS wrote: > On Friday, 19 July 2013 at 08:08:27 UTC, John Colvin wrote: >> On Friday, 19 July 2013 at 08:02:45 UTC, JS wrote: >>> I have a template >>> >>> template T(alias t) >>> { >>> pragma(msg, t.stringof); >>> other stuff ... >>> } >>> >>> which I use in a clas

Re: concurrency problem with pointers

2013-07-19 Thread evilrat
On Thursday, 18 July 2013 at 17:23:20 UTC, Ali Çehreli wrote: On 07/18/2013 08:29 AM, evilrat wrote: > i hate asking for help Please do so. Otherwise we can't learn from others' issues. :) that's who i am. long story, but in short, people hated when i ask something and after few minutes i fin

Re: How to require operator overloading in interface

2013-07-19 Thread Adam D. Ruppe
You can't have templates in interfaces unless they are final, otherwise it won't work right. The way I'd do it is is make the op template final, and have it forward to another normal virtual function: interface Addable { final Addable opBinary(string op : "+")(Addable rhs) { return

How to require operator overloading in interface

2013-07-19 Thread JS
I would like to require any implementation of an interface to override import std.stdio, std.cstream; interface A { void opOpAssign(string op : "^")(int c); } class B : A { int x; void opOpAssign(string op : "+")(int c) { x = c; } // Note it uses + } void main(

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread JS
On Friday, 19 July 2013 at 11:12:31 UTC, Andrej Mitrovic wrote: On 7/19/13, JS wrote: The problem is, with varadic types being passed I can't do this: template T!(T..., string file = __FILE__) Yeah it's a known (and common) issue. http://d.puremagic.com/issues/show_bug.cgi?id=8687 It woul

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread Andrej Mitrovic
On 7/19/13, JS wrote: > The problem is, with varadic types being passed I can't do this: > > template T!(T..., string file = __FILE__) Yeah it's a known (and common) issue. http://d.puremagic.com/issues/show_bug.cgi?id=8687

Re: passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread JS
On Friday, 19 July 2013 at 09:06:27 UTC, JS wrote: I would like to pass to all my templates the file and module locations where they are used(this goes into a debugging system I have come up with). The problem is, with varadic types being passed I can't do this: template T(T..., string file =

Re: GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
Am Fri, 19 Jul 2013 11:47:41 +0200 schrieb Marco Leise : > Am Fri, 19 Jul 2013 11:10:04 +0200 > schrieb Marco Leise : > > dav1d gave me advice on rebuilding druntime with debug symbols. > That lead me to this "GitHub" stack trace: > > https://github.com/D-Programming-Language/druntime/blob/v2.06

Re: GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
Am Fri, 19 Jul 2013 11:10:04 +0200 schrieb Marco Leise : dav1d gave me advice on rebuilding druntime with debug symbols. That lead me to this "GitHub" stack trace: https://github.com/D-Programming-Language/druntime/blob/v2.063.2/src/rt/deh2.d#L104 https://github.com/D-Programming-Language/druntim

passing __FILE__, __MODULE__, etc... with varadic types

2013-07-19 Thread JS
I would like to pass to all my templates the file and module locations where they are used(this goes into a debugging system I have come up with). The problem is, with varadic types being passed I can't do this: template T!(T..., string file = __FILE__) doesn't work. I think there is no way

GktD: exceptions in handlers cause segfaults.

2013-07-19 Thread Marco Leise
I am trying to throw exceptions in gtk signal handlers, but I am greeted with segfaults. What's the cause and are there solutions? (DMD 2.063.2 on Linux x86-64) Here is some reduced code: import gtk.Main; import gtk.MainWindow; import gdk.Event; import gtk.Widget; class TestWindow : MainWindow {

Re: Pass symbol to template?

2013-07-19 Thread JS
On Friday, 19 July 2013 at 08:40:09 UTC, John Colvin wrote: On Friday, 19 July 2013 at 08:08:25 UTC, JS wrote: I have some templates to help initialize things, like a property getter and setter. mixin(Property!("Name", int)); creates a property named Name with type int. I'd like to be able t

Re: stringof alias

2013-07-19 Thread JS
On Friday, 19 July 2013 at 08:08:27 UTC, John Colvin wrote: On Friday, 19 July 2013 at 08:02:45 UTC, JS wrote: I have a template template T(alias t) { pragma(msg, t.stringof); other stuff ... } which I use in a class and pass fields/members to. D complains that t does not have a this.

Re: Pass symbol to template?

2013-07-19 Thread John Colvin
On Friday, 19 July 2013 at 08:08:25 UTC, JS wrote: I have some templates to help initialize things, like a property getter and setter. mixin(Property!("Name", int)); creates a property named Name with type int. I'd like to be able to call it like mixin(Property!(Name, int)); (Name is a symb

Re: stringof alias

2013-07-19 Thread John Colvin
On Friday, 19 July 2013 at 08:02:45 UTC, JS wrote: I have a template template T(alias t) { pragma(msg, t.stringof); other stuff ... } which I use in a class and pass fields/members to. D complains that t does not have a this. I'd just like to print the literal text that was passed to

Pass symbol to template?

2013-07-19 Thread JS
I have some templates to help initialize things, like a property getter and setter. mixin(Property!("Name", int)); creates a property named Name with type int. I'd like to be able to call it like mixin(Property!(Name, int)); (Name is a symbol but undefined at the mixin site(since it will be

stringof alias

2013-07-19 Thread JS
I have a template template T(alias t) { pragma(msg, t.stringof); other stuff ... } which I use in a class and pass fields/members to. D complains that t does not have a this. I'd just like to print the literal text that was passed to T. (which I actually do in ctfe) This is so I can

Re: Import all?

2013-07-19 Thread JS
On Friday, 19 July 2013 at 00:39:03 UTC, Jonathan M Davis wrote: On Friday, July 19, 2013 01:25:54 JS wrote: Note I reverted to 2.062 because 2.063.2 was causing weird errors in Visual D... so this might be the problem but I remember getting the same errors when I was trying 2.063.2(but possibl

Re: GetOverloadedMethods

2013-07-19 Thread JS
On Friday, 19 July 2013 at 06:27:36 UTC, Jacob Carlborg wrote: On 2013-07-19 00:47, JS wrote: module main; import std.stdio; interface A { final void Afoo() { } void bar(); } class B : A { final void Bfoo() { } void bar() { } void doo() { } } class C : B { //override