Post AQ8raMQ4XaPbRQWVQu by eris@merveilles.town
(DIR) More posts by eris@merveilles.town
(DIR) Post #AQ8pge6ZV2TA7ZGsoy by eris@merveilles.town
2022-11-30T14:54:40Z
0 likes, 0 repeats
reading http://blog.syncpup.com/posts/let-it-crash-under-attack.htmlBut with all that, as Joe Armstrong once jeered, no amount of type checking would catch the following bogus code:```maybe_write() -> {ok, U} = file:open("/path/to/file.txt", [write]), file:close(U), ok = file:write(U, <<"foo">>), ok.```im currently noodling with an idea for a PL where functions can 'consume' their parameters, making them unusable. this example would not work in such a PL; linear typing
(DIR) Post #AQ8pgeW5y8szOjDGbZ by ukko@p.enes.lv
2022-11-30T21:14:09.969167Z
0 likes, 0 repeats
@eris hmm, how similar would a linear type system checker be to, eg, rust's type system. if we take a fully immutable subset of rust we get only borrows & consumes which i think would be similar to a linear type system and i think mutable borrows would act similar if they exist. or am i missing something important? (this isn't meant to be a "just use rust" comment if it looks like it.)
(DIR) Post #AQ8q5bRIY1FV5prmPA by eris@merveilles.town
2022-11-30T21:15:19Z
1 likes, 0 repeats
@ukko rust's type system is complex, linearity is simple
(DIR) Post #AQ8q5cul3yPNfUeoxk by eris@merveilles.town
2022-11-30T21:17:14Z
1 likes, 0 repeats
@ukko in a purely linear type system, every value is used at most once, and nothing else
(DIR) Post #AQ8qKZyiGJNYuCdZKK by ukko@p.enes.lv
2022-11-30T21:21:24.530176Z
0 likes, 0 repeats
@eris Ahh, so no borrows at all? How would you perform a read from a file? Something like (char, file) <- read_char(file)?
(DIR) Post #AQ8qhvkxSQkj6rL1v6 by vaartis@pl.kotobank.ch
2022-11-30T21:24:31.704297Z
1 likes, 0 repeats
@eris actually someone did a C variant that did this, where functions returned consumable tokens, but I'll never be about to find it
(DIR) Post #AQ8qps8MoFocBw4fiK by ukko@p.enes.lv
2022-11-30T21:27:03.914017Z
0 likes, 0 repeats
@eris now that I look at this example I realise read_char actually does modify the file so this would actually be a more functional programming approach to it I guess. If you tried hard enough you could even create some generic monadic syntax here but that again gets too complex; perhaps something like Prolog's `-->` operator which I don't fully understand but I think is similar.Btw sorry for just throwing out random ideas @ you if they go in a completely different direction from what you originally intended
(DIR) Post #AQ8rT9j5Kt1M2wysVc by eris@merveilles.town
2022-11-30T21:33:20Z
1 likes, 0 repeats
@ukko fully linear type systems are unused; you have a property of linearity in functions in greater nonlinear type systems
(DIR) Post #AQ8rTV91hdFWTUHOMK by eris@merveilles.town
2022-11-30T21:33:39Z
1 likes, 0 repeats
@vaartis huh, feels like something vale or cyclone would do
(DIR) Post #AQ8rW3Gbo9CAsl2g76 by eris@merveilles.town
2022-11-30T21:34:09Z
1 likes, 0 repeats
@ukko im not after monads or complicated types
(DIR) Post #AQ8raMQ4XaPbRQWVQu by eris@merveilles.town
2022-11-30T21:35:00Z
1 likes, 0 repeats
@ukko this noodling is part of my idea for an 80% programming language: does things very well 80% of the time
(DIR) Post #AQp5HKe4TKjgQyD0C0 by thamesynne@dragon.style
2022-12-21T02:11:22Z
1 likes, 0 repeats
@eris @ukko *exactly* once. at most once is an affine type system.