Errors, bugs, questions - page 714

 
victorg:

A macro and an inline function are indeed different things. But that's not what I mean. Here is an example where the arguments' values are unknown at compile time

In the first case, the code must be pasted into the current function (I suppose) and in the second case, the function is called with parameters passed through the stack (I suppose). But for the purpose of optimization, the compiler may actually implement the second variant through substitution as well. Is it so? I do not know. That's why I asked.

It's the Metakvotts who have to be tortured. But my opinion coincides with yours (because of optimisation, the result might be different).
 

The ellipse object is only highlighted with the mouse if you click on the anchor points.

Is it a bug or a feature? It is very inconveniently implemented.

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Способы привязки объектов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Способы привязки объектов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Способы привязки объектов - Документация по MQL5
 
The vertical scale, if set manually, is not remembered on restart. Also a nuisance.
 
MetaDriver:

Это что, юмор такой чёрный?

1.  Извини, - бред.  Я понимаю, тут паранойя в моде, и является ломовым аргументом за "почему так не надо делать".  Никакой опасности не вижу в упор. Смотрел внимательно, если чё.  Любое имя, в конечном счёте есть ссылка.  Индексация есть обычное расширение понятия имени. Не более.  Давай запретим присваивание вообще.  В целях безопасности.  Ссылки же крайне опасны так?

2.  Духу объектно-ориентированного программирования, при такой логике, яростно противоречат С++, С#, Делфи, пара дюжин менее популярных языков, в которых индексаторы совершенно нормально работают и справа и слева.  Причём здравому смыслу и моему духу это почему-то не противоречит.

Индексаторы делаются для связи с внешней средой.  Их функция именно интерфейсная.  Я могу инкапсулировать и прятать что угодно, но индексы мне нужны для оперирования объектами как массивами. Фактически все массивы как-то устроены. Например обычные динамические массивы mql. Может запретим их слева от оператора присваивания ставить?  Заменим функцией какой-нибудь типа SetArrayValue(array, i, j, value);  Заодно и в читабельности выиграем. Да и отладка станет куда проще.  Мля. Уф..

3.  А как насчёт того, чтоб сделать нормальный индексатор?  Горничная это конечно классно, но королева всё-таки лучше.

4.  Вот в этом месте у меня крыша конкретно начала ехать.  Это что, нечитабельно??

Вот это читабельнее, да?

  t.setDataElement(i, i*i);

Круто.  Пожалуй пойду лечиться.

5.  Ваще круто.

6. Я плакаль.


e(array, i, j, value); This will also improve readability. And debugging will also become much easier. Shit. Ugh...

Well, a setter has an advantage that you can do something more than a simple equation.

For example, you can log information, convert data (if we're talking about strings or more complex data), send messages to other objects if something important happens (like update data).

How will your object know when the date has changed? Apparently you're going to store quotes...
Oh yes, that's a false problem, because your object is more like a struct and doesn't really manage anything.
Everything is done in another rubbish class, which handles everything or even worse, everything happens in onStart(), onTick(), ... ! :)

Have a nice day

 
MetaDriver:

3. how about making a normal indexer? maid is cool, but queen is better.

Muti gasket. Compared to a normal lvalue, however, it will be much more expensive in terms of time. But it will look just the way you need it.

______

Ah, hell no. Then you need a type ghost operator overload. Pity.

 
speedy:

Well, the advantage of the setter is that you can do something more than a simple equation.

For example, you can log information, convert data (if we are talking about strings or more complex data), send messages to other objects if something important happens (like update data).

How will your object know when the date has changed? Apparently you're going to store quotes...
Oh yes, it's a false problem, because your object is more like struct and doesn't really control anything.
Everything is done in another rubbish class, which handles everything or even worse, everything happens in onStart(), onTick(), ... ! :)

Have a nice day

The point is that the indexer is the same as the setter in terms of features . It's implemented as a function, the contents of which can be anything (the simplest typical case is array bounds checking and handling other errors), and it's not just returning a reference to an array item.

You have a good day too.

(Sorry about yesterday's tone. I was a bit on edge - trouble at work. You had nothing to do with it. Well, unless you're being too categorical :)

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - Документация по MQL5
 
TheXpert:

Muti gasket. Compared to a normal lvalue, however, it will be much more expensive in terms of time. But it will look the way you need it.

______

Ah, hell no. You need to overload the type conversion operator then. Too bad.

Actually I think they'll do it. There's an obvious flaw with reference returns in the language.

You don't have to make reference variables, but l-value return from functions is sacred... :)

I don't think it cannot be solved in principle - the language has usual mql-arrays and they feel very well at both sides of the assignment operator. But they are C++ classes by implementation !

Here is another example from the same series. This code compiles but does not work.

#define _MyContainer(name,type,size)  struct name { public: type array[size]; type At(int i) {return array[i];} }
#define  ASize 8
#define  BSize 4

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   _MyContainer(MyClass, int, ASize);
   MyClass MyVar;
   Print(sizeof(MyVar)); 
   for(int i=0;i<ASize;i++)
     {
      MyVar.array[i]=i*i;
     }
   for(int i=0;i<ASize;i++)
     {
      Print(MyVar.At(i));
     }
   _MyContainer(My2DBag, MyClass, BSize);
   My2DBag MyVar2D;
   for(int i=0;i<BSize;i++)
     {
      for(int j=0;j<ASize;j++) MyVar2D.array[i].array[j]=(i+1)*(j+1);
     }
   for(int i=0;i<BSize;i++)
     {
      for(int j=0;j<ASize;j++) Print(MyVar2D.At(i).At(j));
// Run-time ERROR:  DefTest (USDJPY,M30)  invalid pointer access in 'DefTest.mq5' (38,46)

//      for(int j=0;j<ASize;j++) Print(MyVar2D.array[i].At(j));
     }
  }

My point is not that they shouldn't compile - my point is that they should work. :)

 
MetaDriver:

...
I'm not saying it shouldn't compile, I'm saying it should work... :)

Yes, you're right, it's a compiler error, we'll fix it.
 

MQL5 has a wonderful constant IS_DEBUG_MODE belonging to Other constants group. Can we add such constant for a tester? Something like IS_TESTER_MODE...

Документация по MQL5: Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Именованные константы / Прочие константы - Документация по MQL5
 
denkir:

MQL5 has a wonderful constant IS_DEBUG_MODE belonging to Other constants group. Can we add such constant for a tester? Something like IS_TESTER_MODE...

Wouldn't these constants work?

ENUM_MQL5_INFO_INTEGER

Identifier

Description

Property type

MQL5_PROGRAM_TYPE

Type of mql5-program

ENUM_PROGRAM_TYPE

MQL5_DLLS_ALLOWED

Permission to use the DLL for thecurrent program running

bool

MQL5_TRADE_ALLOWED

Permissionto trade for this running program

bool

MQL5_DEBUGGING

Sign of a running program working in debug mode

bool

MQL5_TESTING

Sign of running a program in the tester

bool

MQL5_OPTIMIZATION

Sign of running a program during optimization

bool

MQL5_VISUAL_MODE

Sign of running a program in a visual testing mode

bool

Reason: