Forum > General

Generic primitives, generic records.

(1/4) > >>

Wodzu:
Hi, is it possible to create something like this:


--- Code: ---type
  T3DPosition = record
    X: _T;  //instead of T any primitive type f.e. Single, Double, Integer...
    Y: _T;
    Z: _T;
  end;

var
  Pos1, Pos2: T3DPosition;

begin
  Pos1.X := Pos1.X + Pos2.X; //X is any single primitive
end;
--- End code ---

Do you catch my drift? ;)

azagaros:
My suggestion is learn Object Orientated programming.  You can do this with OOP tricks of Free Pascal.  I don't remember the exact code.. I can do this in C++ easily, another OOP language, even with overloaded operators and Run time information.

Wodzu:
This is not an answer for my question.

But thanks anyway, I've never laugh so much reading "technical" post.  :)
Especially the part with C++ (totaly irrevelant  :o) and RTTI (even if FPC would publish it for records(!) that would be so ineffective).

So in other words, everything is easy but you don't remember the exact code :)

Are you a forum troll or something?

Ñuño_Martínez:
Wodzu: I don't understand. Your code is a valid record and will compile without problems (if _T was previously defined ;) ) so, what are you actually asking for?

Batuhan:
use 'variant' instead of _T

http://www.freepascal.org/docs-html/ref/refsu18.html#x46-520003.7.1

Navigation

[0] Message Index

[#] Next page

Go to full version