May 30, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Thursday, 29 May 2014 at 19:06:15 UTC, Steven Schveighoffer
wrote:
>> Static if is certainly NOT an attribute, it doesn't make any sense.
>
> Well... it sorta does. static if does not introduce a new scope, even with {}, and this only happens with attributes.
>
> -Steve
in which case
static if(cond) {
immutable:
}
int x;
should not create x as immutable if cond is true. The current
behavior is not consistent with attribute either.
|
May 30, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Thu, 29 May 2014 20:40:10 +0100, Walter Bright <newshound2@digitalmars.com> wrote: > On 5/29/2014 11:25 AM, Dmitry Olshansky wrote: >> Agreed. The simple dream of automatically decoding UTF and staying "Unicode >> correct" is a failure. > > Yes. Attempting to hide the fact that strings are UTF-8 is just doomed. It's like trying to pretend that floating point does not do rounding. > > It's far more practical to embrace what it is and deal with it. Yes, D programmers will need to understand what UTF-8 is. I don't see any way around that. And it's the right choice. 4 of the 7 billion people in the world today are in Asia and by 2100 80% of the worlds population will be in Asia and Africa. http://bigthink.com/neurobonkers/it-is-not-about-political-views-or-ideologies-it-is-blunt-facts-which-are-not-known R -- Using Opera's revolutionary email client: http://www.opera.com/mail/ |
May 30, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Thu, 29 May 2014 21:15:21 -0400, deadalnix <deadalnix@gmail.com> wrote:
> On Thursday, 29 May 2014 at 19:06:15 UTC, Steven Schveighoffer
> wrote:
>>> Static if is certainly NOT an attribute, it doesn't make any sense.
>>
>> Well... it sorta does. static if does not introduce a new scope, even with {}, and this only happens with attributes.
>>
>> -Steve
>
> in which case
>
> static if(cond) {
> immutable:
> }
>
> int x;
>
> should not create x as immutable if cond is true. The current
> behavior is not consistent with attribute either.
Ugh, that is really bad. It shouldn't do that. Is that intentional?
-Steve
|
May 31, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 05/30/2014 02:37 PM, Steven Schveighoffer wrote:
>>>
>>
>> in which case
>>
>> static if(cond) {
>> immutable:
>> }
>>
>> int x;
>>
>> should not create x as immutable if cond is true. The current
>> behavior is not consistent with attribute either.
>
> Ugh, that is really bad. It shouldn't do that. Is that intentional?
enum cond=true;
static if(cond){
immutable:
}
int x;
static assert(is(typeof(x)==int));
What is the problem?
|
May 31, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 5/30/2014 5:37 AM, Steven Schveighoffer wrote:
> On Thu, 29 May 2014 21:15:21 -0400, deadalnix <deadalnix@gmail.com> wrote:
>
>> On Thursday, 29 May 2014 at 19:06:15 UTC, Steven Schveighoffer
>> wrote:
>>>> Static if is certainly NOT an attribute, it doesn't make any sense.
>>>
>>> Well... it sorta does. static if does not introduce a new scope, even with
>>> {}, and this only happens with attributes.
>>>
>>> -Steve
>>
>> in which case
>>
>> static if(cond) {
>> immutable:
>> }
>>
>> int x;
>>
>> should not create x as immutable if cond is true. The current
>> behavior is not consistent with attribute either.
>
> Ugh, that is really bad. It shouldn't do that. Is that intentional?
Yes. Semantic scope and lexical scope are different things. The ':' thing applies to the remaining statements in the lexical scope. 'static if' does not create a new semantic scope, even though the { } suggests it does.
There have been several suggestions to make 'static if' apply independently of the rest of the grammar, i.e. allow things like:
int static if (cond) * else [ ] foo; // conditionally make foo a pointer or an array
I think we can agree that looks awful, but it is the same thing as suggesting that the 'immutable:' above extend outside of its lexical scope.
You might ask "why is semantic scope different from lexical scope" and the reason is simply that 'static if' would not be very useful if that were the case.
|
June 02, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Sat, 31 May 2014 18:56:17 -0400, Timon Gehr <timon.gehr@gmx.ch> wrote:
> On 05/30/2014 02:37 PM, Steven Schveighoffer wrote:
>>>>
>>>
>>> in which case
>>>
>>> static if(cond) {
>>> immutable:
>>> }
>>>
>>> int x;
>>>
>>> should not create x as immutable if cond is true. The current
>>> behavior is not consistent with attribute either.
>>
>> Ugh, that is really bad. It shouldn't do that. Is that intentional?
>
> enum cond=true;
>
> static if(cond){
> immutable:
> }
>
> int x;
> static assert(is(typeof(x)==int));
>
> What is the problem?
OK, so the original premise is not true? I was assuming deadalnix was saying x would be immutable.
-Steve
|
June 02, 2014 Re: Scott Meyers' DConf 2014 keynote "The Last Thing D Needs" | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Sat, 31 May 2014 19:27:08 -0400, Walter Bright <newshound2@digitalmars.com> wrote: > On 5/30/2014 5:37 AM, Steven Schveighoffer wrote: >> On Thu, 29 May 2014 21:15:21 -0400, deadalnix <deadalnix@gmail.com> wrote: >> >>> On Thursday, 29 May 2014 at 19:06:15 UTC, Steven Schveighoffer >>> wrote: >>>>> Static if is certainly NOT an attribute, it doesn't make any sense. >>>> >>>> Well... it sorta does. static if does not introduce a new scope, even with >>>> {}, and this only happens with attributes. >>>> >>>> -Steve >>> >>> in which case >>> >>> static if(cond) { >>> immutable: >>> } >>> >>> int x; >>> >>> should not create x as immutable if cond is true. The current >>> behavior is not consistent with attribute either. >> >> Ugh, that is really bad. It shouldn't do that. Is that intentional? > > Yes. Semantic scope and lexical scope are different things. The ':' thing applies to the remaining statements in the lexical scope. 'static if' does not create a new semantic scope, even though the { } suggests it does. deadalnix's suggestion, at least to me, was that currently the compiler would attribute immutable to int x. Testing, I see it does not. Maybe I misinterpreted the implication. The statement "current behavior is not consistent with attribute" seems wrong then. > There have been several suggestions to make 'static if' apply independently of the rest of the grammar, i.e. allow things like: > > int static if (cond) * else [ ] foo; // conditionally make foo a pointer or an array > > I think we can agree that looks awful, but it is the same thing as suggesting that the 'immutable:' above extend outside of its lexical scope. I agree, I think we are arguing the same thing. static if seems like an attribute in how it scopes things. -Steve |
Copyright © 1999-2021 by the D Language Foundation