Answer the question
In order to leave comments, you need to log in
Keyword "call itself" in programming languages?
I haven't seen a keyword in any programming language that means "call itself". You must always specify your own name explicitly. It is clear that the use of such a word is limited (only self-recursive functions). But still, I think it would be nice.
Maybe someone knows languages with such a feature?
Answer the question
In order to leave comments, you need to log in
Here, in my opinion, there is a different kind of restriction - how can you call something without a name? That is, in a regular recursion, I take my name and a recursion is formed, and you propose to make a special construction that will do the same. It turns out just a complication of syntax without much benefit.
Wirth showed that recursion can be reduced to an iterative scheme, so recursion can be dispensed with.
"call itself" what exactly do you imagine? Code reduction? And what to do with arguments?
I only know that such things can definitely be used in Bash
function testit() {
echo "$1"
[ -n "$1" ] && return;
echo $__FUNCNAME__ "ok"
}
testit
function testit() {
if (arguments.length>1 && arguments[1]<2) {
console.log(arguments[0], arguments[1]);
arguments.callee("offtop", arguments[1]+1);
} else {
console.log("no arguments left");
}
}
testit("test", 1);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question