My body is ugly [Re: Contextualizing keywords]

Pete example at example.com
Mon Aug 3 02:20:45 PDT 2009


Don Wrote:

> Robert Fraser wrote:
> > Hi, hope you're all enjoying the properties debate.
> > 
> > I've been seeing the "too many keywords" argument a lot lately, and I 
> > think it's definitely a valid argument. "shared" and "body" in 
> > particular are rather annoying keywords since I frequently use them in 
> > code. And if users are deciding not to use D because of the number of 
> > keywords, that's even worse.
> 
> Why not just get rid of 'body'?
> 
> 'body' is the most useless keyword in D. It's ugly, and doesn't achieve 
> anything much at all -- it's just a compiler-checked comment, really.
> Almost identical to // body
> 
> Compare:
> ----------------------
> int foo(int a)
> in {
>     assert(a>2);
> }
> body
> {
>     return a-1;
> }
> ----------------------
> int foo(int a)
> in {
>     assert(a>2);
> }
> // body
> {
>     return a-1;
> }
> ----------------------
> 
> That's a ridiculously tiny benefit for a keyword. I hate my body.
> <g>

I think this is much more elegant:

# int foo(int a) {
#    in {
#       assert(a>2);
#    }
#
#    return a-1;
# }





More information about the Digitalmars-d mailing list