-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Self-aware environments #3
Comments
Is it really a good idea to have mutable functions?
This I'm inclined to agree with. Though, arguably named functions are to be referenced by name / label. It would be very useful to either have a generic variable which is automatically populated with a reference to the closest closing function or some syntax to assign a local name as in clojure which handles this with an optional name argument in the anonymous function definition which is populated into the scope of the function, not above it. (fn name? [params* ] exprs*)
(fn name? ([params* ] exprs*)+)
This carries the same reservation as above. Why would we want mutability in our functions. Especially in the wrapping methods as they are generally used (in my understanding) to implement "mandatory functionality"
How is this beneficial? The types are essentially irrelevant at run-time as the compiler gurantees correctness.
What is the use case for manually unrolling the stack? What benefit is there? You have access to values which are properly scoped. |
The first and foremost benefit is being able to pass your parent anonymous function as a callback, situations arise where it would be convenient to do this in JS all that time. For example:
Not usually at all to the function the signature belongs to; however, if I have a construct like
Before/after hooks can be so much more than just "mandatory functionality". Let's suppose that I have an event driven library; I export functions named
Now suppose that my
I've considered this quite a bit... it would certainly be useful to have it be a language keyword that references the current function, it would probably more clear than introducing a sigil that does it, too. The reason I was clinging to the '^' was because then you could chain '^''s as a cool way to reference parent closures, BUT it would probably be more clear if it was instead something like That would bring us to the discussion of what the keyword could be... I'll immediately toss out Another reason I'd like to have a 'current closure' keyword is that since functions/blocks are first-class, it would make sense if that class had member functions, no? So without the keyword, how would you access those functions from within the function you're currently defining (assuming its anonymous)? |
I know you're reserved on using the I've always wanted Brick to be as verbose as possible, so I prefer the If we decide that |
Functions will have runtime type annotations associated with them, the way that all objects will have types to check at runtime, which is what permits pattern-matching. You can pattern match a function based on its' types. |
|
How about something like |
Namely, a function should be aware of its context and be able to modify it.
Firstly, a function should have a method by which it can call itself, anonymous fn or otherwise. (it's certainly more clear if the method is the same)
Which would output
Secondly, a function should probably have access to it's :before's and :after's; ie:
This is to simply allow for dynamically adding and removing before and after hooks.
It would also be useful to have a function's type signature available to the function, and maybe even a copy of the arguments it was passed.
It would also be nice to extend the syntax (^^^^^'s!) to let a function get these same attributes of its caller (and therefore its caller's caller, and its caller's caller's caller, etc...)
The text was updated successfully, but these errors were encountered: