re: shouting
@wallhackio What is IIFE?
re: shouting
@vaporeon_ a special javascript syntax that lets you declare and execute a function simultaneously :DDDDD
re: shouting
@wallhackio @vaporeon_ i mean, any language that has lambdas can do that really
re: shouting
@aescling @vaporeon_ how would I do it in python?
re: shouting
@wallhackio @vaporeon_ apparently you cannot because python sucks ass
re: shouting
@wallhackio @vaporeon_ HOWEVER:
@lambda _:_()
def _some_iife():
...
does immediately get applied, somehow. apparently. i have not tested this
re: shouting
@aescling @vaporeon_ what the fuck
re: shouting
@aescling @vaporeon_ why are there parenthesis after @lambda _:_()
?
re: shouting
re: shouting
@aescling @vaporeon_ oh because it's calling _some_iffe
the pattern
my_func = decorator(my_func)
where you replace a function with a the return value of another function, is equivalent to
@decorator
def my_func():
print('my_func')
So we could define an decorator iife
:
def iife(x):
x()
And use it like so:
@iife
def my_func():
print('my_func')
This is fully equivalent to the disgusting evil hack you just shared.
re: shouting
@aescling @vaporeon_ whatever the return value of the decorator is becomes the value of the function you decorated
re: shouting
@wallhackio @vaporeon_ indeed