question for #define experts - page 2

 
Oh, my God, the boys can't live without pads.
 
Nikolai Karetnikov:

Thank you! )

Essentially.

That's where I left off with the class option. Even such elementary things as #define parameterization are quickly forgotten without daily use.

On nerves.

God, how sensitive everybody is here; you may ask a question without an implication, without the intent to offend or insult, but no, somewhere in the soul of an unrecognized genius you get a nagging and a desire to assert yourself at the expense of yet another amateur. I do not encounter it on the English forum, although I write there regularly. Knowing this, I usually try not to react to such remarks, but if Dmitry, you want to frolic in a verbal battle, I will give you the pleasure of plunging you headfirst into your own emanations.

Cut the fly, baby.

 
Vladimir Simakov:

Why didn't you show this decision to the man straight away?)

UPD: bezgovna - spelled no sh..t ))))

Well, you're just enjoying the idea that I didn't know that. So just keep on beating yourself up in an orgasm of your own awesomeness.

 
Dmitry Fedoseev:
Oh man, the boys can't live without pads anymore.

About the gaskets.

What's good about singleton? Because you can store state, process logs with complex logic, etc., while keeping everything concise in the main code. This way proper project architecture is created and the code itself becomes more readable.

PS. Otherwise, yes, everything is to a fan. Many people here in the community like the spaghetti code with Hungarian notation, and the masochism with trying all orders and positions (all in general) on every tick is great).

 

A long time ago (many years ago) .... There was already a thread about the best logs, whether it was in a separate thread or in another thread I can't remember.

But it was done in a slightly different way. There they defanged the function name and added there all sorts of macro lines of function names and so on... and then you could change the handler on the fly

something like "#defin PRINT prepare; Print"

and the print itself in the style of

void Print (string a; string a1="" ;string a2=""; ...... // 64 times. I wish we could just write ...a[]

{

Print (Our preparation, arguments);

}

The define could have been handled like an ordinary print, and by changing the handler we can write data into a file or display it. The number of arguments can be any (up to 64) // for those who haven't learned yet.

By the way, this ispartly what the author was asking))

 
Dmitry Fedoseev:
But, unfortunately, you won't impress the suckers.

Would you like to?

Sorry, but as I remember from the days when Assembler was still used, macro extension (macro ) is a tool that allows you to replace its definition with its code just before compilation.

It's just that programming in Assembler is a bit cumbersome and there are no subroutines.

Programming in MQL is a bit more comfortable.

Question: Would you be more comfortable writing a subroutine, or just the Print("No sheet"); or something to predefine in the preprocessor?

 
Алексей Тарабанов:

(1) Would you like to?

Sorry, but as I remember from the days when Assembler was still used, macro extension (macro ) is a tool that allows you to replace its definition with its code just before compilation.

(2) Simply, it is rather cumbersome to program in Assembler and there are no subroutines there.

Programming in MQL is a bit more comfortable.

(3) Question: Would you feel more comfortable writing a subprogram, or just the Print("No sheet"); or pre-define something in the preprocessor?

1) The question is not for me.

2) There are subroutines in assembler.

3) I'm more comfortable not to bullshit on questions that aren't worth a rotten egg.

 
Alexandr Andreev:

A long time ago (many years ago) .... There was already a thread about the best logs, whether it was in a separate thread or in another thread I can't remember.

But it was done in a slightly different way. There they defanged the function name and added there all sorts of macro lines of function names and so on... and then you could change the handler on the fly

something like "#defin PRINT prepare; Print"

and the print itself in the style of

void Print (string a; string a1="" ;string a2=""; ...... // 64 times. I wish we could just write ...a[]

{

Print (Our preparation, arguments);

}

The define could have been handled as a regular print, and by changing the handler we could either write data into a file or display it on the screen. The number of arguments can be any (up to 64) // for those who haven't learned yet.

By the way, this isexactly what the author was asking))

string aN="" and 63 times - that's a fury.

Let me explain:

  1. A string is an object that is a wrapper over a wchar_t*.
  2. By making string="" 63 times, you do the following: you allocate memory for 63 string objects (on the stack in this case), call the parametric constructor (63 times), allocate a wchar_t* buffer of some size in the heap (just there), the first two bytes of which are initialized with 0x0000 (yes, that happens 63 times too).

If you're doing it that way, make string=NULL, in this case you will save major costs of allocating unnecessary memory in heap.

UPD. No, I'm wrong, if done properly, there will be no memory allocation in the heap.

 
Vladimir Simakov:

string aN="" and 63 times is fierce.

Let me explain:

  1. string is an object that is a wrapper over wchar_t*.
  2. By making string="" 63 times, you do the following: you allocate memory for 63 string objects (on the stack in this case), call the parametric constructor (63 times), allocate a wchar_t* buffer of some size in the heap (just there), the first two bytes of which are initialized by 0x0000 (yes, this also happens 63 times).

If you do it that way, make string=NULL, in this case you will save major costs of allocating unnecessary memory in heap.

UPD. No, I'm wrong, if done properly, there will be no memory allocation in the heap.

Once again you don't understand what we're talking about. Alexander writes about replacing Print() via define (to avoid crawling all over the file and looking for all the prints). The problem of this is that Print can have several parameters, although no one distinguishes them as parameters - just a string connected by commas. So, to provide a replacement for the standard Print function, you need a function that accepts 64 optional parameters (to fully match the Print() function). And you need it to add some data before the log, maybe a strip with an arrow (==>) for better visibility, maybe a line number, date or output into a file. No one can care about the speed of this at all, because it is done in especially complex cases of searching errors, and then removed.

 
string _info;
void _Print(string s,string s1="",string s2="",string s3="",string s4="",string s5="",string s6="",string s7="",string s8="")//.....
   {
   string ss;
   StringConcatenate(ss,s,s1,s2,s3,s4,s5,s6,s7,s8);//....
   //Comment(_info,ss);
   Print(_info,ss);
   }
#define Print _info=__FILE__+" line "+__LINE__ +" "+__FUNCSIG__+" Print: "; _Print

void OnStart()
  {
   
   Templ();
  }
  
void Templ()
   {
   Print("Error, a!=",5," and other....",3,4,5);
   Print("a=",5);
   Print("Hi");
   }


Everyone seems to understand.....

So this is for those who are just starting their way....

We can wrap it all in a stat class and return a reference, which then equalize the rest since this method has a minus when working with if (a!=5) Print(a); this will not work, you should always write if (a!=5) {Print(a);}, in classes you can correct this moment, but I'm too lazy)) and in general, it seems all is in the archives of history

the way with classes, initialize our data via static method and combine the operator call our print.... thenif (a!=5) Print(a); it will work

Reason: