HN user

artikae

8 karma
Posts0
Comments9
View on HN
No posts found.

A Gc<T> that can't give you a pointer inside seems almost unusable in the context of Rust. Pointers are not a narrow use case; references are pointers.

Rust APIs are largely built around references. If you were to put a Vec<T> (dynamic array) into a pointerless Gc<T>, you would be almost entirely unable to access its contents. The only way to access it would be swap it with an empty Vec, access it, then swap it back a-la Cell. You wouldn't even be able to clone the Vec without storing a dummy version in its place during the call.

https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#m...

Fstrings.wtf 1 year ago

those only apply to arrays of primitives

I guess you've not written much python, or just not used any custom types in lists if you have.

    class Thing:
        def __init__(self, a, b):
            self.a = a; self.b = b
        def __eq__(me, them):
            return me.a == them.a and me.b == them.b
    >>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hi")]
    True
    >>>[1, 2, Thing(6, "Hi")] == [1, 2, Thing(6, "Hello")]
    False

In this case, the builtins are syntax, namely the `==` operator. There's a uniform syntax for comparing two objects for equality.

Are you blind or using Orca to interact with your computer? If the answer is no, then your recent experience with Debian is not particularly relevant to what the article is talking about, since you obviously wouldn't have run in to any of the issues discussed.

assoc-in reminds me a lot of lenses in Haskell. I figure you could probably implement something like it using them. This is what I came up with:

  import Control.Lens
  baseLens --> nextIndex = baseLens . ix nextIndex
  assocIn structure keyLens newValue = set keyLens newValue structure
It works like so:
  setTo256 structure = assocIn structure (ix 0 --> 0 --> 0) 256
  -- setTo256 [[[1]], [[2]]] returns [[[256]], [[2]]]

All it takes for something to be replaced is something that does the job better. You can only really apply your definition in hindsight, after something has stood the test of time. You can't tell the difference between sails and wheels until after the rise of the steam engine.