What would it take to implement the Uniform Function Call Syntax
for a function's argument which is not the first?
Right now it is possible to do the following:
int someNumber(int a, int b)
{
return a + b;
}
void main()
{
int n1 = 5;
int n2 = n1.someNumber(n1 + 1); // Here the `n1
On Friday, 11 November 2016 at 16:39:26 UTC, Heisenberg wrote:
What would it take to implement the Uniform Function Call
Syntax for a function's argument which is not the first?
Right now it is possible to do the following:
int someNumber(int a, int b)
{
return a + b;
}
void main()
{
On Friday, 11 November 2016 at 17:07:50 UTC, John Colvin wrote:
I'm sure there are loads of corner cases this doesn't cover,
but:
template inPos(uint n, alias f)
{
auto inPos(Args...)(auto ref Args args)
{
return f(args[1 .. n+1], args[0], args[n+1 .. $]);
}
}
import std.st
On Friday, 11 November 2016 at 18:33:09 UTC, Heisenberg wrote:
On Friday, 11 November 2016 at 17:07:50 UTC, John Colvin wrote:
I'm sure there are loads of corner cases this doesn't cover,
but:
template inPos(uint n, alias f)
{
auto inPos(Args...)(auto ref Args args)
{
return f(
On Friday, 11 November 2016 at 21:51:29 UTC, John Colvin wrote:
On Friday, 11 November 2016 at 18:33:09 UTC, Heisenberg wrote:
On Friday, 11 November 2016 at 17:07:50 UTC, John Colvin wrote:
I'm sure there are loads of corner cases this doesn't cover,
but:
template inPos(uint n, alias f)
{
On Friday, November 11, 2016 22:48:24 Heisenberg via Digitalmars-d wrote:
> Isn't the whole point of UFCS implementation in providing better
> re-usability and scalability, helping the encapsulation, making
> the chaining of function calls easier?
The primary benefit of UFCS is so that generic cod
On Friday, 11 November 2016 at 16:39:26 UTC, Heisenberg wrote:
What would it take to implement the Uniform Function Call
Syntax for a function's argument which is not the first?
Right now it is possible to do the following:
int someNumber(int a, int b)
{
return a + b;
}
void main()
{
On Saturday, 12 November 2016 at 06:42:24 UTC, Temtaime wrote:
You are wrong. We can use n1 for the second parameter.
int someNumber(int a, int b)
{
return a + b;
}
int main()
{
int n1 = 5;
return (n1.someNumber = n1); // 10
}
In this specific case, yes - however:
int getR
On Friday, 11 November 2016 at 23:27:30 UTC, Jonathan M Davis
wrote:
Ultimately, the only technical benefit from UFCS is that it
allows you to call a function without caring whether it's a
member function or a free function, which is of great benefit
to generic code and not really much else. Ot