26

Re: Explain about pattern matching in C#

Hello, vdimas, you wrote: V> And how it helps if the hierarchy already cannot be modified and before the hierarchy did not know about a certain visitor? The visitor happens also exterior. And  classical  on double dispatching that it is necessary to implement only him, and actually specific algorithms will be already in the pure state exterior.

27

Re: Explain about pattern matching in C#

Hello, elmal, you wrote: E> it was possible  on value of primitives Earlier,  and lines like, now added possibility on the specific types, all innovation. No, not all. switch (obj) {//Match different kinds of constants: case 10: Console. WriteLine ("int const"); break; case "Hello World": Console. WriteLine ("string const"); break; case null: Console. WriteLine ("Argument is null"); break;//Match the type. Note, that variable _ is not used, however it is needed even//when you want to check only the type. case Cat _: Console. WriteLine ("Argument is Cat"); break;//Match reference type and value type with conditions: case string str when str. Length> 10 && str! = "Hello World": Console. WriteLine (str); break; case long num when num> 0 && num <1000: Console. WriteLine (num); break;//Combined cases: case string str when int. TryParse (str, out int num) && num! = 100: Console. WriteLine ("Combined case"); break;//The default case can be written as: case var _: Console. WriteLine ("Not expected value of obj"); break;} E> For example if there is support Tuples with  In  is both , and . And not only for , but also for the arbitrary classes.

28

Re: Explain about pattern matching in C#

Hello, Night Looking, you wrote: V>> And how it helps if the hierarchy already cannot be modified and before the hierarchy did not know about a certain visitor? The NANOSECOND> the Visitor happens also exterior. The question about "could not be modified hierarchy". If visitor it was not primary in hierarchy to fasten it directly does not quit.

29

Re: Explain about pattern matching in C#

Hello, vdimas, you wrote: V> the Question about "could not be modified hierarchy". V> If visitor it was not primary in hierarchy to fasten it directly does not quit. Quits. Double dispatching on the virtual methods is not a mandatory member .

30

Re: Explain about pattern matching in C#

Hello, vdimas, you wrote: V> Only it is badly clear, where "is searched", in sense, what there about width of spanning? V> it is necessary to search in various methods-expansions of all static classes of all loaded and dependent assemblies? V> I.e. here the assembly is specified as dependent, but yet  because it is real types from it were not used yet, but for your sentence it is necessary  all both at once? And then to walk simple search by each call of the virtual method-expansion? Why not to do such search at a stage of compilation for each compiled type? Result will be EMT. Well and at performance from this table we precisely know at once the mailing address of the necessary method, unless can be demanded to load the assembly.

31

Re: Explain about pattern matching in C#

Hello, Night Looking, you wrote: ARK>> Why not to make virtual extension methods? The NANOSECOND> Because it absolutely other mechanics, as a matter of fact duck typing, and it demands absolutely other volume of changes both in language and in CLR. I do not know that there in CLR but what to change in language? In my opinion, approximately anything.

32

Re: Explain about pattern matching in C#

Hello, AlexRK, you wrote: ARK> Why not to do such search at a stage of compilation for each compiled type? Because, in case of polymorphic hierarchy, at a compilation stage the specific type is unknown.

33

Re: Explain about pattern matching in C#

Hello, AlexRK, you wrote: the NANOSECOND>> Because it absolutely other mechanics, as a matter of fact duck typing, and it demands absolutely other volume of changes both in language and in CLR. ARK> I do not know that there in CLR but what to change in language? Appears duck typing with all that it implies type of cardinal change of rules of an overload of methods or necessity to consider it in  templates.