Feature request: Optional, simplified syntax for simple contracts
Aleksandar Ruzicic
aleksandar at ruzicic.info
Mon Jun 17 23:00:46 PDT 2013
Well, that's why I've said we don't have a statement that uses
comma to separate it's part. We have lists (argument list,
initializer list, array literals, etc) and I would keep comma for
separating list items.
In for and foreach we use semi-colons, so I tought that using
semi-colon in in would be more consistent than comma.
But that's just my opinion and if this feature got implemented I
would be happy with commas also. :)
On Tuesday, 18 June 2013 at 05:46:35 UTC, Tyler Jameson Little
wrote:
> Or the comma operator:
>
> int x = (5, 3); // x is 3
>
> Arrays:
>
> int[] x = [3, 5];
>
> Struct initializers:
>
> struct t { int x, y };
> auto z = t(3, 5);
>
> Variable declarations:
>
> int x = 5, y = 3;
>
> I'm not sure which would be more idiomatic though... I'm
> leaning more towards commas though, to keep with the syntax of
> the initializers.
>
> On Tuesday, 18 June 2013 at 05:28:07 UTC, Manu wrote:
>> What about the argument list only 3 characters earlier?
>>
>>
>> On 18 June 2013 15:16, Aleksandar Ruzicic
>> <aleksandar at ruzicic.info> wrote:
>>
>>> On Sunday, 16 June 2013 at 00:19:37 UTC, Manu wrote:
>>>
>>>> Super awesome idea! How about coma separated expressions to
>>>> perform
>>>> multiple asserts?
>>>>
>>>> int func(int i, int j) in(i<5, j<10)
>>>> {
>>>> return i + j;
>>>> }
>>>>
>>>
>>> I find use of comma inside of parentheses of a statement a
>>> bit unusual.
>>> Correct me if I'm wrong but I don't think there is a single
>>> statement in D
>>> that separates it's "parts" with a comma. It's always a
>>> semi-colon.
>>>
>>> So I think it should be:
>>>
>>> int func(int i, int j) in (i < 5; j < 10)
>>> {
>>> return i + j;
>>> }
>>>
>>>
>>> But either comma or a semi-colon used as a separator, this is
>>> a really
>>> nice syntactic sugar!
More information about the Digitalmars-d
mailing list