Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Documentation about array initialization #1661

Merged
merged 6 commits into from
Dec 21, 2021
Merged

Conversation

MikaelMayer
Copy link
Member

This fixes #1660
Array initialization with values was not documented yet.

@MikaelMayer MikaelMayer added the part: documentation Dafny's reference manual, tutorial, and other materials label Dec 20, 2021
@MikaelMayer MikaelMayer self-assigned this Dec 20, 2021
@@ -2409,7 +2409,10 @@ A one-dimensional array of `n` `T` elements is created as follows:
a := new T[n];
```
The initial values of the array elements are arbitrary values of type
`T`.
`T`. They can also be initialized with the array display syntax:
Copy link
Member

@keyboardDrummer keyboardDrummer Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see "array display syntax" defined anywhere in the manual, so I wouldn't introduce this name without defining it.

Consider changing this to They can be initialized using an ordered list of expressions enclosed in square brackets, similar to a sequence display expression. Here is an example:

I based the above on this existing piece from the manual, which reads "A sequence can be formed using a sequence display expression, which is a possibly empty, ordered list of expressions enclosed in square brackets."

@@ -2409,7 +2409,7 @@ A one-dimensional array of `n` `T` elements is created as follows:
a := new T[n];
```
The initial values of the array elements are arbitrary values of type
`T`. They can also be initialized with the array display syntax:
`T`. They can also be initialized using a sequence display expression, as follows:
Copy link
Member

@keyboardDrummer keyboardDrummer Dec 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect, since a sequence display expression also has another forms (seq(3, x => x *2)), and this only has the bracket form.

@@ -2409,7 +2409,7 @@ A one-dimensional array of `n` `T` elements is created as follows:
a := new T[n];
```
The initial values of the array elements are arbitrary values of type
`T`. They can also be initialized using a sequence display expression, as follows:
`T`. They can also be initialized using a sequence display expression delimited by square brackets, as follows:
Copy link
Member

@keyboardDrummer keyboardDrummer Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 'delimited by square brackets' implies that multiple elements are separated by square brackets, like 1 [] 2 [] 3. I'd use the term 'enclosed' here.

Maybe you can reply to the suggestion I made earlier? #1661 (comment) That way I can understand what you didn't like about that.

@@ -2409,7 +2409,7 @@ A one-dimensional array of `n` `T` elements is created as follows:
a := new T[n];
```
The initial values of the array elements are arbitrary values of type
`T`. They can also be initialized using a sequence display expression delimited by square brackets, as follows:
`T`. They can also be initialized using a sequence display expression enclosed in square brackets, as follows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave out the 'also', otherwise it's implying the previous sentence already mentioned a way of initializing the values. Also, "a sequence display expression enclosed in square brackets" to me reads like there's an entire sequence display expression in square brackets, even though such as expression already has square brackets.

I think referring to a sequence display expression is a little confusing, since it's not exactly the same as this, so I'd prefer an explicit description like "an ordered list of expressions enclosed in square brackets". If we want to mention "sequence display expression" then I'd like to indicate it's only similar.

@MikaelMayer MikaelMayer merged commit ce446cb into master Dec 21, 2021
@MikaelMayer MikaelMayer deleted the chore-issue-1660 branch December 21, 2021 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part: documentation Dafny's reference manual, tutorial, and other materials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] Show inline array value initialiser shortcut
2 participants