DIP 1003 Formal Review
Eugene Wissner via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 16 12:39:59 PDT 2017
On Tuesday, 16 May 2017 at 19:25:25 UTC, Steven Schveighoffer
wrote:
> On 5/16/17 2:48 PM, Eugene Wissner wrote:
>> On Tuesday, 16 May 2017 at 18:34:06 UTC, Steven Schveighoffer
>> wrote:
>>
>> 1) Consistency with functions without contracts.
>
> This only applies to the "naked" version which has ugly }{ in
> it. The other options people are asking about are replacing
> body with a keyword, which I think you agree would be bad for
> consistency?
>
Yeah, I think function or something else is a worse alternative.
Better leave body as is than replace it with another word. I can
name my variables body_ if I need.
>> 2) I wouldn't like to have body optional because: it
>> introduces an
>> additional style guide rule: there will be people who will
>> omit it and
>> people who will say: explicitely is better, always use body.
>
> Currently, body is required. It would still be required. Just
> not a keyword. I'm specifically asking if just removing the
> 'keyword-ness' of it is not doable for some reason.
>
> Note: body is optional for non-contract functions (yes, void
> foo() body { } is valid). I don't see a rash of people
> promoting having body there.
>
I wasn't aware of it. Mea culpa.
>> 3) Syntax highlighting: Editors that work with regex will mark
>> body in
>> all contexts as a keyword.
>
> This is a solved problem. Create a C# file, then write 'get' or
> 'set' somewhere that's not inside a property, and see if it's
> highlighted differently.
>
>> 4) I know body isn't reserved anywhere, I can use it without
>> thinking
>> abot the contexts (good for new comers who may think body is a
>> reserved
>> keyword if it is used as such in some contexts).
>
> I think maybe you misunderstand what I was asking.
>
> -Steve
What I meant If I read a documentation on dlang.org that some
identifier is reserved for some purpose I automatically think it
can't be used as variable name. I don't want to check the list of
reserved keywords every time I doubt. The same I never named my
variables linux or Windows because they are used in version
blocks. I have never tested if I can name my variable linux or
Windows. Don't know if it makes sense.
More information about the Digitalmars-d
mailing list