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

Smart Contract Language: imperative over functional #894

Closed
4 tasks done
bchamagne opened this issue Feb 7, 2023 · 0 comments · Fixed by #895
Closed
4 tasks done

Smart Contract Language: imperative over functional #894

bchamagne opened this issue Feb 7, 2023 · 0 comments · Fixed by #895
Assignees
Labels
Epic Group of issues feature New feature request smart contracts Involve smart contracts

Comments

@bchamagne
Copy link
Member

bchamagne commented Feb 7, 2023

We'd like our smart contract to be less functional.
This is a big feature that introduce an entirely new language version (from 0.0.1 to 1.0.0).

  • Smart Contract Language semantic versioning
  • Mutable bindings
  • Functions are all part of a module
  • For loops

Semantic versioning

  • Version 0.0.1 will be the legacy code (I call it the functional lang)
  • Version 1.0.0 will be the language designed by this issue (I call it the imperative lang)
  • Version 1.x.x will be the evolution of the imperative language
  • Version 2.x.x and others will be when/if we introduce breaking changes

Mutable bindings

Users should be able to create variables and modify them.
Variables will be scoped by block.

name = "Anonymous"

if true do 
  name = "Roger"
end

# here, name == "Roger"
if true do 
  name = "Roger"
  ...
end

# here, name is undefined

For loop

Because we will have mutable bindings, the for loop is the easiest way for user to handle lists.

for item in list do 
  ...
end

Functions are grouped by modules

Instead of having all functions available directly, we will put them in modules.

Map.put(map, key, value)
Map.get(map, key, default)
Contract.set_content(string)
Contract.set_type(string)
Chain.get_first_address(string) 
Chain.get_genesis_address(string)
...
@bchamagne bchamagne added feature New feature request smart contracts Involve smart contracts labels Feb 7, 2023
@bchamagne bchamagne self-assigned this Feb 7, 2023
@samuelmanzanera samuelmanzanera added the Epic Group of issues label Feb 7, 2023
@samuelmanzanera samuelmanzanera linked a pull request Feb 8, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Epic Group of issues feature New feature request smart contracts Involve smart contracts
Projects
Status: Done 🍻
Development

Successfully merging a pull request may close this issue.

2 participants