shouting 

RECURSIVE IIFE SOLUTION :DDDDD

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 

@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_ why are there parenthesis after @lambda _:_()?

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 

@wallhackio @vaporeon_ does that mean an IIFE decorator implicitly changes a function to None after its definition

re: shouting 

@aescling @vaporeon_ personally what i would do is

def iife(func):
func()
return func

@iife
my_func():
print('my_func')

So that the original function still exists

re: shouting 

@aescling @vaporeon_ what is wrong with having an iife that is a procedure can use again?

re: shouting 

@wallhackio @vaporeon_ the entire point of an IIFE is that you are NOT defining a function meant to be actually reused!

re: shouting 

@aescling @vaporeon_ the python syntax forces a new variable to be added to the current scope, something the javascript IIFEs do not do

there is no need to perfectly replicate javascript IIFE behavior because it is impossible

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.