Forum > General

Some observations on the use of RTTI

<< < (3/14) > >>

egsuh:
Ah I see. There were explanations already.

Warfley:

--- Quote from: Thaddy on October 08, 2024, 09:50:31 am ---That is explained higher up in the wiki and in my comments of the complete wiki example too: you can omit the attribute suffix part. One usually does.
The code is correct.
Clear? Otherwise, please ask what is not clear. This is also Delphi compatible.

--- End quote ---
My question to this would be, if people are to lazy to type out ADateTimeAttribute, why name it ADataTimeAttribute and not just ADateTime to begin with? Code should not enforce naming conventions, the programmer should chose the names they seem fit and the compiler should not interfere with that by introducing new names for things without them being specifically declared.

Or to put it in a different way, the compiler should not silently add new symbols because it thinks it can do naming better than the programmer

Thaddy:
The attribute post-fix is (seems) only necessary to distinguish between a normal class and an attribute class
The attribute class has some special handling (like I showed with the multiple constructors).
As I understand it, it is to recognize an attribute, and how to interpret it:
[ADateTime] vs [ADateTime(DateTimeValue)] in my example reference the same attribute class.
The compiler knows it is an attribute class and based on how the attribute is declared it calls the proper constructor.
You do not instantiate an attribute class manually. That happens at runtime or compile time.
An Attribute needs not to be ever used and is only created when it is referenced.

Warfley:
Well... I don't think it's a good idea to have semantic embedded in naming conventions. Because in the end it should just be that, a convention. Also it should be mentioned that this is a complete novum for Pascal, there is not a single feature that implies semantic from naming. You can write your programs in any (natural) language (using define macros you can even translate keywords). If you impose meaning to the names, you also impose english as base language for your identifiers.
Especially as Attribute is a very common word that you may call your classes that just by "accident".

I mean the clearest way of doing that would just be a syntax feature:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TMyAttribute = attribute class ...Or to not introduce new keywords, a synonym for "attribute" would be property, so adding something like this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TMyAttribute = property class ...would be completely trivial to add to the parser (like <10 lines of code to be added to the FPC kind of trivial)

I don't see any advantage in utilizing the naming scheme over something like above, and but I see tons of disadvantages

Thaddy:
It is also the proverbious Delphi compatibility..

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version