OT: What's your favorite codeline?

language_fan foo at bar.com.invalid
Wed Sep 2 04:28:32 PDT 2009


Wed, 02 Sep 2009 10:28:58 +0200, downs thusly wrote:

> Robert Fraser wrote:
>> downs wrote:
>>> <downs>     foo.betweens("src=\"", "\"") /select/ (string s) { return
>>> s.find(criteria) != -1; }
>> 
>> Heh, I love that infix expression syntax. Too abd it ends up with a
>> completely useless wrapper struct & 2 function calls, but hopefully LDC
>> can inline that out.
>> 
>> 
> I'm 90% sure it can.
> 
> [update] Actually, I just tried and LDC compiles a simple /select/ test
> to plain, inlined code. [update2] GDC doesn't.
> [update3] For that matter, neither does DMD.
> 
> LDC is really shaping up to be the best D compiler out there. It already
> is on Unix (imho). Now if only they can get win32 exception support to
> work ..
> 
>>> <downs>     auto videocon =
>>> ctx.getStreams().first(WHERE!("?.codec.codec_type ==
>>> CodecType.Video")).codec;
>> 
>> Heh, going LINQ on us, now?
> 
> I _was_ thinking of that :) Could have used ex!() but WHERE is a little
> denser.
> 
> (for comparison: ex!("c -> c.codec.codec_type == CodecType.Video") )

This is impressive. You acknowledge that the functional representation is 
so much better that you actually implement its compiler with the 
metaprogramming facilities. Imagine, in future, you can just write, mixin 
compile("SML", ` some code ... `); and all your problems are solved. It's 
a shame the built-in syntax looks like this crap

  (T)(T c){ return c; }

instead of this

  c -> c



More information about the Digitalmars-d mailing list