« first day (368 days earlier)      last day (36 days later) » 

3:18 AM
0
Q: Why don't languages do automatic pimpl?

Tom HuntingtonI just profiled my template instantiations with https://github.com/microsoft/vcperf A lot of time is spent instantiating private members with types from the standard library templates std::map, std::tuple, std::variant, std::span. But there is a simple way to avoid this with the placement-new pim...

 
 
2 hours later…
5:15 AM
'placement new pimpl' should be called 'impl'
or maybe just 'padding'
 
 
5 hours later…
10:27 AM
fair
 
 
12 hours later…
10:26 PM
ocaml's polymorphic variants are way nicer then I was expecting
they're really handy for error propagation if you mix them with result and let*/let+
 
10:47 PM
there's no better way to error handle then weird CPS-like program transforms
 
10:57 PM
oh, there's let*/let+ in ocaml now?
 
as far as I know they started in ocaml, where have you seen them?
oh huh ok, they've only been in there since 2019, later then I thought
 
my ocaml is a bit old
 
fair
 
* and + for working with monads and applicative functors...
 
you can customize the type, but i use
let* : (a, b) result -> (a -> (c, b) result) -> (c, b) result
let+ : (a, b) result -> (a -> c) -> (c, b) result
quite handy
 
11:01 PM
this page needs one example
oh, I missed it
 
yeah i was about to say haha
the and functions confuse me, but the let ones are fairly simple
pretty much just CPS magic
 
for error propagation... you could just throw and catch? unless you miss haskell
 
doesn't account for the possibility of catching multiple errors at once, which is what i'm going for
(context: making a compiler)
imagine a compiler where you had to fix one name error at the top of a file in order to be able to see another one two lines down :P
also exceptions aren't tracked in types, which is kinda icky
 
11:20 PM
I thought you were using polymorphic variants because, just like non-checked exceptions, they never limit you to a fixed set of allowed errors in each function?
 
yep
but polymorphic variants are tracked in function signatures
 
oh... true
useful as documentation
 
let does_weird_stuff t =
    if t then `One 1 else `Two true

does_weird_stuff : bool -> [< `One of int | `Two of bool ]
yeah
 
then you have to find the right balance of, using inference to not have to update everything when adding a new error, vs not understanding the code anymore and getting awful type error messages because everything is inferred
 
mhm
generally i'm annotating like (concrete, 'a) result
so only the errors are inferred
which seems to work so far
something i will say is that let*/let+ generate awful errors
 
11:28 PM
@blueberry cool. I never realized it was that simple
 
yeah it's pretty neat
 
11:44 PM
typing paradigm: half-explicit
 

« first day (368 days earlier)      last day (36 days later) »