arguments.callee in Racket (Scheme)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


arguments.callee in Racket (Scheme)?



I need the feature arguments.callee of JavaScript in Racket (Scheme). Do you know how?


arguments.callee



Here, an example in JavaScript


function makeFactorialFunc() {
return function(x) {
if (x <= 1)
return 1;
return x * arguments.callee(x - 1);
};
}




1 Answer
1



You cannot get the currently executing function in a dynamic way in Racket, but you can certainly still implement the function in your question in Racket, just by giving the function a name:


(define (make-factorial-func)
(define (func x)
(if (<= x 1)
1
(* x (func (- x 1)))))
func)



It’s possible that you feel like you need the dynamic-ness of arguments.callee for some reason, and it might be possible to achieve that goal through some other mechanism, but seeing as you don’t provide any context for why you think it’s necessary in your question, I can’t guess as to what that other mechanism might be.


arguments.callee






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived