Skip to main content

Questions tagged [functions]

For questions about the design or implementation of functions. This could include the syntax of defining and calling functions or implementing function calls at a lower level.

7 votes
1 answer
474 views

What problems do applicative functors solve, as an abstraction relative to monads and arrows?

TL;DR This site is of course particularly interested in the language designer's and implementor's perspective so, following What is an arrow and what powers would it give as a first class concept in a ...
D. Ben Knoble's user avatar
27 votes
3 answers
11k views

Colored vs uncolored functions

I've heard people say "colored" functions (e.g. async functions, or functions marked with throws) are bad because they ...
Zizheng Tai's user avatar
3 votes
1 answer
341 views

Concept Overloading in C++

The meaning of function overloading is that two or more functions can have the same name but different parameters. In C++20, concept has been introduced. I found ...
JimmyHu's user avatar
  • 165
-2 votes
3 answers
281 views

How about support function return itself? [closed]

It seems that no language supports this feature: Define a function that can return the function itself. This function will continue to be called and continue to return itself. For example: ...
Aster's user avatar
  • 3,458
9 votes
2 answers
3k views

How do languages chain higher-order functions while still keeping performance?

How do different programming languages deal with the chaining of higher-order functions (ex. [1,2,3].foldl((a, b) => a+b, 0), ...
apropos's user avatar
  • 1,295
8 votes
7 answers
2k views

Why tag function definition with def, fn, fun, func or function etc?

What makes it hard for compilers/interpreters that we need to tag the function definition with keyword fn/fun/func/function? I can understand that types for numbers: int, int32, float32, float64... ...
Anubhav's user avatar
  • 205
3 votes
0 answers
101 views

Is it more readable to declare the return type of a function on the left side of it's name? [duplicate]

A lot of C-like programming languages (Java, C#, ...) use the following syntax for defining functions: returnType functionName(parameters...) { } Is there a ...
tigrou's user avatar
  • 131
13 votes
0 answers
338 views

Why were OS/360 PL/I procedure calls so expensive?

In Guy Steele’s famous paper Debunking the “expensive procedure call” myth or, procedure call implementations considered harmful or, LAMBDA: The Ultimate GOTO, he describes the poor performance of ...
Alexis King's user avatar
  • 12.7k
13 votes
5 answers
1k views

Prior art on pipelines of function calls

Say I have a loop that looks like this: for i in range(1, 10) { print(i) } Now I want to take the same sequence in reverse, and filter out even numbers. I might ...
Rob N's user avatar
  • 1,175
14 votes
4 answers
4k views

Could function parameters be placed inside names?

While in the shower thinking about my code, my mind went to C#'s type parameters, and I wondered what stops the type param from being placed in the middle of the function name like this: ...
flumperious's user avatar
4 votes
4 answers
758 views

Architecture for overriding "trait" implementations many times in different contexts?

I just asked this question about Rust: Is it possible to create a default trait implementation in Rust, and then override that trait implementation somewhere else? My problem is, in my custom lang, I ...
Lance Pollard's user avatar
9 votes
6 answers
2k views

Do variadic functions need to have a different calling convention to regular functions?

In C, calling a variadic functions are 'special' and not to be treated as regular functions or vice versa. Calling a variadic function through a regular function pointer, or vice-versa invokes ...
CPlus's user avatar
  • 10.5k
4 votes
2 answers
462 views

What are the disadvantages of making methods just functions with a 'this' first parameter?

In Lua, a function is no different from a method, except that a method has this as the first parameter, and calling a method on an object automatically passes the ...
CPlus's user avatar
  • 10.5k
17 votes
1 answer
1k views

How can we define a denotational semantics for recursive functions?

Motivation I want to define a denotational semantics (see here or here) for recursive functions in my language, by representing them as mathematical functions. Background Consider a simple language ...
David Young's user avatar
  • 2,532
7 votes
5 answers
3k views

What are the pros/cons of having multiple ways to print?

In C++, there are two ways of printing something: printf() or cout <<. However, in Python, there's only one way: ...
Redz's user avatar
  • 1,096

15 30 50 per page