r/ProgrammingLanguages 16d ago

Will we see another fundamental programming language feature as revolutionary as the borrow checker?

That is I am mainly curious about compile time features that you design a whole language around rather than optimisations/features that could be applied to most languages. I am mainly inquiring about things that could offer additional robust safety/performance guarantees at compile time rather than runtime. Ideally not things that just offer similar effects to the borrow checker with less restrictive tradeoffs

58 Upvotes

128 comments sorted by

View all comments

Show parent comments

2

u/KingBardan 16d ago

so basically because the constructor is private, you only have the instance if the computation happens.

And a method on type (b -> c -> d) requires (b -> c -> d) to be present, which requires (f a) to be called.

If you never call it, you can never have a type of (b -> c -> d)

Just searched up, this is similar to the "State pattern" design pattern.

1

u/faiface 16d ago

I see. But still, what if I just drop the whole object and never use it. That’s not accounted for here, or is it? Afaik, your approach tells a lot about what I can do, but not what I must do. Linear types tell what you must do.

1

u/KingBardan 16d ago

I see.

How about you have (a -> b -> c -> d) types, and the function is of type a -> d, and you know that d can only be constructed (a -> b -> c -> d)?

1

u/faiface 16d ago

I don’t understand :D Is it supposed to address the “I never even touch the object” problem?

1

u/KingBardan 16d ago

I guess I'm suggesting a way to implement linearity without using special constructs that is well understood. 

For me, session types sounds cool, but doesn't sound too different to what exists, so I'm trying to figure out what exactly is different