Feature #17

Allow the definition of aliases of types.

Added by Alain Prouté over 10 years ago. Updated over 9 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:Alain Prouté% Done:

0%

Category:Compiler
Target version:1.x
Platform: Triage Stage:
Resolution:

Description

Allow the definition of aliases of types.

History

#1 Updated by Cédric RICARD over 9 years ago

Can we have a little more explanations about this enhancement, please?

How should it works? What is the benefit compaired to a form like :

define [[ChildType]]:
  child_type(ParentType).

#2 Updated by Alain Prouté over 9 years ago

If you write:

type ChildType:
child_type(ParentType).

what you get is a 'clone' of ParentType which is distinct from ParentType. On the contrary an alias is just another name for the same type.

Of course, this is an important distinction since the compiler determines one and only one type for each term.

#3 Updated by Cédric RICARD over 9 years ago

Alright, but what are the benefits ?

In my mind, a great enhancement can be performances, but only if a clone can't be used in place of the original (in other words, they are different types with same definition).

Example. With the form

define [[ChildType]]:
  child_type(ParentType).

the use of ChildType will create some (useless) overload because to access to the value, we need to extract the parent type. If the compiler known this is a clone, It will be able to do some optimisation and make value access as efficient as the parent (or original) type because their are exactly the same in memory.

#4 Updated by Alain Prouté over 9 years ago

The optimization is another problem (not yet solved). I spoke only about semantics. The 'feature' of aliases is that we may use a simple short name instead of a complicated schema applied to several types which may themselves be schemas applied to etc... This is just for comfort, readability, and maybe also a conceptual enhancement. This is still to be discussed. Anyway, aliases are not implemented yet.

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux