Another idiom I wish were gone from phobos/druntime

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 00:35:36 PST 2015


On Wed, 04 Feb 2015 16:24:14 -0800, Andrei Alexandrescu wrote:

> I'm seeing another idiom that seems to become fashionable. Consider this
> excerpt from
> https://github.com/D-Programming-Language/phobos/blob/master/std/
algorithm/iteration.d#L407:
> 
>              auto opSlice(size_t low, size_t high)
>              in {
>                  assert(low <= high);
>              }
>              body {
>                  import std.range : take;
>                  return this[low .. $].take(high - low);
>              }
> 
> which of course trivially boils down to:
> 
>              auto opSlice(size_t low, size_t high)
>              {
>                  assert(low <= high);
>                  import std.range : take;
>                  return this[low .. $].take(high - low);
>              }
> 
> What advantage could possibly be in transforming a 5-liner into a
> 9-liner? Are we really aiming at writing the maximum possible lines of
> code here and using as many language features as possible everywhere?
> 
> I think we should dust off that Phobos contributors' guide. Sadly, there
> is little we can do against the more subtle issues.

so you basically telling that "in block" feature is so useless, that even 
language devs recommend to avoid it. great.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150205/9cdb7eaa/attachment-0001.sig>


More information about the Digitalmars-d mailing list