Re: Get class type parameters at compile time

2012-12-14 Thread js.mdnq
On Friday, 14 December 2012 at 20:14:29 UTC, Philippe Sigaud wrote: On Fri, Dec 14, 2012 at 1:18 AM, bearophile wrote: Fit to be added to Phobos? Maybe, I don't know. People seem to ask for this quite regularly. Here is a slightly improved version, what do you think? template isTemplat

Re: alias type reduction

2012-12-14 Thread js.mdnq
On Friday, 14 December 2012 at 05:54:33 UTC, Philippe Sigaud wrote: Ok, I'll try again. when I was doing it I would get circular referencing but maybe I did something wrong... Another possibility is to use `.A`: the (.) prefix means the symbol is looked in the external scope, not inside t

Re: Extensions to types loaded from a C library

2012-12-14 Thread Jeremy DeHaan
Just thought I should give an update. After testing a little bit, I found out that it is not safe in some situations. With the code looking like this: struct sfVector2f { float x; float y; this(float X, float Y) { x = X; y = Y;

Re: Marking bug entires as fixed/closed on bugzilla

2012-12-14 Thread monarch_dodra
On Friday, 14 December 2012 at 18:42:24 UTC, Brad Roberts wrote: On 12/14/2012 3:47 AM, monarch_dodra wrote: I have a whole list of bugs/issues that have since been corrected in 2.060alpha. I was wondering when and how these were to be closed? Am I supposed to wait for an official 2.061 first

Re: Parallelizing code -- design problem in networkish code

2012-12-14 Thread Sean Kelly
Do updates have to happen concurrently with read operations? Could you maybe queue updates and batch them at specific times instead? That would save you from having to protect every access. Or maybe different portions of the network could be owned by different threads? That makes it essentia

Re: Parallelizing code -- design problem in networkish code

2012-12-14 Thread Ali Çehreli
On 12/13/2012 08:38 PM, Charles Hixson wrote: > Now what I was thinking of involved an array in another class (i.e., not > the Cell class) defined: > Cell[] cells; > and the Cell class, which includes: > public class Cell > { ... > Idno[] ups; > ... > } > where ups is an array of Id#s which are i

Re: VIM: What wizardry is this?

2012-12-14 Thread Jace Bennett
On Friday, 14 December 2012 at 20:54:32 UTC, Jesse Phillips wrote: On Friday, 14 December 2012 at 20:37:12 UTC, Jace Bennett wrote: Am I getting coolness from janus or from the dmd installer? In short, it's awesome, but wtf? That is the compiler, been there for about 10 releases. Don't know

Re: VIM: What wizardry is this?

2012-12-14 Thread Jesse Phillips
On Friday, 14 December 2012 at 20:37:12 UTC, Jace Bennett wrote: Am I getting coolness from janus or from the dmd installer? In short, it's awesome, but wtf? That is the compiler, been there for about 10 releases. Don't know who Janus is.

VIM: What wizardry is this?

2012-12-14 Thread Jace Bennett
I'm new and trying to feel my way around here. I have MacVim + Janus on OSX 10.8. I pulled d.vim into the janus folder, and started messing around. On write, I get really cool and helpful errors along the lines of "writeln is not defined, did you mean to import std.stdio?" Why, yes, Vim, I di

Re: Get class type parameters at compile time

2012-12-14 Thread Philippe Sigaud
On Fri, Dec 14, 2012 at 1:18 AM, bearophile wrote: > > Fit to be added to Phobos? > Maybe, I don't know. People seem to ask for this quite regularly. Here is a slightly improved version, what do you think? template isTemplatedType(Type...) if (Type.length == 1) { mixin("alias " ~ Type[0].st

Re: Extensions to types loaded from a C library

2012-12-14 Thread Jeremy DeHaan
With D's UFCS syntax, there's really no need to modify Derelict directly to extend a C struct. http://www.gamedev.net/blog/1140/entry-2254754-uniform-function-call-syntax-in-d/ Obviously, this technique won't work for constructors, but it should work for most any other method you'd like to

Re: Marking bug entires as fixed/closed on bugzilla

2012-12-14 Thread Brad Roberts
On 12/14/2012 3:47 AM, monarch_dodra wrote: > I have a whole list of bugs/issues that have since been corrected in > 2.060alpha. > > I was wondering when and how these were to be closed? > > Am I supposed to wait for an official 2.061 first? > > Do I have to prove it was fixed, or just a simple

Re: contracts in interfaces

2012-12-14 Thread Ali Çehreli
On 12/14/2012 12:11 AM, Yann wrote: >>> why does this produce a segmentation fault when executed: There are quite a few bugs about interface contracts and inherited contracts: http://d.puremagic.com/issues/buglist.cgi?quicksearch=interface+contract Although, I haven't seen one about segmen

Re: Using arrays with functions taking ranges

2012-12-14 Thread monarch_dodra
On Friday, 14 December 2012 at 15:59:48 UTC, Mu wrote: It works because "put" is defined for all input ranges as "write to first element and popFront". That makes more sense, thanks. So what happens is that for "regular" ranges std.range.put() gets used, while for arrays in RefAppender std.arr

Re: Using arrays with functions taking ranges

2012-12-14 Thread Mu
It works because "put" is defined for all input ranges as "write to first element and popFront". That makes more sense, thanks. So what happens is that for "regular" ranges std.range.put() gets used, while for arrays in RefAppender std.array.put() gets used, right? (I noticed that the unitte

Re: Using arrays with functions taking ranges

2012-12-14 Thread monarch_dodra
On Friday, 14 December 2012 at 14:56:45 UTC, Mu wrote: It "works" because in theory, all mutable ranges verify the "is output range" trait. However, they are not "sinks", so if you write too much into them, you'll get an out of index exception. Does it work at runtime, and do you get the correc

Re: Using arrays with functions taking ranges

2012-12-14 Thread Mu
It "works" because in theory, all mutable ranges verify the "is output range" trait. However, they are not "sinks", so if you write too much into them, you'll get an out of index exception. Does it work at runtime, and do you get the correct behavior? From what I tested, yes it works correctly

Re: Using arrays with functions taking ranges

2012-12-14 Thread monarch_dodra
On Friday, 14 December 2012 at 13:09:15 UTC, Mu wrote: Thank you, monarch_dodra. This looks like what I wanted. I have a question: How come the function works with MmFile.opSlice's without appender(&)? And is this reliable behavior? caesarCipher(cast(ubyte[]) inputFile.opSlice, cast(ubyte[])

Re: Using arrays with functions taking ranges

2012-12-14 Thread Mu
Thank you, monarch_dodra. This looks like what I wanted. I have a question: How come the function works with MmFile.opSlice's without appender(&)? And is this reliable behavior? caesarCipher(cast(ubyte[]) inputFile.opSlice, cast(ubyte[]) outputFile.opSlice, 13); Trying to use appender(&) on

Re: Extensions to types loaded from a C library

2012-12-14 Thread Jacob Carlborg
On 2012-12-14 13:36, Mike Parker wrote: Obviously, this technique won't work for constructors, but it should work for most any other method you'd like to add. And I don't see a need to add a constructor anyway except in very specific circumstances (i.e. you want a constructor with fewer or more

Re: Extensions to types loaded from a C library

2012-12-14 Thread Jacob Carlborg
On 2012-12-14 10:30, Jeremy DeHaan wrote: I was playing with some code in the Derelict project(mainly the SFML portion) and was wondering what would happen if I made some changes. As long as the size of the struct doesn't change it's ok. Preferably you shouldn't change the type or ordering of

Re: Operator overloading of native types?

2012-12-14 Thread Jacob Carlborg
On 2012-12-14 00:19, H. S. Teoh wrote: I'd like to overload the '*' operator to work with string arguments. Is it possible? I tried the following, but apparently operator overloading doesn't work at the package level? string opBinary(string op)(string repeatMe, int thisManyTimes)

Re: Extensions to types loaded from a C library

2012-12-14 Thread Mike Parker
On Friday, 14 December 2012 at 09:30:50 UTC, Jeremy DeHaan wrote: I was playing with some code in the Derelict project(mainly the SFML portion) and was wondering what would happen if I made some changes. Here's an example of what I mean. In the C code, the struct sfVector2f is defined as such:

Re: Marking bug entires as fixed/closed on bugzilla

2012-12-14 Thread Simen Kjaeraas
On 2012-47-14 12:12, monarch_dodra wrote: I have a whole list of bugs/issues that have since been corrected in 2.060alpha. I was wondering when and how these were to be closed? Am I supposed to wait for an official 2.061 first? Do I have to prove it was fixed, or just a simple "verified fi

Marking bug entires as fixed/closed on bugzilla

2012-12-14 Thread monarch_dodra
I have a whole list of bugs/issues that have since been corrected in 2.060alpha. I was wondering when and how these were to be closed? Am I supposed to wait for an official 2.061 first? Do I have to prove it was fixed, or just a simple "verified fixed" comment enough?

Re: Using arrays with functions taking ranges

2012-12-14 Thread monarch_dodra
On Friday, 14 December 2012 at 10:20:38 UTC, Mu wrote: Thank you for your suggestion, bearophile. I ended up checking if the range is empty, and if it was, I'd increment it as elements were added. Honestly, I much dislike this method. It does not feel right. The C++ version is more consistent

Re: Using arrays with functions taking ranges

2012-12-14 Thread Mu
Thank you for your suggestion, bearophile. I ended up checking if the range is empty, and if it was, I'd increment it as elements were added. Honestly, I much dislike this method. It does not feel right. The C++ version is more consistent because of the iterators. Please, if anyone has a bet

Re: Extensions to types loaded from a C library

2012-12-14 Thread simendsjo
On Friday, 14 December 2012 at 09:30:50 UTC, Jeremy DeHaan wrote: I was playing with some code in the Derelict project(mainly the SFML portion) and was wondering what would happen if I made some changes. Here's an example of what I mean. In the C code, the struct sfVector2f is defined as such:

Extensions to types loaded from a C library

2012-12-14 Thread Jeremy DeHaan
I was playing with some code in the Derelict project(mainly the SFML portion) and was wondering what would happen if I made some changes. Here's an example of what I mean. In the C code, the struct sfVector2f is defined as such: typedef struct { float x; float y; } sfVector2f; The D v

Re: contracts in interfaces

2012-12-14 Thread Yann
Thanks for your reply! @property uint n(); n() needs to be const: @property uint n() const; Ok. Why is that? why does this produce a segmentation fault when executed: I don't know, you should show us a more complete minimal code that shows the segfault. Here you go (I stripped it do