Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #120355
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: thread about the pros and cons of lambdas, but more about cons |
| Date | 2024-09-26 11:38 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <20240926113837.00003872@yahoo.com> (permalink) |
| References | <20240925195423.00007ecc@yahoo.com> <vd1poc$3q40f$2@dont-email.me> <20240925233008.000063f7@yahoo.com> <vd1ts5$3r06g$1@dont-email.me> <vd35p3$44l4$1@dont-email.me> |
On Thu, 26 Sep 2024 11:25:05 +0300
Paavo Helde <eesnimi@osa.pri.ee> wrote:
> On 26.09.2024 00:04, Paavo Helde wrote:
> > On 25.09.2024 23:30, Michael S wrote:
> >> On Wed, 25 Sep 2024 22:53:47 +0300
> >> Paavo Helde <eesnimi@osa.pri.ee> wrote:
> >>
> >>>
> >>> This is called a strawman argument. You invent an example where
> >>> the lambda does not really suit and is slower than an
> >>> alternative, then attack it.
> >>>
> >>> Solution is simple: use lambdas where they fit.
> >>>
> >>
> >> Can you give me one reason why writing recursive lambdas in C++
> >> can not be streight-forward?
> >> That's how lambda-base recursive code that is 100% equivalent of
> >> above C++ looks in Go. Simpler, isn't it?
> >>
> >> var ff4 func(x, y uintptr)
> >> ff4 = func(x, y uintptr) {
> >> if x >= w || y >= h {
> >> return
> >> }
> >> if img[w*y+x] != target {
> >> return
> >> }
> >> img[w*y+x] = dest
> >> ff4(x-1, y)
> >> ff4(x+1, y)
> >> ff4(x, y-1)
> >> ff4(x, y+1)
> >> }
> >
> > Looks simpler, but not sure it actually is, given that access to
> > the "outer" variables seems to be not encapsulated or controlled in
> > any way. Probably this is an equivalent to a C++ free function with
> > global or thread-local variables, not to a C++ lambda.
> >
> >
> > There are many things in C++ which I do not like and many things
> > which I'm sure could work better. However, my task as a software
> > engineer is to make the best use of the tools which I have got.
> > With C++ this means avoiding use or misuse of very many of its
> > features.
>
> PS. One of things I have learned to avoid in C++ is heavy recursion,
> which is known to be slow (on x86 at least) and can easily cause
> stack overflows. I just tested this simplistic fully recursive
> floodfill4 and both versions run out of stack already with so small
> as 200x200 uniformly filled images, in a VS2022 x86_64 program with
> default settings.
>
When I test it on Windows the stack size is set to 8MB.
That's enough for 200x200.
It seems, on many x86-64 Linuxes 8MB is a default.
> So this solution is totally unacceptable for production code, and all
> talk about its simplicity (or not) is purely academic.
>
It depends.
Sometimes one knows up front that the images are small.
Yet sometimes one knows that in his environment stack is allowed to be
huge.
For example, Go on x86-64 sets default stack limit to 1 GB.
But more often what you said is correct.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-25 19:54 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-25 19:17 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-25 19:55 +0200
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-25 22:53 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-25 23:30 +0300
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 00:04 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 11:17 +0300
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 11:25 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 10:28 +0200
Re: thread about the pros and cons of lambdas, but more about cons Paavo Helde <eesnimi@osa.pri.ee> - 2024-09-26 11:49 +0300
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 11:38 +0300
Re: thread about the pros and cons of lambdas, but more about cons Ben Bacarisse <ben@bsb.me.uk> - 2024-09-25 23:13 +0100
Re: thread about the pros and cons of lambdas, but more about cons Ben Bacarisse <ben@bsb.me.uk> - 2024-09-25 23:28 +0100
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 10:41 +0300
Re: thread about the pros and cons of lambdas, but more about cons David Brown <david.brown@hesbynett.no> - 2024-09-26 10:29 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 11:35 +0200
Re: thread about the pros and cons of lambdas, but more about cons David Brown <david.brown@hesbynett.no> - 2024-09-26 13:27 +0200
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 13:31 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 15:25 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 14:58 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 16:53 +0300
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 15:54 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:55 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:01 -0700
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 19:04 +0200
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 20:20 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:38 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:27 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 04:06 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-26 10:58 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 10:27 -0700
Re: thread about the pros and cons of lambdas, but more about cons Bonita Montero <Bonita.Montero@gmail.com> - 2024-09-26 19:32 +0200
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-26 14:09 -0700
Re: thread about the pros and cons of lambdas, but more about cons Michael S <already5chosen@yahoo.com> - 2024-09-27 16:15 +0300
Re: thread about the pros and cons of lambdas, but more about cons Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 04:25 -0700
csiph-web