哪些编程语言支持函数的嵌套定义?
例如:python中的嵌套函数
def FuncAsClass():
x=1 # data members
def setX(val): # setter methods
nonlocal x
x=val
def getX(): #getter
return(x)
def adder(): # arbitrary state-dependent method
total=0
for i in range(x+1):
total+=i
return total
# the interface offered by the class
interface ={"setX":setX, "getX":getX, "sum":adder }
return interface