scalahub / Kiosk

Ergo node frontend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow literals to be directly used in declarations instead of via constants

scalahub opened this issue · comments

case class Constant(name: String, var `type`: DataType.Type, value: String) extends Declaration {

Currently to declare a literal value, for example, the address 4MQyMKvMbnCJG3aJ, we need to declare it in a constant and then refer to it later. That is, we must do:
"constants":[{"name":"myAddress", "value":"4MQyMKvMbnCJG3aJ", "type":"address"}, ...]
"address":{"value":"myAddress"}

We can be a little creative and use the actual address instead of the name myAddress, as in:
"constants":[{"name":"4MQyMKvMbnCJG3aJ", "value":"4MQyMKvMbnCJG3aJ", "type":"address"}, ...]
"address":{"value":"4MQyMKvMbnCJG3aJ"}. However, this is prone to errors and confusion if the actual value changes to a different address, hence this approach is discouraged.

It will be more preferable to allow such literals to be directly defined the first time they are used and avoid having to define an extra constant. To be precise, the above lines should be replaced by a single line as in:

"address":{"literal":"4MQyMKvMbnCJG3aJ"}