Island RTTI support?

A newbie question -
Any RTTI support with Island? Which part of the RTL code should I peek?

Also any Delphi TValue equivalent? That is, an object( record) container that can be cast to different types?

there’s fairly extension rtti info. It’s all located in Type.pas.

Not being very familiar with the Delphi post-d7 work, what is TValue?

TValue is a record that can contain “any” data, and cast back and forth from different types.
http://docwiki.embarcadero.com/Libraries/XE2/en/System.Rtti.TValue

Basically I am looking for something similar with Island/Oxygene, particularly, something like below (Delphi code)

function TValue.TryAsType<T>(out AResult: T): Boolean;
var
  val: TValue;
begin
  Result := TryCast(System.TypeInfo(T), val);
  if Result then
    val.Get<T>(AResult);
end;

class function TValue.From<T>(const Value: T): TValue;
begin
  Make(@Value, System.TypeInfo(T), Result);
end;

I don’t believe we have something like this right now, no. Can you give me a concrete use case what you’d need this for?

I think the problem is TValue is everywhere in Delphi. So it’s difficult to get rid of it. But that is because in Delphi not everything is an Object, like in Island or .Net. So I don’t think TValue is really needed, we have Object, and can assign everything to it and then cast it back. It would be nice to have the exact same TValue to pass values from/to Delphi, but that’s impossible, since TValue rely on Delphi’s own RTTI typeinfo.

By the way, case X type of should be in a better place in the docs (If it is somewhere, I’m unable to find it), it’s a little gem.

@joseasl
Thank you for the heads up.

So basically I can use Object as a container for types, including primitive types such as integer, double etc?

@mh
I need a unified “generic” converter, so I can convert a string value read from XML to a designated type, something like
Concert(aValueStr: String): T

Any advice?

Yes.

we don’t currently have anything like that. We do have the Convert class that can turn types into other types though, which might be good enough.

Making a note, thanx! Case Statements is on a long list of Oxygene topics I have yet to update (soon). Types and Members are done, Statements and Expressions are half done (some missing but on the list, some not fully written, like this one). Those two sections are next on my docs list.

By the way, what order does the search in docs follow?
It usually shows me Cirrus related things first, then any number of articles where that word is present, and deep down the topic that is an exact match to what I was looking for.
I’d prefer either alphabetic, or, better, the articles where the search term is in the title.

@ck?

@ck is gonna hate me… more :sweat_smile:

1 Like

It uses a search indexer with the relative position in the file as one of the keys for finding it. So yeah, having it in the title moves it up in the list.

Then there is something wrong here


See where is the scrollbar, I typed case. I guess a lot of occurrences inside the article are more valued that on in the main title.

Search should be a lot better now: https://docs.elementscompiler.com/Oxygene/Expressions/Case/#q=case

*you might have to force refresh it.

1 Like

Indeed, it wasn’t even trying to request the results online. Much better now, thanks.