Serpent looks quite similar to Python. What behaviors or syntax would be on your list to warn other Serpent developers about?
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 expression
3^(2^254)surprisingly evaluates to
1, 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.