Skip to content

Overhaul spec content - #489

Merged
cburgdorf merged 18 commits into
argotorg:masterfrom
cburgdorf:christoph/docs/spec2
Aug 9, 2021
Merged

Overhaul spec content#489
cburgdorf merged 18 commits into
argotorg:masterfrom
cburgdorf:christoph/docs/spec2

Conversation

@cburgdorf

@cburgdorf cburgdorf commented Jul 27, 2021

Copy link
Copy Markdown
Collaborator

What was wrong?

  • The layout of the syntax definitons is broken e.g:

image

  • lots of broken links
  • the Python indentation rules were not properly reflected in the syntax sections
  • lots of missing content

How was it fixed?

Still an ongoing effort but:

  1. The spec files where all split into individual files (similar to how the Rust reference is organized which makes it easier to maintain the links of each section
  2. I removed the TOC preprocessor that we used for the release notes since it was causing lots of layout issues with the syntax definitons
    image
  3. Changed the syntax sections to properly use NEWLINE, INDENT, DEDENT tokens to describe the syntax
  4. Added a bunch of new content as well as stubs for things that we will need to cover (e.g. all the expressions and statements)

@cburgdorf
cburgdorf force-pushed the christoph/docs/spec2 branch 2 times, most recently from cacea03 to 2adc3e3 Compare July 28, 2021 11:48
@codecov-commenter

codecov-commenter commented Jul 28, 2021

Copy link
Copy Markdown

Codecov Report

Merging #489 (c44317d) into master (7a6d874) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #489   +/-   ##
=======================================
  Coverage   87.69%   87.69%           
=======================================
  Files          80       80           
  Lines        5276     5276           
=======================================
  Hits         4627     4627           
  Misses        649      649           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a6d874...c44317d. Read the comment docs.

@cburgdorf
cburgdorf force-pushed the christoph/docs/spec2 branch 5 times, most recently from 49cc6c5 to dbcd1e8 Compare August 3, 2021 13:37
@cburgdorf cburgdorf changed the title Christoph/docs/spec2 Overhaul spec content Aug 6, 2021
@cburgdorf
cburgdorf force-pushed the christoph/docs/spec2 branch from 041a48a to 47c14fa Compare August 6, 2021 10:23
@cburgdorf
cburgdorf marked this pull request as ready for review August 6, 2021 10:24
@cburgdorf
cburgdorf requested a review from g-r-a-n-t August 6, 2021 10:24
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@g-r-a-n-t This is far from finished but I think it may be good to get the first chunk in before it grows to large.

@g-r-a-n-t

Copy link
Copy Markdown
Collaborator

Looks great. I left a bunch of comments, some of which are suggestions and others are just general thoughts that probably warrant new issues.

6 / 3 == 2 TODO: Rest
5 % 4 == 1
2 ** 4 == 16
12 & 25 == 8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we could use the bin representation for bitwise ops

Comment thread docs/src/spec/contracts.md Outdated
@@ -0,0 +1,3 @@
# Function calls

Constant size values stored on the stack or in memory can be passed into and returned by functions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might be more clear:

All types, except for Map, may be passed into and returned by functions.

Comment thread docs/src/spec/functions.md Outdated
Comment thread docs/src/spec/keywords.md
Comment thread docs/src/spec/string_type.md Outdated
square: Rectangle = Rectangle(width=10, length=10)
```

All fields of struct types are always initialized.

@g-r-a-n-t g-r-a-n-t Aug 6, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All fields of struct types must be initialized.

Comment thread docs/src/spec/struct_types.md Outdated
@@ -0,0 +1,9 @@
# The `to_mem` function

Reference type values can be copied from storage and into memory using the `to_mem` function.

@g-r-a-n-t g-r-a-n-t Aug 6, 2021

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the future, I think there may be somewhat nuanced usage of to_mem() on values in memory.

Example:

pub fn foo(self):
  self.sum(self.my_array)
  self.sum([1, 2, 3]) # this is not copied in `sum`, as `to_mem` operates on it passively

fn sum(some_array: u8[3]):
  let sum: u256 = 0
  for val in some_array.to_mem():
    sum += val

  return sum

So I think we should remove the check requiring that the value be in storage (if it exists). This would of course be a separate issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But why would we even write some_array.to_mem() here? Isn't the assumption that some_array is in memory anyway? Isn't it that we would only need to call to_mem() on something that is self.<something>? Or is this hypothetical code in which some_array may allow readonly storage pointers?

Also we might want to reconsider if to_mem can be merged with clone.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Isn't the assumption that some_array is in memory anyway?

This is the current assumption, as we require that reference type parameters be in memory.

Or is this hypothetical code in which some_array may allow readonly storage pointers?

This is what has been described in #161. to_mem would serve as a function that would guarantee that a readonly value is in memory. If the value is already in memory, then we would leave it alone, as to not incur unnecessary gas costs. If the value is in storage, then we would copy it.

Comment thread docs/src/spec/tuple_types.md Outdated
@g-r-a-n-t

Copy link
Copy Markdown
Collaborator

Also, I'd be happy to rewrite a bunch of stuff in the data layout section after this gets merged.

@cburgdorf
cburgdorf force-pushed the christoph/docs/spec2 branch from 47c14fa to c44317d Compare August 9, 2021 10:16
@cburgdorf
cburgdorf merged commit c8e58b5 into argotorg:master Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants