-
Notifications
You must be signed in to change notification settings - Fork 1
These examples would be clearer in a namespace #85
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
base: rinderknecht@new_jsligo
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| type storage = int | ||
| module Counter = struct | ||
| type storage_type = int | ||
| type return_type = operation list * storage_type | ||
|
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we doing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually do that to distinguish types from values. Otherwise statements like |
||
|
|
||
| type ret = operation list * storage | ||
| (* Three entrypoints *) | ||
|
|
||
| (* Three entrypoints *) | ||
| [@entry] | ||
| let add (value : int) (store : storage_type) : return_type = | ||
| [], store + value | ||
|
|
||
| [@entry] | ||
| let increment (delta : int) (store : storage) : ret = [], store + delta | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the previous names seems better overall, increment, decrement and delta vs add, sub and value. |
||
|
|
||
| [@entry] | ||
| let decrement (delta : int) (store : storage) : ret = [], store - delta | ||
|
|
||
| [@entry] | ||
| let reset (() : unit) (_ : storage) : ret = [], 0 | ||
| [@entry] | ||
| let sub (value : int) (store : storage_type) : return_type = | ||
| [], store - value | ||
|
|
||
| [@entry] | ||
| let reset (_p : unit) (_s : storage_type) : return_type = | ||
| [], 0 | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| type storage = int; | ||
| type ret = [list<operation>, storage]; | ||
| namespace Counter { | ||
| type storage_type = int; | ||
| type return_type = [list<operation>, storage_type]; | ||
|
|
||
| // Three entrypoints | ||
| // Three entrypoints | ||
|
|
||
| // @entry | ||
| const increment = (delta: int, store: storage): ret => | ||
| [[], store + delta]; | ||
| // @entry | ||
| const add = (value: int, store: storage_type): return_type => | ||
| [[], store + value]; | ||
|
|
||
| // @entry | ||
| const decrement = (delta: int, store: storage): ret => | ||
| [[], store - delta]; | ||
| // @entry | ||
| const sub = (value: int, store: storage_type): return_type => | ||
| [[], store - value]; | ||
|
|
||
| // @entry | ||
| const reset = (_p: unit, _s: storage): ret => [[], 0] | ||
| // @entry | ||
| const reset = (_p: unit, _s: storage_type): return_type => | ||
| [[], 0]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why the module wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the JsLIGO example? I suppose it's not necessary here except that devs probably put most contracts in a module. If you think it's distracting I'll take it out.