HN user

bgschiller

45 karma
Posts8
Comments19
View on HN

I'm trying to make a spreadsheet interface for solving scheduling problems.

Constraint satisfaction and optimization is exactly the sort of problem we should be using computers for, but there's zero chance your neighborhood cafe can figure out prolog or OR-tools or whatever.

E.g. I couldn’t for the life of me annotate the return value of the pipe function

Don't feel bad, no one can do that (yet! I think it should be possible with Variadic Tuple Types, coming in TS 4). There are a couple of attempts[1][2], but they all lack in some way. Redux does it with a boatload of overloads [3].

1: https://dev.to/ascorbic/creating-a-typed-compose-function-in...

2: https://stackoverflow.com/a/53066700/1586229

3: https://github.com/reduxjs/redux/blob/686d29b5d4e2dcb6709c16...

I think you might be underestimating how hard breastfeeding is pushed in US hospitals. Our second night in the hospital with my son, my wife's milk hadn't come in yet.

Our son was screaming because he was hungry. The nurse kept saying this was good, that it would encourage breast milk production. It took several tries to convince her that, while it might be good in the long run, we needed some food for this baby.

This was a consistent experience with all nurses we dealt with. Interestingly, breastfeeding specialists tended to be more understanding.

I think I'm confused. If you want to delegate _everything_, why not just actually use inheritance? Or even the object itself. What's an example of when you would want an ObjectProxy?

Definitely agree about metaclass magic being a blessing and a curse. That superdelegate library was fun to write and uses a metaclass to make the API pleasant.

I also found myself doing that pretty often, so I wrote this:

    def nget(d, *ks, **kwargs):
        for k in ks:
            d = d.get(k)
            if d is None:
                return kwargs.get('default')
        return d

   >>> d = {'a': {'b': {'c': 12 }}}
   >>> nget(d, 'a', 'd', 'c', default='Not Found!')
   'Not Found!'
   >>> nget(d, 'a', 'b', 'c')
   12