Re: Programming on OSX
On 01-Jan-12 3:27 AM, Jacob Carlborg wrote: On 2011-12-31 00:50, Joel Christensen wrote: I've got an Mac with OSX. But I have a few problems with using it with D. 1. I haven't got any media programming going. Could you please elaborate. Derelict is a library that contains bindings for OpenGL, OpenAL, SDL and DevIL among others. Thanks for replying Jacob. I looked up Derelict and it seem to say Derelict's SDL didn't work with OSX yet. I haven't done much digging though. I'm more interested in Allegro5 working with OSX, there's one Allegro library that works with Windows and Linux, but not OSX. On a bit different note. What's the differences with a library, a wrapper, and a binding? 2. The readln (etc) isn't much good, same problem as Linux. It can only add characters and remove characters from the end.
Re: Programming on OSX
On 1/1/2012 7:38 PM, Joel Christensen wrote: On 01-Jan-12 3:27 AM, Jacob Carlborg wrote: On 2011-12-31 00:50, Joel Christensen wrote: I've got an Mac with OSX. But I have a few problems with using it with D. 1. I haven't got any media programming going. Could you please elaborate. Derelict is a library that contains bindings for OpenGL, OpenAL, SDL and DevIL among others. Thanks for replying Jacob. I looked up Derelict and it seem to say Derelict's SDL didn't work with OSX yet. I haven't done much digging though. I'm more interested in Allegro5 working with OSX, there's one Allegro library that works with Windows and Linux, but not OSX. DerelictSDL works fine on Mac. The Derelict 2 branch also has a binding for Allegro 5 which should work on Mac after a minor update. I'm using the DerelictAllegro binding for a couple of projects right now. On a bit different note. What's the differences with a library, a wrapper, and a binding? A /library/ is a collection of resuable code. SDL and Allegro5 are libraries. A /binding/ is a kind of library that provides a bridge to use a library written in a language different from what it was written with.The details of how that happens depends entirely on the language the binding is written for. For example, in Java, bindings to C or C++ libraries are effectively wrappers, because of the way the bindings must be written. But in D, because it is compatible with the C ABI, bindings can be one-to-one. Meaning, as long as a C function or type has a declaration in D, it can be used in D. Derelict is an example of a binding (well, several bindings). A /wrapper/ is a kind of library that encloses an existing library in a different interface. Usually, it's a free function interface being wrapped in an object-oriented interface. For example, Allegro is written in C. A D (or C++) wrapper might be written to give it an object-oriented interface, as long as it had a binding to work with. In other words, it allows you to do this (: Bitmap bmp = new Bitmap(); instead of this: ALLEGRO_BITMAP* bmp = al_create_bmp(...); So to use a wrapper of a C library in D, you would have this setup: C Library - D binding library (allows C functions to be called in D) - D Wrapper library (giving an object oriented interface) - application Of course, the wrapper could also be the binding. Personally, I think wrappers are a waste of time, but some people prefer them to using a C API directly.
Re: Programming on OSX
On Sunday, 1 January 2012 at 11:54:46 UTC, Mike Parker wrote: Personally, I think wrappers are a waste of time, but some people prefer them to using a C API directly. I agree for wrappers that mindlessly provide a different syntax for the same functionality, but wrappers can take advantage of more advanced language features to provide better safety, genericity or brevity than the original. These are the wrappers that are worth writing and worth using.
Re: Cartesian product of ranges?
On 14/12/11 9:21 PM, Timon Gehr wrote: On 12/14/2011 09:14 PM, Justin Whear wrote: I've looked through std.algorithm and std.range, but haven't found anything to compute the Cartesian product of several ranges. I have the nagging feeling that this can be accomplished by combining several of the range transformations in the standard library. What I'm after is something like this: alias Tuple!(int, string) P; assert(equal( cartesianProduct([1, 2], [a, b]), [ P(1, a), P(1, b), P(2, a), P(2, b) ] )); auto cartesianProduct(R,S)(R r, S s)if(isInputRange!R isForwardRange!S){ struct CartesianProduct{ private{R r; S s, startS;} this(R r, S s){this.r=r; this.s=s; startS=this.s.save;} @property auto front(){return tuple(r.front, s.front);} @property bool empty(){return r.empty;} void popFront(){ s.popFront(); if(s.empty){ s = startS.save; r.popFront(); } } static if(isForwardRange!R): @property auto save(){return typeof(this)(r.save, s.save);} } return CartesianProduct(r,s); } The implementation of this was discussed at length a while ago. The obvious implementation that you have above was presented, but Andrei was unhappy that it didn't work well with infinite ranges. Some schemes were investigated so that the products of two infinite ranges could would get better sampling, but the whole thing got stuck in analysis paralysis and nothing ever happened. What you have above should be added into Phobos. If people want the product of infinite ranges then they can just to it manually.
Re: typedef deprecated - now what ?
On 31/12/2011 13:34, Trass3r wrote: Basically it was deprecated because it's poorly defined and implemented. snip Would you care to elaborate? Moreover, if that's the only reason then why not improve it rather than getting rid of it? There are several types of typedefs that need to be available: parallel, opaque, supertype and subtype. See http://d.puremagic.com/issues/show_bug.cgi?id=5467 I see. So the built-in typedef is closest in semantics to subtype, but leaves bits to be desired. Stewart.
Re: Programming on OSX
On 1/2/2012 6:10 AM, Joel Christensen wrote: Thanks very much Mike. I guess I've got a bit of a wrapper over a binding. I'll look more into Derelict for Mac OSX. If it's DerelictAllegro you're using, then you need to know this. Derelict loads libraries manually (via dlopen on Posix systems). This means you have to do this in your code for each binding you want to use: DerelictAllegro.load(); This will use preconfigured paths to load the libraries. Currently, DerelictAllegro is only configured to load on Windows. I need to figure out how it is typically installed on OSX so I can pass the correct paths to the loader. It should just be a matter of a quick Google, but it might be a few hours yet before I can get to it. In the meantime, the load method accepts a string parameter if you want to load a specific library. So you can do this for now: DerelictAllegro.load(path); ... where path is the framework/dylib/so, whatever the case may be. Aside from that, the rest should just work.
Re: Programming on OSX
On Sunday, 1 January 2012 at 11:54:46 UTC, Mike Parker wrote: On 1/1/2012 7:38 PM, Joel Christensen wrote: On 01-Jan-12 3:27 AM, Jacob Carlborg wrote: On 2011-12-31 00:50, Joel Christensen wrote: I've got an Mac with OSX. But I have a few problems with using it with D. 1. I haven't got any media programming going. Could you please elaborate. Derelict is a library that contains bindings for OpenGL, OpenAL, SDL and DevIL among others. Thanks for replying Jacob. I looked up Derelict and it seem to say Derelict's SDL didn't work with OSX yet. I haven't done much digging though. I'm more interested in Allegro5 working with OSX, there's one Allegro library that works with Windows and Linux, but not OSX. DerelictSDL works fine on Mac. The Derelict 2 branch also has a binding for Allegro 5 which should work on Mac after a minor update. I'm using the DerelictAllegro binding for a couple of projects right now. I seem to get SDL to work, but not OpenGL. I copied it's frame work from system some where to another frameworks place. I've got XCode installed. P.S. I wont have OSX for a while soon, (getting a new computer). Also lost my previous login password, so I've started a new one. [snip]
Re: Programming on OSX
[snip] I seem to get SDL to work, but not OpenGL. I copied it's frame work from system some where to another frameworks place. I've got XCode installed. Hmm. I had a go at another test program I found and got it working. Graphics with D on OSX, so now that's Windows, Ubuntu, and now OSX. Just one solid colour, mind. [snip]