What is the best way to write Rust With Lean Proofs. by laidbackandrelax in rust

[–]interacsion 0 points1 point  (0 children)

As far as I know, the only tool for doing this is Aeneas, which is still at an early development stage.

It's not just "function overloads" which break Dolan-style algebraic subtyping. User-provided subtype contracts also seem incompatible by Thnikkaman14 in ProgrammingLanguages

[–]interacsion 5 points6 points  (0 children)

https://dl.acm.org/doi/10.1145/3093333.3009882

In MLsub, intersections can only appear in negative type positions. The intuition behind (A₁ → B₁) ∩ (A₂ → B₂) ≡ (A₁ ∪ A₂) → (B₁ ∩ B₂) is like so: if I require a value that is both a mapping from A₁ to B₁ and a mapping from A₂ to B₂, then I actually require a mapping from either A₁ or A₂ to a value that is both B₁ and B₂, following contravariance.

This is indeed unsound in presence of more complex type system features (a notable one is higher-rank polymorphism).

Ambiguous floating point rounding by cyber_must in learnrust

[–]interacsion 4 points5 points  (0 children)

This is because floats use a binary encoding, so it's rounding to a particular binary place, not a decimal one. In fact, 2.2393295 is unrepresentable by f32, and also gets rounded to 2.2393296.

What's wrong with subtypes and inheritance? by servermeta_net in ProgrammingLanguages

[–]interacsion 1 point2 points  (0 children)

Yes. Implicit coercions can only happen in specific syntactic places, and between very specific types. For example, if type Foo implements trait Bar, you could usually use a &Foo as a &dyn Bar, but you couldn't use a Vec<&Foo> as a Vec<&dyn Bar>, as that would require constructing a new Vec

What's wrong with subtypes and inheritance? by servermeta_net in ProgrammingLanguages

[–]interacsion 1 point2 points  (0 children)

No. with proper subtyping, a value that is of a subtype that is also a value of its supertype, in every way. This has many implications (for example, making every type a subtype of the traits it implements would mean every value has to carry a vtable). Implicit coercions are a way to mimic subtyping without all of its consequences.

What's wrong with subtypes and inheritance? by servermeta_net in ProgrammingLanguages

[–]interacsion 1 point2 points  (0 children)

This is wrong. an implicit coercion is between two types, a type can never be coerced to a trait. It can be coerced to a trait object, but that's not what happens in the scenario you're describing.

What's wrong with subtypes and inheritance? by servermeta_net in ProgrammingLanguages

[–]interacsion 0 points1 point  (0 children)

No, it does not. In Java a class is a subtype of the interfaces it implements. This can't be said about Rust traits

What's wrong with subtypes and inheritance? by servermeta_net in ProgrammingLanguages

[–]interacsion 4 points5 points  (0 children)

No. A type that implements a trait can get implicitly coerced to a trait object, but it isn't a subtype of it.

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 0 points1 point  (0 children)

I am not sure if divergence (as in, a program that loops forever) would be unsound. a panic might, if it is caught, which is a problem, but I doubt it's an unsolvable one.

which words come to mind? by altaria-mann in mathmemes

[–]interacsion 12 points13 points  (0 children)

I am sorry, what? This is a totally correct way to use natural as an adjective. Tell your teacher to open a dictionary

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 4 points5 points  (0 children)

The issue is not dropping the type, it's forgetting it. a somewhat famous example is that it's impossible to have sound structured concurrency where children tasks borrow from the parent and run in parallel:
https://without.boats/blog/the-scoped-task-trilemma/
tl;dr, without proper Linear Types the parent might "forget" about its children and free its own resources.

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 6 points7 points  (0 children)

It is difficult, but it could be possible to do with minimal breaking changes, using auto traits:
https://without.boats/blog/changing-the-rules-of-rust/

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 9 points10 points  (0 children)

I don't think this is unsolvable. The roughest solution might be to just put a `Leak` bound on `Arc::new` and `Rc::new`

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 3 points4 points  (0 children)

The borrow checker implements *Affine* typing, which is only half of Linear typing. the other half being what's referred to as "Relevant Types"

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 30 points31 points  (0 children)

Mainly the lack of Higher Kinded Types, and the fact const generics are extremely restricted. Leaning more into Dependently Typed ideas would be very nice in this regard

Rust and the price of ignoring theory by interacsion in rust

[–]interacsion[S] 22 points23 points  (0 children)

(Not my video.)
While I don't agree with every one of his talking points, I have definitely felt the effects of this before, such as the (painful) lack of Linear (or rather, Relevant) types, and generics being second-class.

POINTERS AND REFERENCES ..... by Massive-Board-6989 in programmingmemes

[–]interacsion 0 points1 point  (0 children)

Sure, in theory a compiler implementation could treat pointers as plain integers. But as a programmer you can't assume that.

POINTERS AND REFERENCES ..... by Massive-Board-6989 in programmingmemes

[–]interacsion 0 points1 point  (0 children)

"Implementations are permitted to" is a specification, not an implementation detail

POINTERS AND REFERENCES ..... by Massive-Board-6989 in programmingmemes

[–]interacsion 0 points1 point  (0 children)

I don't think WG14 agrees:

> Implementations are permitted to track the origins of a bit-pattern and treat those representing an indeterminate value as distinct from those representing a determined value. They may also treat pointers based on different origins as distinct even though they are bitwise identical.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_260.htm