DMD 0.177 release [Length in slice expressions]
Bill Baxter
dnewsgroup at billbaxter.com
Wed Dec 20 17:59:58 PST 2006
Chris Nicholson-Sauls wrote:
> BCS wrote:
>> Chris Nicholson-Sauls wrote:
> Not really, no. But consider:
>
> # ColdC D
> #
> # result = {@foo, 0, @bar}; result = foo ~ [0] ~ bar;
> # result = {42, @someFunc()}; result = [42] ~ someFunc();
> # result = {@foo, 1, @foo, 2}; result = foo ~ [1] ~ foo ~ [2];
> # result = {3, 6, @myConst, 9}; result = [3, 6] ~ myConst.dup ~ [9];
>
> It becomes part of the literal syntax, which makes things cleaner in
> most elaborate cases. Just something I enjoy over there that I wouldn't
> mind seeing from time to time over here. :)
I think that syntax is a little more attractive than ~ for some cases.
It makes it clearer that you're building a list. We don't say [] ~ 1 ~
2 ~ 3 to make the array [1,2,3], after all. But for that reason
(because it's generalizing array literals) I think it should use []
instead of {}. So
result = [@foo, 0, @bar];
To me that certainly does make it clearer that I'm making a list out of
lists.
The @ as a special symbol just for this kind of bothers me, though. And
how would it work for user-defined types? I guess it could just be
turned into the equivalent opCat calls...
--bb
More information about the Digitalmars-d-announce
mailing list