Some kind of interesting memory management paradigm. Perhaps ownership-style?
A type system like Haskell's, where you can pass types to functions as if they were normal values. Basically, making types "first-class citizens".
Multiple dispatch. This one is neat, I'd highly suggest it. Basically, in most OO langs you have single dispatch — when I call my_var.some_function, the some_function I'm calling depends on the type of my_var. Well, what if the function depended on the types of all arguments? So, instead of doing:
def my_function(x, y, z):
if type(x) is int and type(y) is str and type(z) is int:
# stuff 1
elif type(x) is str and type(y) is int and type(z) is str:
# stuff 2
# etc etc
I made a 🐍Snake AI 💻
[ currently broken :D ]
Hi!
I made Snake. You can control it using WASD, or the arrow keys. Eat the red apples, and don't crash into the walls or yourself!
But.....
When you press space, it uh... helps you out a little :)
Enjoy!
@DynamicSquid You could add:
my_var.some_function
, thesome_function
I'm calling depends on the type ofmy_var
. Well, what if the function depended on the types of all arguments? So, instead of doing:You do something like:
And obviously, you don't have to give a type — doing
def x(y):
would apply toy
of any type.More info on multiple dispatch can be found here.