Generics: Difference between revisions

From Adam Colton
Jump to navigation Jump to search
Created page with "I dislike the term generics - it's over broad. But I'll put this here until I can resolve some of the conceptual collisions. == Interface Substitution == See Interfaces. ..."
 
No edit summary
Line 8: Line 8:
   int<6>
   int<6>


The reason why it's not necessary is that if the call is:
  int.new(6)
then at compile time we'll see that it's static and substitute the response.
The reason why we do need it is that
  var x int<6> = 123456
is a type and it can't be substituted with a different size
  x = int<4>(555) // error
But this collides the concept of interface substitution.


[[Category: Gryphon]]
[[Category: Gryphon]]

Revision as of 12:39, 23 September 2019

I dislike the term generics - it's over broad. But I'll put this here until I can resolve some of the conceptual collisions.

Interface Substitution

See Interfaces. This is the primary form of generics.

Values

I want to be able to do something like:

 int<6>

The reason why it's not necessary is that if the call is:

 int.new(6)

then at compile time we'll see that it's static and substitute the response.

The reason why we do need it is that

 var x int<6> = 123456

is a type and it can't be substituted with a different size

 x = int<4>(555) // error

But this collides the concept of interface substitution.