Why Ruby?

Jacob Carlborg doob at me.com
Mon Dec 13 11:02:00 PST 2010


On 2010-12-13 04:23, Adam D. Ruppe wrote:
> Ary Borenszweig wrote:
>> D should provide a yield keyword that basically
>> rewrites the body of the method into the first code.
>
> Don't need to change the language for that.
>
> =========
>
> string yield(string what) {
>    return `if(auto result = dg(`~what~`)) return result;`;
> }
>
> class Foo
> {
>      uint array[2];
>
>      int opApply(int delegate(ref uint) dg) {
>           mixin(yield("array[0]"));
>           mixin(yield("array[1]"));
>
> 	return 0;
>      }
> }
> =========
>
> Compiles and runs as expected, on today's D.

This is just ugly.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list