by tlack on 11/7/24, 3:17 AM with 71 comments
by openasocket on 11/7/24, 2:31 PM
append([], List, List).
append([Head|Tail], List, [Head|Rest]) :- append(Tail, List, Rest).
Is a simple list append function: append(X, Y, Z) is a predicate that match if Z is the list of all elements of X, followed by all elements of Y. You can use it to concatenate lists, of course. But you can also use it to confirm that a particular list start with a particular sequence, or ends with a particular sequence! The idea that the same predicate can be used in multiple different ways is really fascinating to me. I have no idea to what extent that would scale in a large system, but it's very interesting
by skrebbel on 11/8/24, 3:52 PM
by benreesman on 11/8/24, 12:36 AM
Neither of these implementations is going to be displacing absl::btree_map or std::sort any time soon, but I do feel we have a lot of “room at the bottom” for making simple and elegant code practical on real machines.
[1] https://stackoverflow.com/questions/7717691/why-is-the-minim...
Edit: replaced poorly formatted code with SO link.
by skybrian on 11/7/24, 7:13 PM
Compare with a Promise. If you can check whether it resolved, you can see it mutate. If the only operation allowed is to await it then from the code’s point of view, it might be considered an immutable reference to the pending result.
by anfelor on 11/7/24, 2:26 PM
by p4bl0 on 11/7/24, 1:05 PM
by ks2048 on 11/7/24, 8:22 PM
by jfmc on 11/7/24, 2:05 PM
by tolerance on 11/7/24, 3:29 PM
by samweb3 on 11/7/24, 2:45 PM
by lelag on 11/7/24, 12:47 PM
[1] https://shchegrikovich.substack.com/p/use-prolog-to-improve-...
by bedobi on 11/7/24, 3:38 PM
data class IncompletePerson(val name: String)
data class Person(
val name: String,
val email: String
)
or data class Person(
val initialAttributes: IncompletePerson,
val email: String
)
if you want to nest it.if you're the type to instead do this
data class Person(
val name: String,
val email: String?
)
I never want to work with your code. Now, there's no disambiguation between the complete object and the incomplete one, I always have to check before doing anything with it, and people will inevitably try send an incomplete object someplace that can't handle it and generate bugs.