Errors, bugs, questions - page 2870

 
Roman:

What does this have to do with templates?
If the usage syntax is not for a template, in this case.

The Developers have put the typename description with an example in this section. Read to the end and you'll find this paragraph and this example

 
A100:

What is the difference between (1) and (2) ? Dear developers - maybe Roman is right and now typename returns type?

I think this is closer to a macro

 
A100:

The Developers have put a description of the typename with an example in this section. Read to the end and you will find this paragraph and this example

You see, that section of the documentation is about templates.
Templates have nothing to do with these examples.
typename is the same as getting sizeof

#define   A '+'

void OnStart()
{
   Print(sizeof(A));
   Print(typename(A));
   Print(sizeof("string"));
   Print(typename("string"));
}
2020.10.09 02:20:21.917 TestScript (MNQZ20,M1)  2
2020.10.09 02:20:21.917 TestScript (MNQZ20,M1)  ushort
2020.10.09 02:20:21.917 TestScript (MNQZ20,M1)  12
2020.10.09 02:20:21.917 TestScript (MNQZ20,M1)  string
 
Roman:

Understand that that section of the documentation is about templates.
Templates have nothing to do with these examples.
typename is like getting sizeof

The documentation says:To create generic ways to handle different data types, the keywordtypename shouldbe usedto get the type of the argument as a string.

Where is the word typename in this sentence? I don't see it? Yes... The template example. Do you expect the Developers to give you examples for all occasions?

 
A100:

The documentation says:To create universal ways of working with different data types, you must use the keyword typenameto get the type of the argument as a string.

Where is the word typename in this sentence? I don't see it? Yes... The template example. Do you expect the Developers were to give you examples for all occasions?

We don't create anything in this case, we just get their names from the types.
Get away from templates. And documentation for the template.
Do you see the result of the print? What else do you need?
Honestly, I don't understand your misunderstanding.

 
Roman:

In this case, we don't create anything, we get their names from the types.
Get away from templates. And the documentation for the template.
Do you see the result of the print? What else do you need?

Do you see the result of this print?

void OnStart()
{
    Print("ushort");
}

Result: ushort

So, is "ushort" a type? And this entry is normal according to you?

void OnStart()
{
    "ushort" ch = '+';
}
No, it is not a type, it is a string. Print does not print types - PrintFormat does not have such a format. It prints strings, numbers, symbols, but not types
 
A100:

Can you see the result of this print?

Result: ushort

So now: is "ushort" a type? And such an entry is normal according to you?

))) You amaze me.

You passed a string literal to the printer and got it.
To get a name of type you use keyword typename("ushort")
get name of type string

You pass type itself typename(string), get the same thing.

Actually it is a bug in the documentation that it does not describe how to handle thetypename keyword.
There is a description for sizeof andtypename only for patterns.
Although I gave an example above thattypename gets the type name, just likesizeof gets the size .

 
Roman:

)))) you surprise me.

You passed a string literal to the printer, you got it.

So you also pass a string literal to print

void OnStart()
{
    Print(typename('+'));
}

Result: ushort

If you think otherwise after all the explanations and studying the documentation, that's your problem:

void OnStart()
{
    Print(short); //Error - потому что принт типы не печатает
}
 
A100:

So you passed a string literal to the print

Result: ushort

If you think otherwise after reading all explanations and documentation, it's your problem.

Did I claim that it returns a string ?
It's you who got hooked on string and Print()
And the output will not be a string literal, but the character integer type ushort.
Anyway too, not my problem in your cognition.

 
Roman:

The output will not be a string literal, but the character integer type ushort.

The output will be exactly string literal. Here - found direct proof - there is no print here at all:

int f()
{
    return typename('+'); //warning: implicit conversion from 'string' to 'number'
}
Now try to prove the opposite - also without a print! Naturally, prove it with an example, not with fantasies like "that's not what it says in the documentation - I know better".
Reason: