The DUB package manager

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Feb 23 11:20:22 PST 2013


On Sat, Feb 23, 2013 at 06:42:43PM +0000, Russel Winder wrote:
> On Sat, 2013-02-23 at 22:24 +0400, Dmitry Olshansky wrote:
> […]
> > It doesn't help *reading* this verbosity.
> 
> Very, very true.
> 
> Sadly, D has some arcane bits that make it equally difficult to read D
> code. For example:
> 
> example.filter!isLongEnough().array()
> 
> Why ! in one place and . in the others, it is all just calling a method
> on something.
[...]

One of the worst offenders in D is the is-expression. Not only are the
meaning of the arguments mysterious and manifold, they also have
non-obvious intents:

	void myGenericFunction(T,U,V)(T t, U u, V v)
		if (is(T) && is(typeof(T.a)) &&
			is(U : int) && is (V _ : W[X], W, X) &&
			is(typeof(T.expectedMember)) &&
			is(typeof(T.expectedMember())) &&
			is(typeof(T.expectedMember() : V))
			// ^ Completely opaque unless you stare at it
			// long enough.
		)
	{
		// Lisp fans would love the level of parentheses in this
		// next line:
		static if (isInputRange!(typeof(T.expectedMember())))
			dotDotDotMagic(t,u,v);
		else
			moreDotDotDotMagic(t,u,v);
	}


T

-- 
"Holy war is an oxymoron." -- Lazarus Long


More information about the Digitalmars-d mailing list