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

Improve documentation #959

Open
5 of 36 tasks
turbolent opened this issue May 28, 2021 · 5 comments
Open
5 of 36 tasks

Improve documentation #959

turbolent opened this issue May 28, 2021 · 5 comments
Labels
Documentation Improvements or additions to documentation Epic Good First Issue Good for newcomers

Comments

@turbolent
Copy link
Member

turbolent commented May 28, 2021

Various topics should be added or improved:

Tasks:

Todos:

  • Reference to optionals, field access + dictionary access
  • "Constant means that the identifier’s association is constant, not the value itself – the value may still be changed if is mutable."
    • Make this a warning
    • Repeat this on the page describing fields
    • On the access control page, add "Remember that if you can access a let dictionary or array you can mutate its contents, this includes when they are pub or access(all) member variables of a contract, resource or struct."
  • Static casting
  • Add an example showing how a function can be passed to a function
  • Storability
  • getAccount and getAuthAccount
  • Debugging: log, debugger, testing
  • IDE, path from Playground
  • Time-based applications
  • unsafeRandom: "unsafe" meaning is two-fold:
    • Prevent accidental misuse
    • Current implementation:
      • Block ID is not a safe source, we should use the random beacon
      • Use of Go's math/rand
        • Doesn't guarantee uniformity
        • Seeded only by 64 bits
        • Not secure, e.g., based on old randoms, next ones can be predicted
  • A glossary and alphabetical index of all concepts (with potential alternative names), keywords, operators, etc.
  • Contract update events
  • Documentation explaining script syntax in similar fashion to the Transaction documentation in Cadence section
  • Clarify that adding a destructor to a resource does not "overwrite"/"replace" the destruction of the resource, it only allows additional code to be performed
  • Conditions are not checked to be side-effect free yet
  • Transactions are atomic. It either succeeds, and all state changes are committed, or it aborts during execution, and none of the changes are committed, even if they had been executed before the abort
  • Destroying nil is a NO-OP. An optional is a single-element container, and if it has no value, there is nothing to do. Just like destroying another container, like an empty array or empty dictionary
  • When loading just to destroy the value, use AnyResource/AnyStruct instead of a specific type, as it may be incorrect, in which case load will return nil
  • Add missing status banners / remove unimplemented features
  • Subtyping for optionals, functions, etc.
  • Point out which functions are unavailable for resources, e.g. Array.contains
  • Paths: Re-iterate and show good + bad example for what “identifier” means
  • Point out that key order is deterministic, but not defined (it is based on the hash of the key)
  • log
  • API documentation for built-in types and standard library types
    • Include type IDs
@turbolent turbolent added the Documentation Improvements or additions to documentation label May 28, 2021
@turbolent turbolent self-assigned this May 28, 2021
@rheaplex
Copy link
Contributor

rheaplex commented Jun 3, 2021

It may be worth explicitly noting that return values are copied.

I have an example for that here:

https://play.onflow.org/5cff15ee-7aaf-497e-af8a-1cf8b3fdc11e?type=tx&id=6018d1ce-e19a-48c8-bd3e-376565c64e22

@rheaplex
Copy link
Contributor

rheaplex commented Jun 3, 2021

And here's an example for the pub const gotcha:

https://play.onflow.org/3ca9083a-4662-48ec-8211-c636ac25e88d?type=account&id=0

@bluesign
Copy link
Contributor

bluesign commented Jun 3, 2021

On the access control page, add "Remember that if you can access a let dictionary or array you can mutate its contents, this includes when they are pub or access(all) member variables of a contract, resource or struct."

@turbolent
Copy link
Member Author

@rheaplex It's documented that it's pass-by-value, but we should make that more prominent / add it as an example / detail, agreed 👍

@turbolent
Copy link
Member Author

@rheaplex also, @bluesign had the great idea to report a warning, I've opened onflow/cadence-tools#429 for that

muttoni added a commit to muttoni/cadence that referenced this issue Nov 26, 2021
I've been going through the Cadence reference documentation and started collating information about all the symbols and operators. While it doesn't completely satisfy the need for a comprehensive glossary mentioned in onflow#959, it can perhaps be a step in that direction and help developers who are learning Cadence to quickly look up the various symbols (something that is hard to do in the documentation Algolia search bar. For example `as?` does not return any useful result).
@j1010001 j1010001 added the P-Low label Jan 18, 2022
@turbolent turbolent mentioned this issue Jun 25, 2022
6 tasks
@j1010001 j1010001 added the Epic label Oct 19, 2022
@turbolent turbolent added the Good First Issue Good for newcomers label Oct 25, 2022
@turbolent turbolent removed their assignment Oct 27, 2022
@j1010001 j1010001 removed the P-Low label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements or additions to documentation Epic Good First Issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants