Closed dezren39 closed 1 week ago
closing this because the answer of the primary question is 'use type()'
i'm guessing that generating functions is unavailable, other than maybe by codegen a file and then ? import ? or exec it? it would be nice if i could make closures etc.
Oh thanks for finding the crash! Let me make a new issue for that one.
Yes the function is type()
There are no closures right now... It may be possible to introduce an object that you can __call__
like Python
Feedback based on example code is very welcome, thanks!
hi i want to be able to determine what type my typed arg is, how do i do that?
also i can't reference func/proc is there a way to do this? i feel like it might be nice to be able to assign them or pass them directly into functions, and for functions to be able to switch on typeof(x) and switch if command/func/proc they can go eval or if string do something else, etc.
can i make procs/functions dynamically? have a proc/function that takes a proc/function makes a proc/function and returns it? thinking like, currying basically.
proc blocks are cool, i'm curious why there is only one and how i would go about making an array of blocks or assign a block to a variable? sometimes i want to reuse a block i'd pass into a proc, would that be a caret?
i found this worked below, closest i could get, but idk if i could pass in values if i needed to.
^ how do i get "Command" into a variable? i'm less interested in the pointer at least right now, but if i can get the whole thing i can parse it myself
oh and i got ysh to throw with this poor choice of mine
maybe this is related to some of my questions? #691 maybe related too? #1849 and https://oilshell.zulipchat.com/#narrow/stream/384942-language-design/topic/block.20arguments.20as.20third.20.2F.20fourth.20arg.20group