opDispatch(string name, E...) (E e) question.

James Miller james at aatch.net
Sun Mar 25 14:04:59 PDT 2012


On 26 March 2012 09:45, bls <bizprac at orange.fr> wrote:
> How do I "call" opDispatch(string name, E...)(E elements) ?
> What I want to archive is to call f.i. fm.list with an arbitrary number of
> arguments without using
>
> fm.list(1, "abc", 4L, 3.33);
>
> Instead I would prefer
> fm.list = (1, "abc", 4L, 3.33);

You can use @property on opDispatch to use setter/getter notation,
however I wouldn't rely on that functionality long-term if you want to
keep the same function-call syntax (since -property flag is supposed
to enforce proper parenthesis use on `@property`s).

> fm.list = (1, "abc", 4L, 3.33);

I'm hoping you mean `fm.list = [1, "abc", 4L, 3.33];` I think that
using the right template parameters, you can use the same code for
(T...)(T el) and (T)(T[]), I just can't remember what that is...

> Another question :
> How do I bring in :
>
> opDispatch(string name, T) (T[] t)

--
James Miller


More information about the Digitalmars-d-learn mailing list