Type Info Read and manipulations

BlitzMax Forums/BlitzMax Programming/Type Info Read and manipulations

Hardcoal(Posted 2012) [#1]
Hi.
is there a way to get info about a type
for example how many fields there is...

what type of manipulations can you do over a type.

can you delete a field.
add method..
get field size etc...

anything.. is weclome


Yasha(Posted 2012) [#2]
You can do this sort of thing with reflection... but in almost all cases, you're better off achieving what you want in a different way. Reflection is a bit of a hack, when you could be solving this problem at the design level (it's not magic, it won't actually unlock magical easy-syntax or anything).

If you really have to have dynamic objects with varying slots and different numbers of methods, you might want to investigate the possibilities offered by something like TMaps or function pointers instead.


Hardcoal(Posted 2012) [#3]
please can you explain me what reflection means?


BladeRunner(Posted 2012) [#4]
take a look into your bmax-docs: brl.reflection
It is a module which allows alternation of types at run-time.
As said above there are not many cases in which this really desirable.


Hardcoal(Posted 2012) [#5]
tnx blade and yasha.

one more issue that boders me.

danny:vals = new vals
goerge:vals=new vals

type Vals
field x
field y
field z
field etc...
end type

is there a one command way to copy all fields of danny into goerge?

instead of doing goerge.x=danny.x gorege.y=danny.y etc...

Last edited 2012


col(Posted 2012) [#6]
HIya,

No you have to do it manually if you want seperate instances with the same data. You can make own 'command' method to do the job and call that :-



Last edited 2012


Hardcoal(Posted 2012) [#7]
ok tnx col


BladeRunner(Posted 2012) [#8]
You Could Use Memcopy, too, but I would not go over that bridge with very complex Types as it is likely to break the Garbage collector.