From the D Blog -- GSoC Report: Step
Andrej Mitrovic via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Fri Sep 9 10:48:10 PDT 2016
On 9/9/16, Mike Parker via Digitalmars-d-announce
<digitalmars-d-announce at puremagic.com> wrote:
> Wojciech Szęszoł has contributed a post describing his experience
> working on DStep for this year's GSoC. The post is at [1] and is
> on reddit at [2].
With regards to Sets missing from the language:
-----
struct Set(T)
{
void[0][T] set; // void[0] should not allocate (according to
ancient manuscripts)
alias set this;
void put ( ) ( auto ref T input )
{
this.set[input] = [];
}
}
void main ( )
{
Set!int set;
set.put(1);
set.put(5);
assert(1 in set);
assert(5 in set);
assert(4 !in set);
}
-----
I'm not sure about any special syntax which is expected for languages
which have built-in sets. It would probably be overkill to add syntax
support, but I'm not sure how often people use set literals or not.
More information about the Digitalmars-d-announce
mailing list