vjovanov / papers

Papers of Vojin Jovanovic.
http://vjovanov.com
0 stars 0 forks source link

All functions should be polymorphic in binding-time up to static :) #9

Open vjovanov opened 9 years ago

vjovanov commented 9 years ago

In the implementation a result of a static function that has dynamic parameters is promoted to static if applied with all static stuff. E.g:

((1 + 2): static Int)

How do we express this desugaring?

densh commented 9 years ago

I don't think that what you are saying is sound.

val x: dynamic Int = 2
val f: static (static Int => dynamic Int) = (y: static Int) => x + y
f(1)

You can not just promote result type here.

vjovanov commented 9 years ago

Yes it is, if the function is pure. You want all you functions without parameters to be either all static or all dynamic in the type.

if you have a dot function you do not want to promote stuff to inline I suppose:

dot(Vector(1,2,3), Vector(1,2,3))

should work since Vector is statically known.

densh commented 9 years ago

Look at the example I've given, it's unsound. x can come from anywhere, you might not be able to compute it, dynamic stuff doesn't have to be pure.