Steven Schveighoffer schvei...@yahoo.com wrote:
1. a function may have the same name and usage, but have a completely
different meaning. Human languages are funny that way. This means,
your function could accept a type as a parameter and use it in a very
wrong way. Most of the time,
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(
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
{
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(
this is avoided as the
rename would break the interface.
Is there any idoms you can use to avoid stuff like this? Relying on
documentation doesn't seem like a good solution.
If what you want is compile-time type safety, then duck typing is
probably not for you. That's sort of the whole point
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;
, then duck typing is
probably not for you. That's sort of the whole point behind duck typing:
you defer typing decisions to runtime. If you need compiler breakage for
something like that, use interfaces.
No, duck typing is compile-time. Essentially, it goes like this:
void foo(T)(T duck
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
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(