Serpent looks quite similar to Python. What behaviors or syntax would be on your list to warn other Serpent developers about?
Asked
Active
Viewed 455 times
1 Answers
6
While Serpent uses a syntax very similar to Python, there are some important differences to be aware of:
- Python numbers have potentially unlimited size, Serpent numbers wrap around
2^256. For example, in Serpent the expression3^(2^254)surprisingly evaluates to1, even though in reality the actual integer is too large to be recorded in its entirety within the universe.- Serpent has no decimals.
- Serpent has no list comprehensions (expressions like
[x**2 for x in my_list]), dictionaries or most other advanced features- Serpent has no concept of first-class functions. Contracts do have functions, and can call their own functions, but variables (except storage) do not persist across calls.
- Serpent has a concept of persistent storage variables.
- Serpent has an extern statement used to call functions from other contracts.
J-B
- 8,941
- 16
- 46
- 77