Re: to! converting 1D to 2D array

2014-03-11 Thread monarch_dodra
On Wednesday, 12 March 2014 at 03:37:49 UTC, ed wrote: Thanks for explaining this, it makes sense what you said. But I'm still not sure why my original Example 1 worked. ~~~ // This works OK and converts long[4] to int[] then implicitly to int[2][2] long[4] a=[1,2,3,4]; int[2][2] b = to!(int[

Re: Compiler version at compile-time

2014-03-11 Thread H. S. Teoh
On Wed, Mar 12, 2014 at 02:53:41AM +, David Eagen wrote: > On Wednesday, 12 March 2014 at 02:46:30 UTC, David Eagen wrote: > >Is there a way to determine the compiler version at compile time? > >Something like: > > > >static if(DMD_VERSION >= 2.066) { > > virtual int foo(); > >} else { > > in

Re: to! converting 1D to 2D array

2014-03-11 Thread ed
On Wednesday, 12 March 2014 at 02:14:45 UTC, bearophile wrote: ed: I am trying to convert a 1D array to a 2D array If you have a dynamic array (1D), you can convert it to a dynamic array of dynamic arrays (2D) using chunks: void main() { import std.stdio, std.range, std.algorithm;

Re: writeln if not empty

2014-03-11 Thread Timothee Cour
Thanks! your solution is more robust (minus some caveats i mentioned) and also trivially extends to variadics. On Tue, Mar 11, 2014 at 2:07 PM, monarch_dodra wrote: > On Tuesday, 11 March 2014 at 05:37:25 UTC, Timothee Cour wrote: > >> void writelnIfNotEmpty(T)(T a){ >> auto file_pos=get_filepos

Re: Compiler version at compile-time

2014-03-11 Thread David Eagen
On Wednesday, 12 March 2014 at 02:46:30 UTC, David Eagen wrote: Is there a way to determine the compiler version at compile time? Something like: static if(DMD_VERSION >= 2.066) { virtual int foo(); } else { int foo(); } Naturally I found it as soon as I posted std.compiler : version

Compiler version at compile-time

2014-03-11 Thread David Eagen
Is there a way to determine the compiler version at compile time? Something like: static if(DMD_VERSION >= 2.066) { virtual int foo(); } else { int foo(); }

Re: to! converting 1D to 2D array

2014-03-11 Thread bearophile
ed: I am trying to convert a 1D array to a 2D array If you have a dynamic array (1D), you can convert it to a dynamic array of dynamic arrays (2D) using chunks: void main() { import std.stdio, std.range, std.algorithm; int[] a = [1, 2, 3, 4, 5, 6]; int[][] b = a.chunks(2).arra

to! converting 1D to 2D array

2014-03-11 Thread ed
Hi All, I am trying to convert a 1D array to a 2D array using to! and was wondering if someone could explain to me why this first example works but the second example does not compile: Example 1: ~~~ import std.conv; long[4] a=[1,2,3,4]; int[2][2] b = to!(int[])(a); assert(b == [[1,2],[3,4]])

Re: Mixing messages and socket operations

2014-03-11 Thread Sean Kelly
On Tuesday, 11 March 2014 at 14:44:51 UTC, Andre Kostur wrote: Hi, I'm trying a prototype project at work and have been trying to find a good example of network programming in D. What I'm trying to do is have a separate thread to deal with the socket (calls .accept() for example), but I'd also

Re: writeln if not empty

2014-03-11 Thread monarch_dodra
On Tuesday, 11 March 2014 at 05:37:25 UTC, Timothee Cour wrote: Thanks, that indeed works in many cases but there are still others (eg what if empty() prints, say in debug mode: writelnIfNotEmpty would not print the debug information even though writeln() would execute that debug code and pri

Re: New to std.algorithm and generics, no idea how to make simple things to work

2014-03-11 Thread monarch_dodra
On Sunday, 9 March 2014 at 09:06:51 UTC, John Colvin wrote: std.container isn't great and hasn't received enough attention. There are plans to improve it, but I believe we're waiting on std.allocator and possibly a higher level layer on top of it before any significant revamp is made. It is per

Re: writeln if not empty

2014-03-11 Thread monarch_dodra
On Tuesday, 11 March 2014 at 05:37:25 UTC, Timothee Cour wrote: void writelnIfNotEmpty(T)(T a){ auto file_pos=get_filepos(stdin); write(a); if(get_filepos(stdin)!=file_pos) writeln; } You could simply create an sink that forwards to stdout, while keeping state: // import std.stdio, std.f

Re: Objective-C runtime: bindings are possible?

2014-03-11 Thread Jacob Carlborg
On 2014-03-11 16:12, Paolo Invernizzi wrote: Hi all, I'm wondering if it is possible to directly interface with the objective-c runtime, as I've read [1] and I have some random crashes in my code right now. Yes, it's possible since the Objective-C runtime is plain C functions. You need to sho

Objective-C runtime: bindings are possible?

2014-03-11 Thread Paolo Invernizzi
Hi all, I'm wondering if it is possible to directly interface with the objective-c runtime, as I've read [1] and I have some random crashes in my code right now. Someone can share some experience? I'm on 10.9... Thanks, Paolo [1] http://d.puremagic.com/issues/show_bug.cgi?id=9931

Mixing messages and socket operations

2014-03-11 Thread Andre Kostur
Hi, I'm trying a prototype project at work and have been trying to find a good example of network programming in D. What I'm trying to do is have a separate thread to deal with the socket (calls .accept() for example), but I'd also like the thread to be responsive to the OwnerTerminated messag

Re: Getting a compiler with '-inline'. Is this valid?

2014-03-11 Thread Steven Schveighoffer
On Tue, 11 Mar 2014 05:15:45 -0400, Saurabh Das wrote: On Tuesday, 11 March 2014 at 09:10:56 UTC, John Colvin wrote: Internal compiler errors are always bugs. Please report it here: https://d.puremagic.com/issues/enter_bug.cgi?product=D Oh okay. Will surely do that. (Yay my first bug

Re: Getting a compiler with '-inline'. Is this valid?

2014-03-11 Thread Saurabh Das
On Tuesday, 11 March 2014 at 09:10:56 UTC, John Colvin wrote: Internal compiler errors are always bugs. Please report it here: https://d.puremagic.com/issues/enter_bug.cgi?product=D Oh okay. Will surely do that. (Yay my first bug report ever!)

Re: Getting a compiler with '-inline'. Is this valid?

2014-03-11 Thread John Colvin
On Tuesday, 11 March 2014 at 08:43:11 UTC, Saurabh Das wrote: Hello, Consider this simple file 'byLineError.d': import std.stdio; void main() { auto f = File("test"); f.byLine.popFront(); } When I compile: dmd byLineError.d --- succeeds dmd -inline byLineError.d --- fails with 'Inte

Re: Getting a compiler with '-inline'. Is this valid?

2014-03-11 Thread Saurabh Das
The title should have read "Getting a compiler _error_ with '-inline'. Is this valid?" :((

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread Orfeo
On Tuesday, 11 March 2014 at 08:22:40 UTC, dennis luehring wrote: ->8- what do you need? ->8- Well, I should connect to result.mdb database and performs some queries, i.e. select * from result order by id select * from task where result_id=22 ... se

Getting a compiler with '-inline'. Is this valid?

2014-03-11 Thread Saurabh Das
Hello, Consider this simple file 'byLineError.d': import std.stdio; void main() { auto f = File("test"); f.byLine.popFront(); } When I compile: dmd byLineError.d --- succeeds dmd -inline byLineError.d --- fails with 'Internal error: backend/cod2.c 2200' Using dmd version "DMD64 D

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread dennis luehring
Am 11.03.2014 09:06, schrieb Orfeo: Thank you for github link, I had tried only with mdbtools on http://mdbtools.sourceforge.net/... So, it seems that I can connect using libmdb or odbc ... so everything is fine? or "I can not" have you any suggestions? answer the question what do you n

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread Orfeo
On Tuesday, 11 March 2014 at 07:52:33 UTC, dennis luehring wrote: ->8--- what is not enough? ->8--- Thank you for github link, I had tried only with mdbtools on http://mdbtools.sourceforge.net/... So, it seems that I can connect using libmdb or odbc ... have you any suggestions?

Running unittests in static libraries.

2014-03-11 Thread Boyd
I've run across an annoying bug in DMD. Apparently unittests compiled in a static library are not run in the executable. This pretty much makes them useless to me since for the project I'm working on, all business code is in static libraries. The executable project is only a shell to test the l

Re: Interface to Microsoft Access database (Jet)

2014-03-11 Thread dennis luehring
Am 11.03.2014 08:37, schrieb Orfeo: I should extract and process data from Microsoft Access database, and mdbtools is not enough. Is there a library that I can use to query Access? Thanks "mdbtools is not enough" what is not enough? what "version" of mdbtools do you use https://github.com/

Interface to Microsoft Access database (Jet)

2014-03-11 Thread Orfeo
I should extract and process data from Microsoft Access database, and mdbtools is not enough. Is there a library that I can use to query Access? Thanks