Why D is not popular enough?
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 3 12:57:13 PDT 2016
On Tuesday, 2 August 2016 at 07:50:29 UTC, ketmar wrote:
> On Monday, 1 August 2016 at 19:33:48 UTC, bitwise wrote:
>> 'scope' keyword, for example, is legal in D syntax, but
>> doesn't actually do anything.
>
> sorry, but you are wrong here. of course, it does HAVE effect.
>
> `void foo (scope delegate () boo)`
>
> this means that compiler should not allocate a closure for
> delegate, as `foo` is promising that it will not store `boo`
> anywhere.
>
> `scope a = new A();`
>
> this does what you think it does, althru it is deprecated in
> favor of `scoped!` template.
I know about these cases, but didn't bother mentioning them, as
they are outliers. Also, they do not make my point any less valid.
The following code compiles without errors(outputs 1):
class Foo{
int val;
this(){ val = 1; }
}
Foo x;
void bar(scope Foo foo) {
x = foo;
}
void main() {
bar(new Foo());
writeln(x.val);
}
'scope' is clearly not functioning as advertised, as is the case
for many aspects of D. Again, users shouldn't have to deal with
this sort of thing. I doubt that anyone outside of would-be D
contributors will continue to use the language beyond the point
where they find a hole like this.
Bit
More information about the Digitalmars-d
mailing list