Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5


devel / comp.lang.c++ / Re: What is visitor pattern?

SubjectAuthor
* What is visitor pattern?wij
+* Re: What is visitor pattern?Öö Tiib
|+- Re: What is visitor pattern?wij
|`* Re: What is visitor pattern?wij
| `* Re: What is visitor pattern?Öö Tiib
|  `- Re: What is visitor pattern?wij
+* Re: What is visitor pattern?Pavel
|+* Re: What is visitor pattern?Öö Tiib
||`* Re: What is visitor pattern?Pavel
|| `* Re: What is visitor pattern?Öö Tiib
||  +* Re: What is visitor pattern?Muttley
||  |`* Re: What is visitor pattern?Öö Tiib
||  | `* Re: What is visitor pattern?Tim Rentsch
||  |  `* Re: What is visitor pattern?Öö Tiib
||  |   `- Re: What is visitor pattern?Tim Rentsch
||  `* Re: What is visitor pattern?Pavel
||   `* Re: What is visitor pattern?Öö Tiib
||    `* Re: What is visitor pattern?Pavel
||     `* Re: What is visitor pattern?Öö Tiib
||      `* Re: What is visitor pattern?Pavel
||       `* Re: What is visitor pattern?Öö Tiib
||        `- Re: What is visitor pattern?Pavel
|`* Re: What is visitor pattern?Bonita Montero
| `* Re: What is visitor pattern?Pavel
|  `* Re: What is visitor pattern?Bonita Montero
|   `* Re: What is visitor pattern?Pavel
|    `* Re: What is visitor pattern?Bonita Montero
|     `* Re: What is visitor pattern?Pavel
|      `* Re: What is visitor pattern?Bonita Montero
|       `* Re: What is visitor pattern?Pavel
|        `* Re: What is visitor pattern?Bonita Montero
|         `* Re: What is visitor pattern?Pavel
|          `* Re: What is visitor pattern?Bonita Montero
|           +* Re: What is visitor pattern?Muttley
|           |`* Re: What is visitor pattern?Bonita Montero
|           | `* Re: What is visitor pattern?Muttley
|           |  +* Re: What is visitor pattern?Bonita Montero
|           |  |`* Re: What is visitor pattern?Muttley
|           |  | +* Re: What is visitor pattern?Bonita Montero
|           |  | |`* Re: What is visitor pattern?Muttley
|           |  | | `- Re: What is visitor pattern?Bonita Montero
|           |  | `- Re: What is visitor pattern?Bonita Montero
|           |  `- Re: What is visitor pattern?Pavel
|           `* Re: What is visitor pattern?Pavel
|            `* Re: What is visitor pattern?Bonita Montero
|             `- Re: What is visitor pattern?Pavel
+* Re: What is visitor pattern?Alf P. Steinbach
|`- Re: What is visitor pattern?Alf P. Steinbach
+* Re: What is visitor pattern?Michael S
|+- Re: What is visitor pattern?Bonita Montero
|+- Re: What is visitor pattern?Öö Tiib
|`- Re: What is visitor pattern?Pavel
`- Re: What is visitor pattern?Bonita Montero

Pages:123
Re: What is visitor pattern?

<58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1172&group=comp.lang.c%2B%2B#1172

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:620a:492:b0:76d:e9c0:9109 with SMTP id 18-20020a05620a049200b0076de9c09109mr272058qkr.7.1692966095381;
Fri, 25 Aug 2023 05:21:35 -0700 (PDT)
X-Received: by 2002:ac8:7d43:0:b0:403:a91d:bfec with SMTP id
h3-20020ac87d43000000b00403a91dbfecmr398319qtb.0.1692966095189; Fri, 25 Aug
2023 05:21:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Fri, 25 Aug 2023 05:21:34 -0700 (PDT)
In-Reply-To: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:3dd9:40c6:70d4:c6a;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:3dd9:40c6:70d4:c6a
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
Subject: Re: What is visitor pattern?
From: already5...@yahoo.com (Michael S)
Injection-Date: Fri, 25 Aug 2023 12:21:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1845
 by: Michael S - Fri, 25 Aug 2023 12:21 UTC

On Sunday, August 20, 2023 at 4:55:56 PM UTC+3, wij wrote:
> I found a C++ example https://refactoring.guru/design-patterns/visitor/cpp/example
> but I still don't understand what it tries to say and the example code don't compile.
> Can anyone explain the visitor pattern or better webpages?
> probably making the example compile may help, thanks in advance.

After trying, with limited success, to follow the discussion between Öö Tiib and Pavel,
I am coming to conclusion that continued ignorance about Visitor Pattern is best both
for my blood pressure and for my programming skills.

Re: What is visitor pattern?

<uca72c$1aur$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1173&group=comp.lang.c%2B%2B#1173

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Fri, 25 Aug 2023 14:33:18 +0200
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <uca72c$1aur$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 25 Aug 2023 12:33:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b587a1518818f1bb298ac3db843a8302";
logging-data="43995"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GlnzYrWNo3rXMCc9Ib2Y6ELbXl1zzhjI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qC+WLZ7G5xXQFFhVoThfBDBsZK4=
In-Reply-To: <58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Fri, 25 Aug 2023 12:33 UTC

Am 25.08.2023 um 14:21 schrieb Michael S:

> After trying, with limited success, to follow the discussion between Öö Tiib and Pavel,
> I am coming to conclusion that continued ignorance about Visitor Pattern is best both
> for my blood pressure and for my programming skills.

I'm not ignore it but I wanted to say that it's easier to implement
it not with a separate base and dervied class for the visitor but
with a function<>-object. That would save a lot of work and you get
the same performance.

Re: What is visitor pattern?

<60a2715e-2d6b-4fc3-93d4-c37ff75f74cen@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1174&group=comp.lang.c%2B%2B#1174

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:b03:b0:64a:15a0:8c97 with SMTP id u3-20020a0562140b0300b0064a15a08c97mr426248qvj.11.1692975160766;
Fri, 25 Aug 2023 07:52:40 -0700 (PDT)
X-Received: by 2002:a05:622a:309:b0:410:8976:562b with SMTP id
q9-20020a05622a030900b004108976562bmr356063qtw.3.1692975160404; Fri, 25 Aug
2023 07:52:40 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Fri, 25 Aug 2023 07:52:40 -0700 (PDT)
In-Reply-To: <XZUFM.137111$PlBb.67508@fx42.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <6df46174-6867-4577-a73d-0fb70d6a25e8n@googlegroups.com>
<9ea1f202-4524-03b8-f003-e11b7fa411e7@removeyourself.dontspam.yahoo>
<c772c32e-d0e0-4199-b173-c64e3535159cn@googlegroups.com> <msVEM.440194$xMqa.182640@fx12.iad>
<942afb61-7d90-4251-87a3-18cf4c68fa03n@googlegroups.com> <G1CFM.897823$GMN3.400773@fx16.iad>
<a0da9e2a-a015-4497-96bc-8f9fbff3957an@googlegroups.com> <XZUFM.137111$PlBb.67508@fx42.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <60a2715e-2d6b-4fc3-93d4-c37ff75f74cen@googlegroups.com>
Subject: Re: What is visitor pattern?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Fri, 25 Aug 2023 14:52:40 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 38001
 by: Öö Tiib - Fri, 25 Aug 2023 14:52 UTC

On Friday, 25 August 2023 at 06:12:09 UTC+3, Pavel wrote:
> Öö Tiib wrote:
> > On Thursday, 24 August 2023 at 08:39:04 UTC+3, Pavel wrote:
> >> Öö Tiib wrote:
> >>> On Tuesday, 22 August 2023 at 05:55:32 UTC+3, Pavel wrote:
> >>>> Öö Tiib wrote:
> >>>>> On Monday, 21 August 2023 at 01:02:21 UTC+3, Pavel wrote:
> >>>>>> Öö Tiib wrote:
> >>>>>>> On Sunday, 20 August 2023 at 21:13:01 UTC+3, Pavel wrote:
> >>>>>>>
> >>>>>>>> 1. Ensure all objects have a common base class (say, it's B)
> >>>>>>>
> >>>>>>> Not needed.
> >>>>>>>
> >>>>>>>> 2. create an abstract class Visitor with an abstract method doOp with an
> >>>>>>>> arg of type [ref to] B.
> >>>>>>>
> >>>>>>> Nope, pile of overloads of doOp one for each type processed.
> >>>>>>
> >>>>>> This would render the pattern useless as has no advantage over adding a
> >>>>>> virtual method to do the op. The rationale of the pattern is to permit
> >>>>>> coding one op in one place.
> >>>>>>
> >>>>> The Visitor class is that "one place"; doing same operation lets say printing
> >>>>> of 50 types in one function results with huge function that is headache
> >>>>> not advantage. Separate functions are testable and maintainable.
> >>>>>
> >>>>>>> Otherwise
> >>>>>>> how you process different types differently?
> >>>>>> I explained this in the problem statement. "Given [a ref to] any such
> >>>>>> object, you are able to
> >>>>>> compute its type and/or call a virtual method".
> >>>>>
> >>>>> IOW you do huge switch typeid ... case static_ cast or have the virtual
> >>>>> method (over what we were "gaining advantage") already there?
> >>>>
> >>>> Even a switch with 30 cases is no worse than 30 methods although switch
> >>>> is not always necessary (try to read the above instead of imagining)..
> >>>>
> >>> Visitor is typically used to search, filter, draw or print whole data object
> >>> hierarchy, convert to JSON to XML or to tree in GUI.
> >> correct
> >>> If whole data hierarchy
> >>> is small then you get 30 cases. Switch case is worse than virtual methods.
> >>
> >> *In general* neither is better or worse.
> >
> > Switch case over type is in general worse than virtual functions. Longer
> > function,
> Longer than what? Definitely the one function is shorter than the sum of
> the length of all the element type hierarchy shims plus concrete visitor
> visit overloads.
>
> > bigger cyclomatic complexity,
> with good code organization, no bigger than absolutely necessary.
>
> > harder to understand, with good code organization, actually, easier (see my point below about
> maintenance.
> > harder to
> > form confidence that it is valid,
> see below in maintenance.
>
> > harder to maintain,
> actually, easier to maintain. For using that GoF / wiki DD
> implementation, non-insignificant amount of scaffolding code has to be
> written. Especially in a complex hierarchy, one can easily forget to
> write that accept shim for a couple of classes where it is needed. E.g.
> if in the hierarchy (or a part thereof) is "(B, C, D) > A" (> meaning
> inheritance), imagine the op shall do same on A and D but different on B
> and C. Isn't it easy to forget to add the accept shim to C (even though
> the actual logic visit(C), at which the programmer is likely to focus,
> is written all right).
>
Can't. You can not leak knowledge of particular operation implemented
by VisitorX that happens to be same for A and D into base visitor. Base
visitor has to have all. Something like:
virtual doOp(A& a) {std::abort();}
virtual doOp(B& b) {std::abort();}
virtual doOp(C& c) {std::abort();}
virtual doOp(D& d) {std::abort();}

It is because different operation implemented by VisitorY may be
same for A and B and different for C and D. You can only leave out
handling of D in derived visitor if D is never processed by that visitor,
so std::abort() suits you.

> > harder to test and
> why?
> > also may need more access to implementation details of all types
> > involved, breaking encapsulation.
> How so? All code is written in the op function that has no access to
> internals.
>
You have example where you need short function and then argue against
whole existence of issues why procedural programming was invented in
fifties, structured programming was invented in sixties, object-oriented
programming and double dispatch were invented in seventies. The issues
are still real in real projects, and ignoring these is called code smell.
I can not be expected to teach all that knowledge of decades in one post.
Lets take step by step?

> >
> >> In particular, as I explained
> >> at the beginning, if the operation is decomposed correctly, its behavior
> >> on the objects of different types has to be coherent, similar in some
> >> way (and maybe more similar than different) and, as such, a significant
> >> parts of the context or results of intermediate computations could be
> >> shared.
> >
> > Translating data hierarchy to xml for particular version of particular
> > protocol while supporting several such in parallel?
>
> Imagine {ABCD) type hierarchy above is to be translated to XML and B and
> C have to become XML elements with some non-trivially computable
> attribute atr1 but XML elements produced from A and D don't need it.
>
Because different endpoints (for what you form the XML) want different
data, one wants like you describe ... other does not want atr1 for A and B
.... while third does not want information about D to be ever sent to it.
Now you have 3 different visitors making XML for each endpoint and any
logic in base visitor about first hurts other two.

> > There can be
> > intermediate computations shared but all are typically in in visitor
> > classes or helpers of those. No one wants the classes in hierarchy
> > to know anything about xml whatsoever,
> correct but do not see how it is connected to anything I wrote
> > nothing to talk about
> > particular brand used in particular version of kinds of end-points.
> let's not argue with anything I did not say, it's really irritating, I
> will gladly give you an example, just explain why {ABCD} above is no good..
>
I tried to.

> >
> >> I demonstrated this in my example with red and green borders: a)
> >> a condition by area prevents visitor from operating on objects is
> >> computed from their property that is orthogonal to their dynamic type;
> >> and b) the exact behavior of the operation (red vs green border in the
> >> example) depends on a subset of types (which, in general, is not
> >> necessarily compact in the hierarchy).
> >>
> > Your example did not need visitor pattern.
>
> No example "needs" visitor pattern: any problem solved with visitor can
> be solved in other ways, e.g. just by adding a virtual method to every
> class. But *both* my examples could be perfectly solved with visitor. If
> the one-time scaffolding is in place, I am ready to argue it is a good
> solution.
>
True about adding virtual method, just that adding 3 virtual functions for XML
generation code into every class will clutter code of those classes.
Especially if you want (some of) same classes to be used in other project
that does not communicate with said end-points at all.

> >
> >>> Think why virtual methods were added? To get rid of switch cases over type.
> >> Of course, not. Virtual methods were *used*, with less or greater
> >> success, to replace switch statements in event-processing scenarios
> >> (like window behavior) (with greater success) or in state machines (with
> >> lesser success).
> >>
> >> But, they were *invented* to implement polymorphic behavior and
> >> relatively loose coupling (generally, lesser dependencies) between the
> >> code that calls the method and the code that implements the method.
> >>
> > Same loose coupling is with code that calls function that does switch
> > case over type, so that kind of victory wasn't achieved.
>
> There is no such thing as "coupling in general".


Click here to read the complete article
Re: What is visitor pattern?

<1630c8a7-60a0-4f3e-a8d6-30d75965c004n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1175&group=comp.lang.c%2B%2B#1175

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:ad4:4a6c:0:b0:649:114f:8379 with SMTP id cn12-20020ad44a6c000000b00649114f8379mr418263qvb.7.1692977301554;
Fri, 25 Aug 2023 08:28:21 -0700 (PDT)
X-Received: by 2002:a05:622a:1b8d:b0:3f6:b052:3431 with SMTP id
bp13-20020a05622a1b8d00b003f6b0523431mr416169qtb.5.1692977301353; Fri, 25 Aug
2023 08:28:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Fri, 25 Aug 2023 08:28:21 -0700 (PDT)
In-Reply-To: <58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com> <58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1630c8a7-60a0-4f3e-a8d6-30d75965c004n@googlegroups.com>
Subject: Re: What is visitor pattern?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Fri, 25 Aug 2023 15:28:21 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2381
 by: Öö Tiib - Fri, 25 Aug 2023 15:28 UTC

On Friday, 25 August 2023 at 15:21:43 UTC+3, Michael S wrote:
> On Sunday, August 20, 2023 at 4:55:56 PM UTC+3, wij wrote:
> > I found a C++ example https://refactoring.guru/design-patterns/visitor/cpp/example
> > but I still don't understand what it tries to say and the example code don't compile.
> > Can anyone explain the visitor pattern or better webpages?
> > probably making the example compile may help, thanks in advance.
>
> After trying, with limited success, to follow the discussion between Öö Tiib and Pavel,
> I am coming to conclusion that continued ignorance about Visitor Pattern is best both
> for my blood pressure and for my programming skills.
>
Brilliant decision. Over the decades I have couple times seen visitor misused in
manner that turned the part of code base very hard to maintain. Team members
changed 2 story-point estimation into 20 each time someone realised "but hey,
then we need to change logic in ####Visitor." It had defective dispatch and then
it needed maintenance that made it to grow into kind of cancer no one dared to
touch.

Re: What is visitor pattern?

<nBfGM.634172$TCKc.364728@fx13.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1181&group=comp.lang.c%2B%2B#1181

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx13.iad.POSTED!not-for-mail
Subject: Re: What is visitor pattern?
Newsgroups: comp.lang.c++
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad>
<6df46174-6867-4577-a73d-0fb70d6a25e8n@googlegroups.com>
<9ea1f202-4524-03b8-f003-e11b7fa411e7@removeyourself.dontspam.yahoo>
<c772c32e-d0e0-4199-b173-c64e3535159cn@googlegroups.com>
<msVEM.440194$xMqa.182640@fx12.iad>
<942afb61-7d90-4251-87a3-18cf4c68fa03n@googlegroups.com>
<G1CFM.897823$GMN3.400773@fx16.iad>
<a0da9e2a-a015-4497-96bc-8f9fbff3957an@googlegroups.com>
<XZUFM.137111$PlBb.67508@fx42.iad>
<60a2715e-2d6b-4fc3-93d4-c37ff75f74cen@googlegroups.com>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <60a2715e-2d6b-4fc3-93d4-c37ff75f74cen@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 782
Message-ID: <nBfGM.634172$TCKc.364728@fx13.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 26 Aug 2023 04:55:47 UTC
Date: Sat, 26 Aug 2023 00:55:40 -0400
X-Received-Bytes: 39748
 by: Pavel - Sat, 26 Aug 2023 04:55 UTC

Öö Tiib wrote:
> On Friday, 25 August 2023 at 06:12:09 UTC+3, Pavel wrote:
>> Öö Tiib wrote:
>>> On Thursday, 24 August 2023 at 08:39:04 UTC+3, Pavel wrote:
>>>> Öö Tiib wrote:
>>>>> On Tuesday, 22 August 2023 at 05:55:32 UTC+3, Pavel wrote:
>>>>>> Öö Tiib wrote:
>>>>>>> On Monday, 21 August 2023 at 01:02:21 UTC+3, Pavel wrote:
>>>>>>>> Öö Tiib wrote:
>>>>>>>>> On Sunday, 20 August 2023 at 21:13:01 UTC+3, Pavel wrote:
>>>>>>>>>
>>>>>>>>>> 1. Ensure all objects have a common base class (say, it's B)
>>>>>>>>>
>>>>>>>>> Not needed.
>>>>>>>>>
>>>>>>>>>> 2. create an abstract class Visitor with an abstract method doOp with an
>>>>>>>>>> arg of type [ref to] B.
>>>>>>>>>
>>>>>>>>> Nope, pile of overloads of doOp one for each type processed.
>>>>>>>>
>>>>>>>> This would render the pattern useless as has no advantage over adding a
>>>>>>>> virtual method to do the op. The rationale of the pattern is to permit
>>>>>>>> coding one op in one place.
>>>>>>>>
>>>>>>> The Visitor class is that "one place"; doing same operation lets say printing
>>>>>>> of 50 types in one function results with huge function that is headache
>>>>>>> not advantage. Separate functions are testable and maintainable.
>>>>>>>
>>>>>>>>> Otherwise
>>>>>>>>> how you process different types differently?
>>>>>>>> I explained this in the problem statement. "Given [a ref to] any such
>>>>>>>> object, you are able to
>>>>>>>> compute its type and/or call a virtual method".
>>>>>>>
>>>>>>> IOW you do huge switch typeid ... case static_ cast or have the virtual
>>>>>>> method (over what we were "gaining advantage") already there?
>>>>>>
>>>>>> Even a switch with 30 cases is no worse than 30 methods although switch
>>>>>> is not always necessary (try to read the above instead of imagining).
>>>>>>
>>>>> Visitor is typically used to search, filter, draw or print whole data object
>>>>> hierarchy, convert to JSON to XML or to tree in GUI.
>>>> correct
>>>>> If whole data hierarchy
>>>>> is small then you get 30 cases. Switch case is worse than virtual methods.
>>>>
>>>> *In general* neither is better or worse.
>>>
>>> Switch case over type is in general worse than virtual functions. Longer
>>> function,
>> Longer than what? Definitely the one function is shorter than the sum of
>> the length of all the element type hierarchy shims plus concrete visitor
>> visit overloads.
>>
>>> bigger cyclomatic complexity,
>> with good code organization, no bigger than absolutely necessary.
>>
>>> harder to understand, with good code organization, actually, easier (see my point below about
>> maintenance.
>>> harder to
>>> form confidence that it is valid,
>> see below in maintenance.
>>
>>> harder to maintain,
>> actually, easier to maintain. For using that GoF / wiki DD
>> implementation, non-insignificant amount of scaffolding code has to be
>> written. Especially in a complex hierarchy, one can easily forget to
>> write that accept shim for a couple of classes where it is needed. E.g.
>> if in the hierarchy (or a part thereof) is "(B, C, D) > A" (> meaning
>> inheritance), imagine the op shall do same on A and D but different on B
>> and C. Isn't it easy to forget to add the accept shim to C (even though
>> the actual logic visit(C), at which the programmer is likely to focus,
>> is written all right).
>>
> Can't.
??? You forgot to add accept function to C. Then your object of dynamic
type C will be happily dispatched to VisitorX::visitElementA by A::accept.

You can not leak knowledge of particular operation implemented
> by VisitorX that happens to be same for A and D into base visitor. Base
> visitor has to have all. Something like:
> virtual doOp(A& a) {std::abort();}
> virtual doOp(B& b) {std::abort();}
> virtual doOp(C& c) {std::abort();}
> virtual doOp(D& d) {std::abort();}
>
> It is because different operation implemented by VisitorY may be
> same for A and B and different for C and D. You can only leave out
> handling of D in derived visitor if D is never processed by that visitor,
> so std::abort() suits you.
what do argue against?

>
>>> harder to test and
>> why?
>>> also may need more access to implementation details of all types
>>> involved, breaking encapsulation.
>> How so? All code is written in the op function that has no access to
>> internals.
>>
> You have example where you need short function and then argue against
> whole existence of issues why procedural programming was invented in
> fifties, structured programming was invented in sixties, object-oriented
> programming and double dispatch were invented in seventies. The issues
> are still real in real projects, and ignoring these is called code smell.
> I can not be expected to teach all that knowledge of decades in one post.
> Lets take step by step?
You are still to provide an example. For now, there nothing to take
apart step by step except for my code that you are not even trying to
take apart.

>
>>>
>>>> In particular, as I explained
>>>> at the beginning, if the operation is decomposed correctly, its behavior
>>>> on the objects of different types has to be coherent, similar in some
>>>> way (and maybe more similar than different) and, as such, a significant
>>>> parts of the context or results of intermediate computations could be
>>>> shared.
>>>
>>> Translating data hierarchy to xml for particular version of particular
>>> protocol while supporting several such in parallel?
>>
>> Imagine {ABCD) type hierarchy above is to be translated to XML and B and
>> C have to become XML elements with some non-trivially computable
>> attribute atr1 but XML elements produced from A and D don't need it.
>>
> Because different endpoints (for what you form the XML) want different
> data, one wants like you describe ... other does not want atr1 for A and B
> ... while third does not want information about D to be ever sent to it.
> Now you have 3 different visitors making XML for each endpoint and any
> logic in base visitor about first hurts other two.
What does your "Because" refer to? There is no "why" in my text (and no
question mark at all). I thought you disliked walls of words? What are
"endpoints"? I do not understand what "make XML for an endpoint" means.
I likely format XML to whatever output stream the visitor caller
provides. If that stream is an endpoint, what significance it has to
this discussion?

>
>>> There can be
>>> intermediate computations shared but all are typically in in visitor
>>> classes or helpers of those. No one wants the classes in hierarchy
>>> to know anything about xml whatsoever,
>> correct but do not see how it is connected to anything I wrote
>>> nothing to talk about
>>> particular brand used in particular version of kinds of end-points.
>> let's not argue with anything I did not say, it's really irritating, I
>> will gladly give you an example, just explain why {ABCD} above is no good.
>>
> I tried to.
No, your words above do not refer to my argument even grammatically.

>
>>>
>>>> I demonstrated this in my example with red and green borders: a)
>>>> a condition by area prevents visitor from operating on objects is
>>>> computed from their property that is orthogonal to their dynamic type;
>>>> and b) the exact behavior of the operation (red vs green border in the
>>>> example) depends on a subset of types (which, in general, is not
>>>> necessarily compact in the hierarchy).
>>>>
>>> Your example did not need visitor pattern.
>>
>> No example "needs" visitor pattern: any problem solved with visitor can
>> be solved in other ways, e.g. just by adding a virtual method to every
>> class. But *both* my examples could be perfectly solved with visitor. If
>> the one-time scaffolding is in place, I am ready to argue it is a good
>> solution.
>>
> True about adding virtual method, just that adding 3 virtual functions for XML
> generation code into every class will clutter code of those classes.
You are essentially repeating arguments for Visitor from
advantage/drawback statements on my first post. What purpose is this
repetition supposed to serve in this discussion?


Click here to read the complete article
Re: What is visitor pattern?

<2KfGM.827216$TPw2.761320@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1182&group=comp.lang.c%2B%2B#1182

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
Subject: Re: What is visitor pattern?
Newsgroups: comp.lang.c++
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <uc9696$3rp9i$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 14
Message-ID: <2KfGM.827216$TPw2.761320@fx17.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 26 Aug 2023 05:05:02 UTC
Date: Sat, 26 Aug 2023 01:05:02 -0400
X-Received-Bytes: 1839
 by: Pavel - Sat, 26 Aug 2023 05:05 UTC

Bonita Montero wrote:
> Am 25.08.2023 um 02:02 schrieb Pavel:
>
>> Are you saying that, for whatever cause (like making Visitor more
>> IoC-ish) you are willing to drastically narrow the class of problems
>> that the pattern commonly-known as Visitor is believed to solve?
>
> I suggested a way to make the vistitor pattern implementable with much
> less code and more maintainable. The visitor neither need an addtional
> base-class and implementation class.
Visitor does not need anything, it simply solves a particular class of
problems that happens to include a structure of objects of multiple
types. Your visitor implementation is invalid if it cannot solve a valid
visitor problem.

Re: What is visitor pattern?

<RVfGM.95673$VzFf.50379@fx03.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1183&group=comp.lang.c%2B%2B#1183

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx03.iad.POSTED!not-for-mail
Subject: Re: What is visitor pattern?
Newsgroups: comp.lang.c++
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <58893c96-4e95-494f-abc3-3fd6db7b6846n@googlegroups.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 14
Message-ID: <RVfGM.95673$VzFf.50379@fx03.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Sat, 26 Aug 2023 05:17:37 UTC
Date: Sat, 26 Aug 2023 01:17:37 -0400
X-Received-Bytes: 1507
 by: Pavel - Sat, 26 Aug 2023 05:17 UTC

Michael S wrote:
> On Sunday, August 20, 2023 at 4:55:56 PM UTC+3, wij wrote:
>> I found a C++ example https://refactoring.guru/design-patterns/visitor/cpp/example
>> but I still don't understand what it tries to say and the example code don't compile.
>> Can anyone explain the visitor pattern or better webpages?
>> probably making the example compile may help, thanks in advance.
>
> After trying, with limited success, to follow the discussion between Öö Tiib and Pavel,
> I am coming to conclusion that continued ignorance about Visitor Pattern is best both
> for my blood pressure and for my programming skills.
>
You are right, no good deed goes unpunished. I should have known better.

-Pavel

Re: What is visitor pattern?

<ucc9bg$g167$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1184&group=comp.lang.c%2B%2B#1184

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 09:24:35 +0200
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <ucc9bg$g167$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 07:24:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="525511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vR3jp8fF12AKCWnqhcF7QintwHLfc7w0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:FTVyHFVJDladTfCbJcTi+hPSDCg=
Content-Language: de-DE
In-Reply-To: <2KfGM.827216$TPw2.761320@fx17.iad>
 by: Bonita Montero - Sat, 26 Aug 2023 07:24 UTC

Am 26.08.2023 um 07:05 schrieb Pavel:

> Visitor does not need anything, it simply solves a particular class
> of problems that happens to include a structure of objects of multiple
> types. Your visitor implementation is invalid if it cannot solve a valid
> visitor problem.

Either I didn't describe the difference to what you imagine correctly
or you just didn't understand me. In the Visitor pattern, the Visitor
needs a base class with a virtual method to derive from, and the derived
object is passed by reference to the Visitor function of the objects
being visited. However, the derived and the base class are superfluous
with functional programming. Since C++11 you can simply request a
function<> object and conveniently you just pass a lambda that when
called, a temporary function<> object is created that represents the
interface to the object that can be visited.

Re: What is visitor pattern?

<uccbgu$gd6k$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1185&group=comp.lang.c%2B%2B#1185

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 08:01:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <uccbgu$gd6k$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad>
<ucc9bg$g167$1@dont-email.me>
Injection-Date: Sat, 26 Aug 2023 08:01:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="25753f8c3f5124524da61367343eaf6b";
logging-data="537812"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hGkg+Yuxo/9mPXXeCPH7L"
Cancel-Lock: sha1:bqnZrVJ71WfWXPh72zXVaRvG/Ps=
 by: Mutt...@dastardlyhq.com - Sat, 26 Aug 2023 08:01 UTC

On Sat, 26 Aug 2023 09:24:35 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 26.08.2023 um 07:05 schrieb Pavel:
>
>> Visitor does not need anything, it simply solves a particular class
>> of problems that happens to include a structure of objects of multiple
>> types. Your visitor implementation is invalid if it cannot solve a valid
>> visitor problem.
>
>Either I didn't describe the difference to what you imagine correctly
>or you just didn't understand me. In the Visitor pattern, the Visitor
>needs a base class with a virtual method to derive from, and the derived
>object is passed by reference to the Visitor function of the objects
>being visited. However, the derived and the base class are superfluous
>with functional programming. Since C++11 you can simply request a
>function<> object and conveniently you just pass a lambda that when
>called, a temporary function<> object is created that represents the
>interface to the object that can be visited.

This sort of programming is the equivalent of touchscreens in cars - looks
great and impresses the "Ooo shiny!" crowd but adds little to the main
functionality of the car and just adds needless complexity with more scope for
failure.

Re: What is visitor pattern?

<uccglr$h6lp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1189&group=comp.lang.c%2B%2B#1189

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 11:29:34 +0200
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uccglr$h6lp$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 09:29:31 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="563897"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Q5XxtT3j/2NOsgCfBQ0/Yu/omb0GK8LU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:3TdhTqx/qS1dyqSMrWwgl1Svu8I=
In-Reply-To: <uccbgu$gd6k$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 26 Aug 2023 09:29 UTC

Am 26.08.2023 um 10:01 schrieb Muttley@dastardlyhq.com:

> This sort of programming is the equivalent of touchscreens in cars - looks
> great and impresses the "Ooo shiny!" crowd but adds little to the main
> functionality of the car and just adds needless complexity with more scope
> for failure.

My solution is less complexity because you don't need to declare
a base class and a derived class. Just declare the parameter as
a function object and pass a lambda which is automatically crated.
That's for sure at maximally the tenth of the code.
You can have functional programming in C++ since 2011. That's a
long time you didn't notice its potential.

Re: What is visitor pattern?

<ucd42s$kc9j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1198&group=comp.lang.c%2B%2B#1198

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 15:00:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ucd42s$kc9j$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me>
<uccglr$h6lp$1@dont-email.me>
Injection-Date: Sat, 26 Aug 2023 15:00:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="25753f8c3f5124524da61367343eaf6b";
logging-data="667955"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EEAfboe5njtph/KUudWD9"
Cancel-Lock: sha1:mqUCLf71PdhBOXB3woKRD/XLQjo=
 by: Mutt...@dastardlyhq.com - Sat, 26 Aug 2023 15:00 UTC

On Sat, 26 Aug 2023 11:29:34 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 26.08.2023 um 10:01 schrieb Muttley@dastardlyhq.com:
>
>> This sort of programming is the equivalent of touchscreens in cars - looks
>> great and impresses the "Ooo shiny!" crowd but adds little to the main
>> functionality of the car and just adds needless complexity with more scope
>> for failure.
>
>My solution is less complexity because you don't need to declare
>a base class and a derived class. Just declare the parameter as
>a function object and pass a lambda which is automatically crated.
>That's for sure at maximally the tenth of the code.
>You can have functional programming in C++ since 2011. That's a
>long time you didn't notice its potential.

People who say you can have functional programming in C++ don't understand
functional programming. Its more than just no cost recursion , its also
polymorphism by *VALUE*. That is not and probably never will be possible in
C++.

Re: What is visitor pattern?

<ucd4gs$ke1h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1199&group=comp.lang.c%2B%2B#1199

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 17:08:15 +0200
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <ucd4gs$ke1h$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 15:08:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="669745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183O07IJIAeoKgE/xKFUOhwuQTz8LpilXU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:sSSfQKxxSjgoKT2aR463oj2rpCo=
Content-Language: de-DE
In-Reply-To: <ucd42s$kc9j$1@dont-email.me>
 by: Bonita Montero - Sat, 26 Aug 2023 15:08 UTC

Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:

> People who say you can have functional programming in C++ don't understand
> functional programming. Its more than just no cost recursion , its also
> polymorphism by *VALUE*. ...

That's what I described and you didn't notice it. A function<>-object
is always polymorphic. I bet you never used function<>-objects in C++.

Re: What is visitor pattern?

<ucd4ug$khfd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1200&group=comp.lang.c%2B%2B#1200

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 15:15:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <ucd4ug$khfd$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me>
<ucd4gs$ke1h$1@dont-email.me>
Injection-Date: Sat, 26 Aug 2023 15:15:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="25753f8c3f5124524da61367343eaf6b";
logging-data="673261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JxiCEJ0wGyKLROLDn99ez"
Cancel-Lock: sha1:yoc4RjcydslPLW6P4FRPLbvCkQw=
 by: Mutt...@dastardlyhq.com - Sat, 26 Aug 2023 15:15 UTC

On Sat, 26 Aug 2023 17:08:15 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:
>
>> People who say you can have functional programming in C++ don't understand
>> functional programming. Its more than just no cost recursion , its also
>> polymorphism by *VALUE*. ...
>
>That's what I described and you didn't notice it. A function<>-object
>is always polymorphic. I bet you never used function<>-objects in C++.

Given they're necessary for the STL what do you think?

Which part of "by value" is confusing you? But if you insist on claiming its
possible show us how you'd do polymorphism for a function with a single int
param for say the values 0, 2, 3, 10 -> 100 and a default.

Re: What is visitor pattern?

<ucd5ee$kjhn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1201&group=comp.lang.c%2B%2B#1201

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 17:24:00 +0200
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ucd5ee$kjhn$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me> <ucd4gs$ke1h$1@dont-email.me>
<ucd4ug$khfd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 15:23:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="675383"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+InyKbOYeisaN3ohqnWR+UF9XnavSq1IU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:EENd8yE7s+zrsrV7rKDjBU/bKcY=
Content-Language: de-DE
In-Reply-To: <ucd4ug$khfd$1@dont-email.me>
 by: Bonita Montero - Sat, 26 Aug 2023 15:24 UTC

Am 26.08.2023 um 17:15 schrieb Muttley@dastardlyhq.com:
> On Sat, 26 Aug 2023 17:08:15 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:
>>
>>> People who say you can have functional programming in C++ don't understand
>>> functional programming. Its more than just no cost recursion , its also
>>> polymorphism by *VALUE*. ...
>>
>> That's what I described and you didn't notice it. A function<>-object
>> is always polymorphic. I bet you never used function<>-objects in C++.
>
> Given they're necessary for the STL what do you think?
>
> Which part of "by value" is confusing you? But if you insist on claiming its
> possible show us how you'd do polymorphism for a function with a single int
> param for say the values 0, 2, 3, 10 -> 100 and a default.

You can't describe what you want and you don't understand function<>
-objects. Stick with C.

Re: What is visitor pattern?

<ucd5k0$kkll$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1202&group=comp.lang.c%2B%2B#1202

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 17:26:59 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <ucd5k0$kkll$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me> <ucd4gs$ke1h$1@dont-email.me>
<ucd4ug$khfd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 15:26:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="676533"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pzYttB7AR88Dmc/5GtUptV9tcNAgHTN4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:MNfLNg1AdzPW4wBzYgBXkQg8K8I=
Content-Language: de-DE
In-Reply-To: <ucd4ug$khfd$1@dont-email.me>
 by: Bonita Montero - Sat, 26 Aug 2023 15:26 UTC

Am 26.08.2023 um 17:15 schrieb Muttley@dastardlyhq.com:
> On Sat, 26 Aug 2023 17:08:15 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:
>>
>>> People who say you can have functional programming in C++ don't understand
>>> functional programming. Its more than just no cost recursion , its also
>>> polymorphism by *VALUE*. ...
>>
>> That's what I described and you didn't notice it. A function<>-object
>> is always polymorphic. I bet you never used function<>-objects in C++.
>
> Given they're necessary for the STL what do you think?
>
> Which part of "by value" is confusing you? But if you insist on claiming its
> possible show us how you'd do polymorphism for a function with a single int
> param for say the values 0, 2, 3, 10 -> 100 and a default.
>

Somehow you are also quite disturbed. I wanted to tell nru that the
visitor pattern in C++ can be greatly simplified with a c++11 function<>
object and you are offended by this mere statement that you have to
explain the possibilities of C++11 as insufficient at this point to
put you above me. The therapist that matches you has yet to be born.

Re: What is visitor pattern?

<ucd665$ko3j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1203&group=comp.lang.c%2B%2B#1203

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mutt...@dastardlyhq.com
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 15:36:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <ucd665$ko3j$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me> <ucd4gs$ke1h$1@dont-email.me>
<ucd4ug$khfd$1@dont-email.me>
<ucd5ee$kjhn$1@dont-email.me>
Injection-Date: Sat, 26 Aug 2023 15:36:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="25753f8c3f5124524da61367343eaf6b";
logging-data="680051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19j/EW6OAISX2zStaLJeEY8"
Cancel-Lock: sha1:Fuosqy9TF1XvP0YL6TVSrudHp+w=
 by: Mutt...@dastardlyhq.com - Sat, 26 Aug 2023 15:36 UTC

On Sat, 26 Aug 2023 17:24:00 +0200
Bonita Montero <Bonita.Montero@gmail.com> wrote:
>Am 26.08.2023 um 17:15 schrieb Muttley@dastardlyhq.com:
>> On Sat, 26 Aug 2023 17:08:15 +0200
>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:
>>>
>>>> People who say you can have functional programming in C++ don't understand
>>>> functional programming. Its more than just no cost recursion , its also
>>>> polymorphism by *VALUE*. ...
>>>
>>> That's what I described and you didn't notice it. A function<>-object
>>> is always polymorphic. I bet you never used function<>-objects in C++.
>>
>> Given they're necessary for the STL what do you think?
>>
>> Which part of "by value" is confusing you? But if you insist on claiming its
>> possible show us how you'd do polymorphism for a function with a single int
>> param for say the values 0, 2, 3, 10 -> 100 and a default.
>
>You can't describe what you want and you don't understand function<>
>-objects. Stick with C.

Translation: I can't do it because its not possible but don't have the balls
to admit I was wrong.

Go back to writing your next piece of lame shit code to post on here in order
to show off.

Re: What is visitor pattern?

<ucd6bp$kol7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1204&group=comp.lang.c%2B%2B#1204

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 17:39:40 +0200
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <ucd6bp$kol7$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me> <ucd4gs$ke1h$1@dont-email.me>
<ucd4ug$khfd$1@dont-email.me> <ucd5ee$kjhn$1@dont-email.me>
<ucd665$ko3j$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Aug 2023 15:39:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3e6943790182c1617cc610032cf207b9";
logging-data="680615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v0RM0GSiRoqa+Uz+jaH1fS1rg/ht0SGw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:iDGnwzkwu/z03O616kXuourRs3I=
In-Reply-To: <ucd665$ko3j$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Sat, 26 Aug 2023 15:39 UTC

Am 26.08.2023 um 17:36 schrieb Muttley@dastardlyhq.com:
> On Sat, 26 Aug 2023 17:24:00 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 26.08.2023 um 17:15 schrieb Muttley@dastardlyhq.com:
>>> On Sat, 26 Aug 2023 17:08:15 +0200
>>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>> Am 26.08.2023 um 17:00 schrieb Muttley@dastardlyhq.com:
>>>>
>>>>> People who say you can have functional programming in C++ don't understand
>>>>> functional programming. Its more than just no cost recursion , its also
>>>>> polymorphism by *VALUE*. ...
>>>>
>>>> That's what I described and you didn't notice it. A function<>-object
>>>> is always polymorphic. I bet you never used function<>-objects in C++.
>>>
>>> Given they're necessary for the STL what do you think?
>>>
>>> Which part of "by value" is confusing you? But if you insist on claiming its
>>> possible show us how you'd do polymorphism for a function with a single int
>>> param for say the values 0, 2, 3, 10 -> 100 and a default.
>>
>> You can't describe what you want and you don't understand function<>
>> -objects. Stick with C.
>
> Translation: I can't do it because its not possible but don't have the balls
> to admit I was wrong.

Of course I can't do that because your requirements are too diffuse.

>
> Go back to writing your next piece of lame shit code to post on here in order
> to show off.
>

Re: What is visitor pattern?

<86v8d1xg92.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1207&group=comp.lang.c%2B%2B#1207

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Sat, 26 Aug 2023 21:26:33 -0700
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <86v8d1xg92.fsf@linuxsc.com>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com> <uIsEM.123835$QQFb.6082@fx38.iad> <6df46174-6867-4577-a73d-0fb70d6a25e8n@googlegroups.com> <9ea1f202-4524-03b8-f003-e11b7fa411e7@removeyourself.dontspam.yahoo> <c772c32e-d0e0-4199-b173-c64e3535159cn@googlegroups.com> <ubv1ke$1q0e7$1@dont-email.me> <01a599fc-0731-45e8-80d2-6f8eb387821dn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="e11e661f808acc58bc4b97373d32be95";
logging-data="1092090"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r9WUD4JEqrBB+I4dhxHVtSkTVd9Ev2hQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:NU49kHyUibeDjDYMrSzEpYQTMfU=
sha1:dNFZhX51mufz/GMiP1qI3NyujGE=
 by: Tim Rentsch - Sun, 27 Aug 2023 04:26 UTC

Tiib <ootiib@hot.ee> writes:

> Double dispatch was first perhaps described by Dan Ingalls in
> seventies

Do you have a reference for that?

> in context of SmallTalk ... [...]

It's Smalltalk, not SmallTalk.

Re: What is visitor pattern?

<5c32396d-2447-4079-9926-4e4dd3d4df9an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1208&group=comp.lang.c%2B%2B#1208

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:5602:b0:650:304:5137 with SMTP id mg2-20020a056214560200b0065003045137mr82144qvb.12.1693115837520;
Sat, 26 Aug 2023 22:57:17 -0700 (PDT)
X-Received: by 2002:a05:620a:8c0d:b0:76f:745:f56e with SMTP id
qz13-20020a05620a8c0d00b0076f0745f56emr118850qkn.0.1693115837340; Sat, 26 Aug
2023 22:57:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Sat, 26 Aug 2023 22:57:17 -0700 (PDT)
In-Reply-To: <86v8d1xg92.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=145.14.19.203; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 145.14.19.203
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <6df46174-6867-4577-a73d-0fb70d6a25e8n@googlegroups.com>
<9ea1f202-4524-03b8-f003-e11b7fa411e7@removeyourself.dontspam.yahoo>
<c772c32e-d0e0-4199-b173-c64e3535159cn@googlegroups.com> <ubv1ke$1q0e7$1@dont-email.me>
<01a599fc-0731-45e8-80d2-6f8eb387821dn@googlegroups.com> <86v8d1xg92.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5c32396d-2447-4079-9926-4e4dd3d4df9an@googlegroups.com>
Subject: Re: What is visitor pattern?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Sun, 27 Aug 2023 05:57:17 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1927
 by: Öö Tiib - Sun, 27 Aug 2023 05:57 UTC

On Sunday, 27 August 2023 at 07:26:52 UTC+3, Tim Rentsch wrote:
> Tiib <oot...@hot.ee> writes:
>
> > Double dispatch was first perhaps described by Dan Ingalls in
> > seventies
>
> Do you have a reference for that?
>
No ... GitHub contains one from eighties; can be I misremembered:
<https://algoritmos-iii.github.io/assets/bibliografia/simple-technique-for-handling-multiple-polymorphism.pdf>

> > in context of SmallTalk ... [...]
>
> It's Smalltalk, not SmallTalk.

Re: What is visitor pattern?

<8b34895c-0c2f-429b-b35f-4a2d293f62abn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1210&group=comp.lang.c%2B%2B#1210

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:18a2:b0:412:1974:9730 with SMTP id v34-20020a05622a18a200b0041219749730mr271464qtc.5.1693167208578;
Sun, 27 Aug 2023 13:13:28 -0700 (PDT)
X-Received: by 2002:a05:6214:a64:b0:63d:30b8:ff8b with SMTP id
ef4-20020a0562140a6400b0063d30b8ff8bmr814403qvb.13.1693167208326; Sun, 27 Aug
2023 13:13:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Sun, 27 Aug 2023 13:13:28 -0700 (PDT)
In-Reply-To: <ea1ee058-e460-4e34-a001-4e9375f1a7can@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com> <ea1ee058-e460-4e34-a001-4e9375f1a7can@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8b34895c-0c2f-429b-b35f-4a2d293f62abn@googlegroups.com>
Subject: Re: What is visitor pattern?
From: wynii...@gmail.com (wij)
Injection-Date: Sun, 27 Aug 2023 20:13:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2603
 by: wij - Sun, 27 Aug 2023 20:13 UTC

On Sunday, August 20, 2023 at 10:22:48 PM UTC+8, Öö Tiib wrote:
>...
> Unsure ... people's mind does not grasp double dispatch too well.

This is because people's mind is not depending on such academical concept 'double dispatch'.
I think many people might be interested in the visitor pattern. So, this is my
understanding from a usecase of virtual class, e.g.

class class Element {
public:
virtual void act(Actor &a) = 0; // act==accept
};

class ThingA : public Element { /* omitted */ }
class ThingB : public Element { /* omitted */ }
class ThingC : public Element { /* omitted */ }

int main() {
// The usecase of Element family should normally for something like the list[] below:
Element *list[3]= { new ThingA, new ThingB, new ThingC };

// By now, because only the act(..) member is available, the common usage
// pattern is like the following tow 'for' loops:

for(int i=0; i<3; ++i) { // Ask elements in list[] to do someting (SomeAct1)
list[i]->act(SomeAct1);
}

for(int i=0; i<3; ++i) { // Ask elements in list[] to do someting (SomeAct2)
list[i]->act(SomeAct2);
}

// That something SomeAct1,SomeAct2 are derived from Visitor and defined by user
// This is main point of Visitor Pattern, separates the implement of Element and SomeAct.
}

Re: What is visitor pattern?

<6006e16c-837a-4ab9-9cb8-6c5e21531a01n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1214&group=comp.lang.c%2B%2B#1214

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:6214:18e6:b0:649:6ad2:47d with SMTP id ep6-20020a05621418e600b006496ad2047dmr747304qvb.1.1693206833062;
Mon, 28 Aug 2023 00:13:53 -0700 (PDT)
X-Received: by 2002:a05:620a:1720:b0:76e:e65f:3d0a with SMTP id
az32-20020a05620a172000b0076ee65f3d0amr766441qkb.1.1693206832884; Mon, 28 Aug
2023 00:13:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 28 Aug 2023 00:13:52 -0700 (PDT)
In-Reply-To: <8b34895c-0c2f-429b-b35f-4a2d293f62abn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.50.190.130; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 84.50.190.130
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<ea1ee058-e460-4e34-a001-4e9375f1a7can@googlegroups.com> <8b34895c-0c2f-429b-b35f-4a2d293f62abn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6006e16c-837a-4ab9-9cb8-6c5e21531a01n@googlegroups.com>
Subject: Re: What is visitor pattern?
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Mon, 28 Aug 2023 07:13:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2956
 by: Öö Tiib - Mon, 28 Aug 2023 07:13 UTC

On Sunday, 27 August 2023 at 23:13:36 UTC+3, wij wrote:
> On Sunday, August 20, 2023 at 10:22:48 PM UTC+8, Öö Tiib wrote:
> >...
> > Unsure ... people's mind does not grasp double dispatch too well.
>
> This is because people's mind is not depending on such academical concept 'double dispatch'.
> I think many people might be interested in the visitor pattern. So, this is my
> understanding from a usecase of virtual class, e.g.
>
Yes, your understanding of use-case is correct, just that the data hierarchy
of a program is usually not a flat list. It is usually something like tree or directed
graph without cycles.

For example list of devices (of different types), every device has list of parameters
(of different types) and list of optional submodules/peripherals connected (of
different types) that may also have options and parameters.

Also visitor is usually used when it is not about operation on one element but needs
to do some operation over all that tree or some subtree of it.

So for above example about devices the visitors can be like that ...
One visitor wants to visit all that data to find out total current and maximum power
consumption of configuration of devices.
Second visitor wants to figure on what temperatures the devices and peripherals
operate.
Third wants to find what kind of backup devices need to be in warehouse for
urgently fix the setup.
Fourth wants to store all current configurable parameter values of the set.
Fifth wants to compose command sequence to turn all the devices off in
fastest and safest manner.

Re: What is visitor pattern?

<86a5uayg62.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1219&group=comp.lang.c%2B%2B#1219

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Mon, 28 Aug 2023 15:07:33 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <86a5uayg62.fsf@linuxsc.com>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com> <uIsEM.123835$QQFb.6082@fx38.iad> <6df46174-6867-4577-a73d-0fb70d6a25e8n@googlegroups.com> <9ea1f202-4524-03b8-f003-e11b7fa411e7@removeyourself.dontspam.yahoo> <c772c32e-d0e0-4199-b173-c64e3535159cn@googlegroups.com> <ubv1ke$1q0e7$1@dont-email.me> <01a599fc-0731-45e8-80d2-6f8eb387821dn@googlegroups.com> <86v8d1xg92.fsf@linuxsc.com> <5c32396d-2447-4079-9926-4e4dd3d4df9an@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="1084eb5dd0b1a11121af7ba127734067";
logging-data="1985633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19voE5C9PeG7+9G3MlGeSJdVJwxqxQRFZQ="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:q3hFsS/EbHD1CDmydMoo27mgyQs=
sha1:mE0yZs2TH68qjJF0qttURiFx008=
 by: Tim Rentsch - Mon, 28 Aug 2023 22:07 UTC

Tiib <ootiib@hot.ee> writes:

> On Sunday, 27 August 2023 at 07:26:52 UTC+3, Tim Rentsch wrote:
>
>> Tiib <oot...@hot.ee> writes:
>>
>>> Double dispatch was first perhaps described by Dan Ingalls in
>>> seventies
>>
>> Do you have a reference for that?
>
> No ... GitHub contains one from eighties; can be I misremembered:
> <https://algoritmos-iii.github.io/assets/bibliografia/
> simple-technique-for-handling-multiple-polymorphism.pdf>

Thank you, that's a good reference.

Re: What is visitor pattern?

<0469bc48-41a6-4824-8cd1-9b100526e3a1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1224&group=comp.lang.c%2B%2B#1224

  copy link   Newsgroups: comp.lang.c++
X-Received: by 2002:a05:622a:309:b0:403:c1e5:e427 with SMTP id q9-20020a05622a030900b00403c1e5e427mr721537qtw.5.1693289918117;
Mon, 28 Aug 2023 23:18:38 -0700 (PDT)
X-Received: by 2002:a17:903:11c8:b0:1bc:6f8c:7c15 with SMTP id
q8-20020a17090311c800b001bc6f8c7c15mr9985477plh.7.1693289917771; Mon, 28 Aug
2023 23:18:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c++
Date: Mon, 28 Aug 2023 23:18:36 -0700 (PDT)
In-Reply-To: <6006e16c-837a-4ab9-9cb8-6c5e21531a01n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=124.218.76.41; posting-account=0Ek0TQoAAAAS0oceh95IuNV59QuIWNeN
NNTP-Posting-Host: 124.218.76.41
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<ea1ee058-e460-4e34-a001-4e9375f1a7can@googlegroups.com> <8b34895c-0c2f-429b-b35f-4a2d293f62abn@googlegroups.com>
<6006e16c-837a-4ab9-9cb8-6c5e21531a01n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0469bc48-41a6-4824-8cd1-9b100526e3a1n@googlegroups.com>
Subject: Re: What is visitor pattern?
From: wynii...@gmail.com (wij)
Injection-Date: Tue, 29 Aug 2023 06:18:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3847
 by: wij - Tue, 29 Aug 2023 06:18 UTC

On Monday, August 28, 2023 at 3:14:04 PM UTC+8, Öö Tiib wrote:
> On Sunday, 27 August 2023 at 23:13:36 UTC+3, wij wrote:
> > On Sunday, August 20, 2023 at 10:22:48 PM UTC+8, Öö Tiib wrote:
> > >...
> > > Unsure ... people's mind does not grasp double dispatch too well.
> >
> > This is because people's mind is not depending on such academical concept 'double dispatch'.
> > I think many people might be interested in the visitor pattern. So, this is my
> > understanding from a usecase of virtual class, e.g.
> >
> Yes, your understanding of use-case is correct, just that the data hierarchy
> of a program is usually not a flat list. It is usually something like tree or directed
> graph without cycles.
>
> For example list of devices (of different types), every device has list of parameters
> (of different types) and list of optional submodules/peripherals connected (of
> different types) that may also have options and parameters.
>
> Also visitor is usually used when it is not about operation on one element but needs
> to do some operation over all that tree or some subtree of it.
>
> So for above example about devices the visitors can be like that ...
> One visitor wants to visit all that data to find out total current and maximum power
> consumption of configuration of devices.
> Second visitor wants to figure on what temperatures the devices and peripherals
> operate.
> Third wants to find what kind of backup devices need to be in warehouse for
> urgently fix the setup.
> Fourth wants to store all current configurable parameter values of the set.
> Fifth wants to compose command sequence to turn all the devices off in
> fastest and safest manner.

I am writing a stave music parser program. Stave music is actually a small
script language similar to average programming language, there is conditional
control flow and stave's 'environment' need to be traced. I am happy the
visitor pattern is learnt and used immediately. The parser part is reduced form
complex 10k lines of codes to 2k simple codes and done fast, just these several days.

In my case, the list[] array structure is enough since this part of program is
just a parser. The tree,graph,... structure of the 'Element' is left for user
to interpret (the visitor can be a printer or different sound devices).

Re: What is visitor pattern?

<ucl9qd$2bhvr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1225&group=comp.lang.c%2B%2B#1225

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Re: What is visitor pattern?
Date: Tue, 29 Aug 2023 19:27:41 +0200
Organization: A noiseless patient Spider
Lines: 142
Message-ID: <ucl9qd$2bhvr$1@dont-email.me>
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 29 Aug 2023 17:27:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="29af086456143f20ae59fea3d0f6f1b5";
logging-data="2476027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CgJrXs9fwqAQKRzhyw3j8tnudtUpU5JE="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:zoXADcdQv4mzzzWbpPQxHsgGmC8=
In-Reply-To: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Tue, 29 Aug 2023 17:27 UTC

I think that's my final solution. Currently I store the bits in
size_ts and I look up the next set bit with countr_zero which maps
to TZCNT on x64 and according to some small code on godbolt ARM
also has a proper instruction for that.
Resettig the bits for the composites is done by a rotating bit-mask.
If the prime is less than size_t * 8 there's a special case optimi-
zation.

#include <iostream>
#include <vector>
#include <charconv>
#include <string_view>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <cstring>
#include <bit>

#if defined(_MSC_VER)
#pragma warning(disable: 26495) // uninitialized member
#endif
#if defined(__llvm__)
#pragma clang diagnostic ignored "-Wdangling-else"
#endif

using namespace std;

int main( int argc, char **argv )
{ constexpr size_t BUF_SIZE = 0x100000;
try
{
size_t end;
if( argc < 2 )
return EXIT_FAILURE;
char const *sizeStr = argv[1];
bool hex = sizeStr[0] == '0' && (sizeStr[1] == 'x' || sizeStr[1] == 'X');
sizeStr += 2 * hex;
if( from_chars_result fcr = from_chars( sizeStr, sizeStr + strlen(
sizeStr ), end, !hex ? 10 : 16 ); (bool)fcr.ec || *fcr.ptr )
return EXIT_FAILURE;
if( !++end )
throw bad_alloc();
using word_t = size_t;
constexpr size_t BITS = sizeof(word_t) * 8;
size_t bEnd = (end + BITS - 1) & -(ptrdiff_t)BITS;
if( bEnd < end )
throw bad_alloc();
union ndi_word_t { word_t w; ndi_word_t( word_t w ) : w( w ) {} };
using bit_vec = vector<ndi_word_t>;
using bit_it = bit_vec::iterator;
bit_vec sieve( (end + BITS - 1) / BITS, (word_t)0xAAAAAAAAAAAAAAAAu );
ofstream ofs;
union ndi_t { char c; ndi_t() {} };
using ndi_vec = vector<ndi_t>;
constexpr size_t AHEAD = 32;
ndi_vec printBuf;
ndi_vec::iterator bufBegin, bufEnd, bufFlush;
if( argc < 3 || *argv[2] )
{
ofs.exceptions( ofstream::failbit | ofstream::badbit );
ofs.open( argc >= 3 ? argv[2] : "primes.txt", ofstream::trunc );
printBuf.resize( BUF_SIZE + AHEAD - 1 );
bufBegin = printBuf.begin();
bufEnd = bufBegin;
bufFlush = bufBegin + BUF_SIZE;
}
auto print = [&]() { ofs << string_view( &to_address( bufBegin )->c,
&to_address( bufEnd )->c ); };
bit_it const pSieveEnd = sieve.end();
size_t sqr = (ptrdiff_t)ceil( sqrt( (ptrdiff_t)end ) );
for( size_t p = 2; p < end; )
{
if( ofs.is_open() )
{
auto [ptr, ec] = to_chars( &bufEnd->c, &to_address( bufEnd + (AHEAD
- 1) )->c, p );
if( (bool)ec ) [[unlikely]]
throw system_error( (int)ec, generic_category(), "converson failed" );
bufEnd = ptr - &bufBegin->c + bufBegin; // NOP
bufEnd++->c = '\n';
if( bufEnd >= bufFlush )
ofs << string_view( &to_address( bufBegin )->c, &to_address( bufEnd
)->c ),
bufEnd = bufBegin;
}
if( ++p == end ) [[unlikely]]
break;
for( bit_it pSieve = sieve.begin() + p / BITS; ; )
{
size_t g = countr_zero( pSieve->w & (word_t)-1 << p % BITS );
p = (p & -(ptrdiff_t)BITS) + g;
if( g != BITS )
break;
if( ++pSieve == pSieveEnd )
goto end;
}
bit_it pSieve = sieve.begin();
if( size_t m = p * p; p < sqr )
if( p >= BITS ) [[likely]]
{
word_t mask = rotl( (word_t)-2, m % BITS );
do
pSieve[m / BITS].w &= mask,
mask = rotl( mask, (int)p % BITS ),
m += p;
while( m < end );
}
else
{
pSieve += m / BITS;
word_t mask = rotl( (word_t)-2, m % BITS );
do
{
word_t punch = -1, oldMask;
do
punch &= mask,
oldMask = mask,
mask = rotl( mask, (int)p );
while( mask < oldMask );
pSieve->w &= punch;
} while( ++pSieve != pSieveEnd );
}
}
end:
if( ofs.is_open() )
print();
return EXIT_SUCCESS;
}
catch( bad_alloc const & )
{
cout << "out of memory" << endl;
}
catch( ios_base::failure const & )
{
cout << "I/O error" << endl;
}
catch( system_error const &se )
{
cout << se.what() << endl;
}
}

Re: What is visitor pattern?

<9axHM.112635$JbKe.40455@fx04.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1227&group=comp.lang.c%2B%2B#1227

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx04.iad.POSTED!not-for-mail
Subject: Re: What is visitor pattern?
Newsgroups: comp.lang.c++
References: <331cb164-e6b3-4f9b-af8d-ee933abd79b7n@googlegroups.com>
<uIsEM.123835$QQFb.6082@fx38.iad> <ubuoig$1ons4$1@dont-email.me>
<AXVEM.568386$SuUf.28925@fx14.iad> <uc1b4g$292ev$1@dont-email.me>
<LzWEM.65654$VPEa.6307@fx33.iad> <uc29p5$2dgb7$1@dont-email.me>
<niCFM.897824$GMN3.379171@fx16.iad> <uc703b$3cer6$1@dont-email.me>
<gcSFM.312013$Fgta.22420@fx10.iad> <uc9696$3rp9i$1@dont-email.me>
<2KfGM.827216$TPw2.761320@fx17.iad> <ucc9bg$g167$1@dont-email.me>
<uccbgu$gd6k$1@dont-email.me> <uccglr$h6lp$1@dont-email.me>
<ucd42s$kc9j$1@dont-email.me>
From: pauldont...@removeyourself.dontspam.yahoo (Pavel)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
MIME-Version: 1.0
In-Reply-To: <ucd42s$kc9j$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 29
Message-ID: <9axHM.112635$JbKe.40455@fx04.iad>
X-Complaints-To: https://www.astraweb.com/aup
NNTP-Posting-Date: Wed, 30 Aug 2023 01:44:37 UTC
Date: Tue, 29 Aug 2023 21:44:23 -0400
X-Received-Bytes: 2464
 by: Pavel - Wed, 30 Aug 2023 01:44 UTC

Muttley@dastardlyhq.com wrote:
> On Sat, 26 Aug 2023 11:29:34 +0200
> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> Am 26.08.2023 um 10:01 schrieb Muttley@dastardlyhq.com:
>>
>>> This sort of programming is the equivalent of touchscreens in cars - looks
>>> great and impresses the "Ooo shiny!" crowd but adds little to the main
>>> functionality of the car and just adds needless complexity with more scope
>>> for failure.
>>
>> My solution is less complexity because you don't need to declare
>> a base class and a derived class. Just declare the parameter as
>> a function object and pass a lambda which is automatically crated.
>> That's for sure at maximally the tenth of the code.
>> You can have functional programming in C++ since 2011. That's a
>> long time you didn't notice its potential.
>
> People who say you can have functional programming in C++ don't understand
> functional programming. Its more than just no cost recursion , its also
> polymorphism by *VALUE*. That is not and probably never will be possible in
> C++.
>
Hard to believe but they were thinking of it as recently as Sep 2020,
see https://wg21.link/p1371r3

But of course, on mutable objects, pattern mathcing loses some 90% of
its use.


devel / comp.lang.c++ / Re: What is visitor pattern?

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor