Generic Class Library - bugs, description, questions, usage and suggestions - page 27

 
Artyom Trishkin:
  1. I meant that automatic removal by the terminal subsystem of all your created objects and put pointers to them in lists you call a crutch, and you don't consider manual handling of objects and creation of crutches to do it a crutch
  2. That wasn't part of what you said in item 1, and is the main reason I responded.
  3. That too, and for the same reason.

What do you create collections for, for collections and automatic deletion of objects?) I didn't say anything about manual operation at all. Where did you get that from?)

Study STL and you'll understand what I'm talking about.

 
Igor Makanu:

how to copy correctly, can you give an example for this template?

I used the help to write the AddValue methodhttps://www.mql5.com/ru/docs/basis/types/classes

I racked my brains, but I don't see any other solution in MQL than I wrote in my example!

Show me your implementation of correct data storage.

That's what I meant in your case.
void  AddValue (const T &value)  { Tptr = new T(value); mlist.Add(Tptr); }

But this solution is wrong anyway. A normal solution is to use something like STL. In your case std::list.

I think MQL5 doesn't limit it. You can try to translate STL sources from the same VS to MQL

 
In the old generation of moderators there were at least two professional programmers. now there are none. and it is very noticeable )
 
Andrey Pogoreltsev:
That's what I mean in your case.

But it's still the wrong solution. The normal solution is to use something like STL. In your case std::list.

I don't think MQL5 doesn't limit it. You may try to translate STL source code from VS to MQL

Once again: MQL is not C++,

and a pointer to an object in MQL is in fact a handle, and a pointer in C++ is a physical memory address.

what's the point of porting C++ libraries to MQL ?

 
Igor Makanu:

Once again: MQL is not C++,

and a pointer to an object in MQL is in fact a handle, and a pointer in C++ is a physical memory address

what's the point of porting C++ libraries to MQL ?

To properly implement the design patterns instead of creating potential problems using generics.

You must be surprised but the pointers for the operating system are virtual too. You still have to convert them into physical ones, but this is a completely different level of work with pointers.

You won't be able to port 1 into 1, but I think you will be able to port a stripped-down C++03. Support of templates and operators is available.

 
Andrey Pogoreltsev:

1. You may be surprised, but pointers for the OS are virtual too. They still need to be converted into physical ones, but that's a whole other level of pointer handling.

2. You won't be able to port 1 into 1 but you will be able to port the stripped-down C++03. Support of templates and operators is also there.

1. I would not be surprised

2. Well, here's the truth - even if you get together and make a port from C++, it will still cause questions, but why not as in the original? - what is the point?

There is a standard library of MQL, using it at least some kind of guarantee that the support will be provided by developers in the future. I've already been burned a couple of times - I used graphic components from articles written a few years ago, it's easy to use, much like working with Delphi components, but when I started trying to implement more serious projects I got a lot of questions and no response from the author of the article

I do not remember who of the prominent programmers said, but something like this: the code should not be beautiful or readable, it must perform its task

as our discussion, if I'm not mistaken, you wanted to store a structure with your data in lists, I showed you my implementation, which I developed for the same task - does my implementation work? - does it cause runtime errors in MQL-programs? - I am curious to find out in the course of the conversation

 

Andrey Pogoreltsev:

C++03 is possible, I think. Support for templates and operators is available.

Well yes, good luck ))

 
Igor Makanu:

The code does not have to be pretty or readable, it has to do its job

This is only true until you want to refine it.

 

I have already pointed out this bug in CLinkedList class, but I will repeat it. The beginning and end nodes of the list are closed to each other: Next of the last node points to the first node, while Previous of the first node points to the last one. As the result, the standard search loop turns into an infinite loop:

#include <Generic\LinkedList.mqh>

void OnStart()
{
  CLinkedList<string> list;
   
  list.AddLast("One");
  list.AddLast("Two");
  list.AddLast("Three");
  int i=0;
  for (CLinkedListNode<string> *node= list.First();  node!=NULL;  node=node.Next())  // Цикл бесконечно бегает по кругу
    { }
} 

In C# such nonsense is naturally not observed. The Next of the last node is zero, as well as thePrevious of the first n ode.

I don't know if it's some "feature" invented by developers (although I don't see its usefulness), but in any case the library's behavior should correspond to the original one.

 
Alexey Navoykov:

I have already pointed out this bug in CLinkedList class, but I will repeat it. The beginning and end nodes of the list are closed to each other: Next of the last node points to the first node, while Previous of the first node points to the last one. As the result, the standard search loop turns into an infinite loop:

In C#, naturally, there is no such nonsense. The Next of the last node is zero, as well as thePrevious of the first n ode.

I don't know if this is some "feature" invented by the developers (although I don't see any benefit from it), but in any case the library's behaviour should correspond to the original.

What the hell is going on here again? They're deleting perfectly good LinkedList posts. Just like that, somewhere in Europe, an anonymous moderator is deleting posts from hated Russians while sniggering maliciously. What a dump, it makes you not want to write.

Reason: