Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81a5527
commit 11bedbc
Showing
6 changed files
with
82 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ Usage | |
quick_start | ||
language | ||
recipes | ||
questions | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. _questions: | ||
|
||
FAQ | ||
=== | ||
|
||
What is the difference between `Block` and `Func (Function)`? | ||
------------------------------------------------------------- | ||
Similar to high level programming languages, :ref:`functions` get some inputs and return some outputs. | ||
It simply allows using the a code block again and again. | ||
:ref:`blocks` are helpful in managing the application flow. | ||
|
||
Technically, TEAL uses | ||
`scratchspace <https://developer.algorand.org/docs/get-details/dapps/avm/teal/#storing-and-loading-from-scratchspace>`_ | ||
to temporarily store values. Tealish automatically manages scratchspace usage and assigns a slot to each variables. | ||
:ref:`blocks` and :ref:`functions` have different slot spaces. When a function is called, inputs are copied to reserved | ||
slot spaces of the function and outputs are copied to reserved slot spaces of the caller (block, function or program). | ||
|
||
Does Tealish has stateful and stateless mode? | ||
--------------------------------------------- | ||
No, Tealish doesn't have modes. The author is responsible for using appropriate `opcodes <https://developer.algorand.org/docs/get-details/dapps/avm/teal/opcodes/>`_. | ||
|
||
|
||
|
||
Can I use subroutines in Tealish? | ||
--------------------------------- | ||
Yes, :ref:`functions` are subroutines under the hood. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
block main: | ||
int sender = Txn.Sender | ||
pay_to_user() | ||
exit(1) | ||
|
||
func pay_to_user(amount: int): | ||
# Function can use variables defined in the outer blocks. | ||
pay(sender, amount) | ||
return | ||
end | ||
exit(0) | ||
end | ||
|
||
func pay(receiver: bytes, amount: int): | ||
inner_txn: | ||
TypeEnum: Pay | ||
Receiver: receiver | ||
Amount: amount | ||
Fee: 0 | ||
end | ||
return | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
func get_balance(account_idx: int, asset_id: int) int: | ||
int balance | ||
if asset_id == 0: | ||
balance = balance(account_idx) - min_balance(account_idx) | ||
else: | ||
_, balance = asset_holding_get(AssetBalance, account_idx, asset_id) | ||
end | ||
return balance | ||
end | ||
|
||
func checks(): | ||
assert(app_local_get(0, "x") > 7) | ||
assert(app_local_get(0, "y") > 6) | ||
end |