rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Rename reifyType and reifiedType operators for better understandability

Open jurgenvinju opened this issue 2 years ago • 1 comments

Describe the bug

These two expression operators are confusing and their (static) semantics is sometimes unclear:

  • # Type
  • type(Symbol symbol,map[Symbol,Production] definitions)

This is their grammar rules in Rascal.rsc:

syntax Expression
	= ...
	| reifiedType    : "type" "(" Expression symbol "," Expression definitions ")"  
        ...
	| reifyType      : "#" Type type !>> "[" !selector

The enhancement proposal is to:

  • change their name in the syntax definition
  • fix all impacted source code in Rascal and Java downstream
  • also rename the operators in the documentation

We might start by only the documentation, but eventually we should fix the implementation names as well.

The renaming:

syntax Expression
	= ...
	| typeValue    : "type" "(" Expression symbol "," Expression definitions ")"  
        ...
	| typeLiteral   : "#" Type type !>> "[" !selector

and corresponding changes in the definition of Pattern.

The rationale is clear in itself:

  • type(Symbol,map[...]) is indeed a value representation of all Rascal types based on Symbol and Production, completely dynamic and so the static type is type[value]
  • and #Type is a special literal type version of the above, where the user gets the Symbol value representation for free and the type can be statically asserted to be as concrete as type[Type] for every #Type.

jurgenvinju avatar Jun 01 '23 10:06 jurgenvinju

IOW, the word "reify" does not carry as much meaning as one might expect ;-) "value" and "type" and "types as values" makes more sense IMHO. @PaulKlint @tvdstorm wdyt?

jurgenvinju avatar Jun 01 '23 10:06 jurgenvinju