When concrete statement

Hi,

  I saw in the typesystem when concrete statement, which executes the body statement list when expression in the parameter becames a concrete type. From here appears question - what is concrete type? Consider the following case (Test project in the attachment). I have concept "Assignment",  which declare some variable of type with initial value, concept "TypeAssignment", which can provide additional type, that extends already defined types or primitive types and concept "TypeReference", which provides using of self defined types (in other words just references to the TypeAssignment).

I thought that concrete types are only primitive types and not concrete types in my case must be all "TypeReference" types. But this opinion is wrong. What is "concrete type" in the fact?

P.S. Look at the typeof_Assignment



Attachment(s):
Test2.zip
1 comment
Comment actions Permalink

Hi Oleg

Concrete types are those types which do not contain type variables inside them. That types which are not type variables but contain some type variables within are called "shallow concrete" types. During a types computation process, types calculated so far e.g. returned by typeof may or may not be concrete, no guarantees given.

"When concrete" statement is a kind of listener on a type, which performs its body when an observed type becomes concrete. You can set in this statement's inspector whether you mean fully concrete or shallow concrete types.

Such a statement is useful when equations and ineqs are not enough for someone, e.g. one wants to inspect directly an inner structure of a certain type. For example, in Java you can't choose which type, numeric or string to use as a type of an expression a + b before types of a and b are fully calculated, and this dilemma is not expressible with equations or ineqs. So first typeof(a) and typeof(b) shold become concrete and only then a type of result may be selected.

In most cases, however (so in yours, too), you do not need this statement because equations and ineqs are pretty enough.

Even in some cases which may appear to be complex, such as type of, say, ternary operator ( cond ? ifTrue : ifFalse), one has no need to inspect types of its parts and simply writes something like

typeof(op) :>=: typeof(ifTrue)

typeof(op) :>=: typeof(ifFalse)

and the type engine deduces types fine.

Regards,

Cyril.

0

Please sign in to leave a comment.