On 2011-03-31 01:05, KennyTM~ wrote:
On Mar 31, 11 06:32, Ary Manzana wrote:
On 3/30/11 5:52 PM, KennyTM~ wrote:
On Mar 31, 11 04:19, Alix Pexton wrote:
On 30/03/2011 20:45, KennyTM~ wrote:
This is confusing as :: is used to separate scopes in C++ (and PHP
too).

The first thing it reminded me of was Lua, where a single colon makes
the left hand side into the first argument of the function on the
right.

foo:bar(x) ==> bar.(foo, x)

So it felt kinda familiar to me ^^

A...

That is almost like UFCS in D.

int foo(string x, int y) { return x.length - y; }

assert (foo("testing", 3) == 4);
assert ("testing".foo(3) == 4);

But OP's proposal is restricted to __traits only.

__traits is a relatively advanced part of the language, plus many of its
features has already been exposed via the library std.traits, e.g.
std.traits.hasMember!(S, "m"), I don't think it really needs a very
short syntax.

Look, metaprogramming in Ruby is a relatively advanced part of the
language. And you know why it is heavily used and everyone can jump and
start using it in a matter of seconds and build the most amazing things?
Because it's very, very, very, (add 1000 very words here), very easy to
use.


We're talking about __traits, a feature for compile-time reflection
where most of its capability is already wrapped up to std.traits. It
isn't comparable with the whole metaprogramming capability in another
language.

You know, metaprogramming is also heavily used in D, because of a
sensible template system, mixins and CTFE, not __traits.

Why make *anything* hard to use if you can do it in an easier way?

Is

meta.hasMember(S, "m")

or even

import std.traits;
...
hasMember!(S, "m")

really that hard to use?

I think the 'meta' namespace is enough. 'A::B' is too much for such a
low-level feature.

In Ruby it would just be: S.hasMember("m") and "hasMember" would just be a regular plain old method, nothing special about it.

--
/Jacob Carlborg

Reply via email to