May 28, 2022

On Saturday, 28 May 2022 at 08:18:16 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 28 May 2022 at 06:17:56 UTC, zjh wrote:

>

No ... for me is like dancing with handcuffs.

Never heard that expression, is it Chinese?

>

you don't understand the beauty of (...) and (...,...) etc.

Ok, but I don’t think D will add folding over the comma-operator like C++. Also, you can implement you own fold in D.

Have you looked at Haskell? It has some of that beauty of dancing with handcuffs.

Folding in C++ is a way to escape from the recursive template parameter parsing which is in my opinion one of the most horrific things in C++ there is.

Folding in C++ is perhaps "powerful" but at the same time unreadable.

D doesn't need folding and should use compile time for loops instead which is much more readable.

May 28, 2022

On Saturday, 28 May 2022 at 17:32:04 UTC, IGotD- wrote:

>

Folding in C++ is perhaps "powerful" but at the same time unreadable.

I find it to be quite limited, but also confusing for the reader:

template<typename T, T... ints>
void f(std::integer_sequence<T, ints...> seq){
    std::cout << (ints - ...) << std::endl; // prints 3
    std::cout << (... - ints) << std::endl; // prints -5
    std::cout << (0 - ... - ints) << std::endl; // prints -7
    ((std::cout << ints), ...); // prints 124
}

int main()
{
    f(std::integer_sequence<int,1,2,4>{});
    return 0;
}

May 28, 2022

On Saturday, 28 May 2022 at 18:15:10 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 28 May 2022 at 17:32:04 UTC, IGotD- wrote:

>

Folding in C++ is perhaps "powerful" but at the same time unreadable.

I find it to be quite limited, but also confusing for the reader:

Two nested folds (nested loops):

template<int... as, int... bs>
void f(std::integer_sequence<int, as...> _1,std::integer_sequence<int, bs...> _2) {

    std::cout << ([](auto x){ return ((bs+x) * ...);}(as) + ...) << std::endl;

}


int main()
{
    f(std::integer_sequence<int,1,2,4>{}, std::integer_sequence<int,1,-1>{});
    return 0;
}

How many seconds do you need to understand what goes on?

(Maybe it would be better to just implement Lisp.)

May 28, 2022

On Saturday, 28 May 2022 at 19:30:42 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 28 May 2022 at 18:15:10 UTC, Ola Fosheim Grøstad wrote:

>

On Saturday, 28 May 2022 at 17:32:04 UTC, IGotD- wrote:

>

Folding in C++ is perhaps "powerful" but at the same time unreadable.

I find it to be quite limited, but also confusing for the reader:

Two nested folds (nested loops):

template<int... as, int... bs>
void f(std::integer_sequence<int, as...> _1,std::integer_sequence<int, bs...> _2) {

    std::cout << ([](auto x){ return ((bs+x) * ...);}(as) + ...) << std::endl;

}


int main()
{
    f(std::integer_sequence<int,1,2,4>{}, std::integer_sequence<int,1,-1>{});
    return 0;
}

How many seconds do you need to understand what goes on?

(Maybe it would be better to just implement Lisp.)

Wow, haven't looked at C++ for decades, it has advanced this far? Truely marvelous ;-) a vivid testimony of Greenspun's tenth rule:

Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

(just plug in C++ here :-)

https://en.m.wikipedia.org/wiki/Greenspun%27s_tenth_rule

May 29, 2022

On Saturday, 28 May 2022 at 19:30:42 UTC, Ola Fosheim Grøstad wrote:

>

As long as the implementation is correct, I don't need to understand it. Just give a good function name. After the implementation, I don't care about the implementation.

May 29, 2022

On Sunday, 29 May 2022 at 00:50:45 UTC, zjh wrote:

>

After the implementation, I don't care about the implementation.

Iteration and expansion are orthogonal in nature. They are two ways of thinking.
As a system language, others have it, but you don't. This is not a complete/systematic system language.
They look difficult. but smell good ,and when used to use them,they are cool!

May 29, 2022

On Sunday, 29 May 2022 at 00:56:26 UTC, zjh wrote:

>

Iteration and expansion are orthogonal in nature. They are two ways of thinking.

For simple iteration, one can use ....
It's easy. Not that hard.

May 29, 2022
On Wednesday, 25 May 2022 at 22:30:27 UTC, Walter Bright wrote:
> But if I do, then file a new bugzilla with an example that actually illustrates the problem. It's not like we're going to run out of bugzilla numbers.
>
> I also dislike reopening closed bugzillas by adding more problems to it. Just open a new one.
>
> > Well, sometimes the person who finds the bug is not great at
> making examples, then others provide better ones on the same bug report.
>
> If it's a mess, close it and open a new one that is better.

If this is the chosen way to use bugzilla, there should be some way for people to know that, otherwise they will never do it.
May 29, 2022

On Sunday, 29 May 2022 at 00:56:26 UTC, zjh wrote:

>

As a system language, others have it, but you don't. This is not a complete/systematic system language.
They look difficult. but smell good ,and when used to use them,they are cool!

It is not so much that they look difficult, if you are used to functional programming then it is passable, but most C++ programmers are not used to functional programming.

If you want to have it, then it should work with all sequences, because if you almost never use them then you will simply not remember what they do (which one is left fold, which one is right fold?)

Adding a single functional programming mechanism in a remote corner of the language is just a hack, not a real solution.

May 29, 2022

On Sunday, 29 May 2022 at 09:43:23 UTC, Ola Fosheim Grøstad wrote:

And this is not 'functional' at all, it is just expand an iteration.
It's very simple .I don't like functional programming at all.
But I like ... very much, Because it avoids using for/foreach and frees the productivity!

I generally don't need to remember folding left/right at all. Besides, even if it's complicated, you can find everything by just searching on the web.
This is not corner skill, this is productivity!

11 12 13 14 15 16 17 18 19 20 21
Next ›   Last »