On 2010-12-13 11:50, Stephan Soller wrote:
On 12.12.2010 21:17, spir wrote:
On Sun, 12 Dec 2010 12:23:03 -0600
Andrei Alexandrescu<seewebsiteforem...@erdani.org> wrote:

Going now
back to D, we can imagine the following lowering:

fun (a, b ; c) stmt

=>

fun(c, (a, b) { stmt })

It seems to me that lowering is analog to redefine "shallow" syntax
(in fact, syntactic sugar) into a deeper syntax mirroring that actual
AST. The syntax tree for foreach/iteration could be written as:

iteration:
collection: c
loopVarNames: ['a','b']
block: stmt

And generalised into:

blockOperation:
source: c
loopVarNames: ['a','b']
block: stmt
where your 'func' is a "block-wise operation". What do you think?

But I do not see in what Ruby-like syntax and point of view are
clearer; actally, I find D far more readable.
And even less what this would bring to D. This is interesting in
highly reflexive languages; even more reflexive than Ruby in fact,
where one could tweak the block at runtime. But this is not the
perspective of D, I guess.


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com


I think it's a matter of consistency. In Ruby blocks are used all the
time for pretty much everything. In D this isn't the case because
usually templates are used for stuff where blocks are used in Ruby (e.g.
map, group and find in std.algorithm).

I think that the templates that take a string as a predicate is just an ugly hack because D has a too verbose delegate syntax.

I don't know if it's possible to unify the way to "pass code as an
argument" in D but that's where Ruby really shines in my opinion:
consistency in usage.

Happy programming
Stephan Soller


--
/Jacob Carlborg

Reply via email to