Duck typing and safety.

2010-08-13 Thread simendsjo
While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio; struct S { void shittyNameThatProbablyGetsRefactored() { }; } void process(T)(T s) { static if(

Re: Duck typing and safety.

2010-08-13 Thread Mafi
Am 13.08.2010 19:01, schrieb simendsjo: import std.stdio; struct S { void shittyNameThatProbablyGetsRefactored() { }; } void process(T)(T s) { static if( __traits(hasMember, T, shittyNameThatProbablyGetsRefactored)) { writeln(normal processing); } else {

Re: Duck typing and safety.

2010-08-13 Thread Adam Burton
simendsjo wrote: While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio; struct S { void shittyNameThatProbablyGetsRefactored() { }; } void process(T)(T s) { static if(

Re: Duck typing and safety.

2010-08-13 Thread Ryan W Sims
On 8/13/10 10:01 AM, simendsjo wrote: While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio; struct S { void shittyNameThatProbablyGetsRefactored() { }; } void process(T)(T s) {

Re: associative array of associative arrays.

2010-08-13 Thread Pelle
On 08/13/2010 01:17 AM, dcoder wrote: Hello. How do you declare and initialize a map that looks like the following: Name = [ Personal Info] Where personal info is type string[string]. I can't get this to compile. I'm wondering what I am doing wrong: import std.stdio; void main() {

Re: Duck typing and safety.

2010-08-13 Thread simendsjo
On 13.08.2010 19:17, Steven Schveighoffer wrote: On Fri, 13 Aug 2010 13:01:47 -0400, simendsjo simen.end...@pandavre.com wrote: While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio;

Re: Duck typing and safety.

2010-08-13 Thread Steven Schveighoffer
On Fri, 13 Aug 2010 13:20:32 -0400, Ryan W Sims rws...@gmail.com wrote: On 8/13/10 10:01 AM, simendsjo wrote: While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio; struct S { void

Re: Duck typing and safety.

2010-08-13 Thread Steven Schveighoffer
On Fri, 13 Aug 2010 13:32:11 -0400, simendsjo simen.end...@pandavre.com wrote: On 13.08.2010 19:17, Steven Schveighoffer wrote: On Fri, 13 Aug 2010 13:01:47 -0400, simendsjo simen.end...@pandavre.com wrote: While reading std.range, I though that a ducktyping design without language/library

Re: Duck typing and safety.

2010-08-13 Thread Tomek Sowiński
simendsjo napisał: While reading std.range, I though that a ducktyping design without language/library support can be quite fragile. Consider the following example: import std.stdio; struct S { void shittyNameThatProbablyGetsRefactored() { }; } void process(T)(T s) { static if(