Re: Passing around a list of differently typed functions

2014-06-23 Thread Tobias Pankrath via Digitalmars-d-learn
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b); bool bar(bool a, bool b); into

Re: Passing around a list of differently typed functions

2014-06-23 Thread FreeSlave via Digitalmars-d-learn
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b); bool bar(bool a, bool b); into

Re: Passing around a list of differently typed functions

2014-06-23 Thread Bienlein via Digitalmars-d-learn
On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int b); bool bar(bool a, bool b); into

Unexpected OPTLINK Termination while building ddb and gtkd

2014-06-23 Thread Orfeo via Digitalmars-d-learn
My dub.json : ``` { name: ddb_test, description: A minimal D application., dependencies: { gtk-d:gtkd: =2.3.3, ddb: =0.2.1 } } ``` My source (source/app.d): ``` import ddb.postgres; import gtk.Window; int main(string[] argv) { return 0; } ``` On linux works, on

Re: Passing around a list of differently typed functions

2014-06-23 Thread Alix Pexton via Digitalmars-d-learn
On 23/06/2014 8:19 AM, Bienlein wrote: On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a, int

Why does this work?

2014-06-23 Thread h_zet via Digitalmars-d-learn
import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left value but when I compiled this, no error occured. DMD version is DMD64 v2.065.(ldc2 exited with error

Re: Why does this work?

2014-06-23 Thread VonGrass via Digitalmars-d-learn
On Monday, 23 June 2014 at 08:30:44 UTC, h_zet wrote: import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left value but when I compiled this, no error occured.

Re: Why does this work?

2014-06-23 Thread hane via Digitalmars-d-learn
On Monday, 23 June 2014 at 08:30:44 UTC, h_zet wrote: import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left value but when I compiled this, no error occured.

Re: Why does this work?

2014-06-23 Thread Mason McGill via Digitalmars-d-learn
On Monday, 23 June 2014 at 08:30:44 UTC, h_zet wrote: import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left value but when I compiled this, no error occured.

Re: Why does this work?

2014-06-23 Thread Mason McGill via Digitalmars-d-learn
On Monday, 23 June 2014 at 09:29:15 UTC, Mason McGill wrote: Strange behavior, indeed. It took me a minute, but I think I know what's going on, and I'm pretty sure it's a bug. D recently introduced a short syntax for function-like templates: enum a(b) = some_value; It looks like this also

Re: Why does this work?

2014-06-23 Thread bearophile via Digitalmars-d-learn
h_zet: Why does this work? Or it is a bug? When you play a little with this code it's easy to see _error_ that should not appear. So there's surely something worth reporting as bug, but I don't yet know what. Bye, bearophile

Contributing to D language

2014-06-23 Thread Mike via Digitalmars-d-learn
I wish I could help with the development of D (either the compiler or std library). Is there a TODO list kept somewhere? Neither Phobos nor DMD have an `issues` page on Github.. I found this http://wiki.dlang.org/Review_Queue but it's kind of short. Best regards, Mike

Re: Contributing to D language

2014-06-23 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jun 23, 2014 at 04:43:30PM +, Mike via Digitalmars-d-learn wrote: I wish I could help with the development of D (either the compiler or std library). Is there a TODO list kept somewhere? Neither Phobos nor DMD have an `issues` page on Github.. [...] http://issues.dlang.org/ See

Re: Contributing to D language

2014-06-23 Thread John Colvin via Digitalmars-d-learn
On Monday, 23 June 2014 at 16:43:31 UTC, Mike wrote: I wish I could help with the development of D (either the compiler or std library). Is there a TODO list kept somewhere? Neither Phobos nor DMD have an `issues` page on Github.. I found this http://wiki.dlang.org/Review_Queue but it's

Re: Question about iteger literals

2014-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sun, 22 Jun 2014 08:23:45 -0400, Uranuz neura...@gmail.com wrote: If these rules are not so clear and have some exceptions (but I don't understand why they are needed) then some documentation needed about this. See integer promotion rules:

Re: Passing around a list of differently typed functions

2014-06-23 Thread Ali Çehreli via Digitalmars-d-learn
On 06/22/2014 11:32 PM, FreeSlave wrote: On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have different type signatures. Is there a way to put the two functions int foo(int a,

Re: Passing around a list of differently typed functions

2014-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Mon, 23 Jun 2014 14:30:12 -0400, Ali Çehreli acehr...@yahoo.com wrote: On 06/22/2014 11:32 PM, FreeSlave wrote: On Monday, 23 June 2014 at 01:16:49 UTC, Evan Davis wrote: As the subject says, I would like to pass around an array of functions. The trick is, that the functions have

Re: Contributing to D language

2014-06-23 Thread Suliman via Digitalmars-d-learn
A lot of developers will say thanks if you help with developing DGUI https://bitbucket.org/dgui/dgui/ D very need native and easy to use GUI lib...

Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-23 Thread Christian Beaumont via Digitalmars-d-learn
Hi, I just started learning D, and thought I'd throw myself in at the deep end with some meta-programming, trying to write the equivalent of the commonly used, async waterfall, and also, because I'd like to use it... If you aren't familiar with it, waterfall is a function that is passed a

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-23 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Jun 23, 2014 at 9:39 PM, Christian Beaumont via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Each function is given a callback, that when called, steps the waterfall forward on to the next function to process. If an error is passed to the callback (instead of null),

Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread John Carter via Digitalmars-d-learn
I guess between perl and Ruby and Scheme etc. I got used to creating hybrid containers Want a pair of [string, fileList]? Just make an Array with two items, one a string, one and array of strings. Done. D barfed... leaving me momentarily stunned... then Oh Yes, type safety, Tuple's are

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread Chris Williams via Digitalmars-d-learn
On Monday, 23 June 2014 at 21:18:39 UTC, John Carter wrote: I guess between perl and Ruby and Scheme etc. I got used to creating hybrid containers Want a pair of [string, fileList]? Just make an Array with two items, one a string, one and array of strings. Done. D barfed... leaving me

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread Ary Borenszweig via Digitalmars-d-learn
On 6/23/14, 6:18 PM, John Carter wrote: I guess between perl and Ruby and Scheme etc. I got used to creating hybrid containers Want a pair of [string, fileList]? Just make an Array with two items, one a string, one and array of strings. Done. D barfed... leaving me momentarily stunned...

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread bearophile via Digitalmars-d-learn
Ary Borenszweig: As a library solution I would do something like this: Union!(int, string)[] elements; elements ~= 1; elements ~= hello; Take a look at Algebraic in Phobos. Bye, bearophile

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread John Carter via Digitalmars-d-learn
On Monday, 23 June 2014 at 21:26:19 UTC, Chris Williams wrote: More likely what you want are variants: Hmm. Interesting. Yes, Variant and VariantArray are much closer to the dynamic language semantics... But the interesting thing is Tuple is much closer to What I Mean when I create these

Re: very short pipeShell program

2014-06-23 Thread John Carter via Digitalmars-d-learn
Ali, of course, is right. The only thing I'd add is for a Windowsy programmer (unless you have cygwin installed) you probably want something like cmd.exe instead of bash.

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread Meta via Digitalmars-d-learn
On Monday, 23 June 2014 at 22:11:57 UTC, John Carter wrote: On Monday, 23 June 2014 at 21:49:29 UTC, Ary Borenszweig wrote: Union types are very common (I use them every day), and IMHO it's very nice to have them included in the language (either built-in or as a library solution). As a

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-23 Thread Christian Beaumont via Digitalmars-d-learn
Just to be sure: whether or not an error is passed to a callback, the final callback is always called? I mean, the last callback could also be called *only when something fails*, a bit like a default case in a switch, or an error-handling routine. Yes, the final callback is always called,

Re: Trying to reproduce Node.js async waterfall pattern.. (Meta-programming)

2014-06-23 Thread Christian Beaumont via Digitalmars-d-learn
Just an idea that popped into my head... Maybe I can use variant for the input/output types? I haven't looked at it yet, so I'm not sure what it does, or the performance costs. I realized that because the final callback always gets called, and the types of the intermediate steps may be

Missed it by THIS much

2014-06-23 Thread Jason King via Digitalmars-d-learn
This is me trying to link with Juno and getting tantalizingly close to success. DMD home is d:\d so binaries are d:\d\dmd2\windows\bin (on path) Juno is in D:\dlang\Juno-Windows-Class-Library D:\dlang\Juno-Windows-Class-Library\juno.lib exists sc.ini is untouched

Re: Why does this work?

2014-06-23 Thread h_zet via Digitalmars-d-learn
On Monday, 23 June 2014 at 09:09:56 UTC, hane wrote: On Monday, 23 June 2014 at 08:30:44 UTC, h_zet wrote: import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left

Another rambling musing by a Dynamic Programmer - map!

2014-06-23 Thread John Carter via Digitalmars-d-learn
So in Ruby and R and Scheme and... I have happily used map / collect for years and years. Lovely thing. So I did the dumb obvious of string[] stringList = map!...; And D barfed, wrong type, some evil voldemort thing again. So.. auto stringList = map!; and we're good.. and

Re: Missed it by THIS much

2014-06-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 24/06/2014 1:13 p.m., Jason King wrote: This is me trying to link with Juno and getting tantalizingly close to success. DMD home is d:\d so binaries are d:\d\dmd2\windows\bin (on path) Juno is in D:\dlang\Juno-Windows-Class-Library D:\dlang\Juno-Windows-Class-Library\juno.lib exists sc.ini

Compilation error while adding two shorts

2014-06-23 Thread David Zaragoza via Digitalmars-d-learn
Hello I'm trying to compile the following program: module main; int main(string[] argv){ short asd = 1; short qwe = asd + asd; return 0; } And the compiler gives this error: C:\Daviddmd simple simple.d(5): Error: cannot implicitly convert expression (cast(int)asd +