Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
pansa2
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
14 ms
·
211.
▲
by
pansa2
1y ago
> Any access of memory using a union, where the union includes the effective type of the memory is legal. Consider: union { int i; float f; } *u; float f = 3.14; u = &f; x = u->i; > I
212.
▲
by
pansa2
1y ago
Pitfall was from Activision, not Atari
213.
▲
by
pansa2
1y ago
The Post Office will sell you US currency, but AFAIK not US stamps.
214.
▲
by
pansa2
1y ago
Yes, the next level of complexity is that `a + b` will sometimes fall back to `b.__radd__(a)` if `a.__add__(b)` returns `NotImplemented`. But also: - There are situations where `__radd__` takes priority over `__add__`. The rules for determi
215.
▲
by
pansa2
1y ago
This is one of the absolute worst design mistakes in Python. The example you give (that `a = a + b` and `a += b` aren't equivalent) is bad enough: >>> a = b = [1, 2, 3] >>> a = b = [1, 2, 3] &
216.
▲
by
pansa2
1y ago
Yeah, I think the walrus operator is occasionally useful in `while` statements, but that's about it. IMO it wasn't worth the additional language complexity for an operator that's so rarely useful.
217.
▲
by
pansa2
1y ago
> the walrus operator limits the variable's scope to the conditional Nope! It's still function-scoped. In Python, walrus or no walrus, the body of a conditional is never a separate scope.
218.
▲
by
pansa2
1y ago
> still a relatively simple language If only. I suspect very few Python programmers can even fully explain what `a + b` does. If `a` and `b` are instances of classes, many would say it's equivalent to `a.__add__(b)` or `type(a).
219.
▲
by
pansa2
1y ago
> And when you know of it -- and dislike it -- just keep doing it the way you did before knowing it. That breaks down as soon as you need to work with anyone else's code that uses the "fancy stuff".
220.
▲
by
pansa2
1y ago
> I have a feeling that if metaclasses and descriptors were to be proposed today it would be laughed out of the PEP process completely. I think you need at least one of these. Modern Python eschews metaclasses but descriptors are every
221.
▲
by
pansa2
1y ago
Looks like there’s a `mixed` type, variables of which can hold values of any type. But at least that’s something you can `grep` for. A more subtle issue with type hints (as in TypeScript/Python, not sure if this applies to Pike) is tha
222.
▲
by
pansa2
1y ago
Pike is described as a "dynamic" language, so I was expecting purely dynamic typing, yet the language uses Java/C-style variable declarations with explicit types. It seems that these are (unsound) type hints , years before T
223.
▲
by
pansa2
1y ago
> "<word> <word>" is only valid syntax if one is a reserved word. `nonlocal` is a keyword
224.
▲
by
pansa2
1y ago
While your code is a valid alternative way to implement @haberman's description, the feature is actually much more flexible. The "subsequent logic" has full access to the interpolation results and strings. Not only can it esc
225.
▲
by
pansa2
1y ago
I suspect: Julia's multiple dispatch means that all arguments to a function are treated equally. The syntax `b(a, c)` makes this clear, whereas `a.b(c)` makes it look like `a` is in some way special.
226.
▲
by
pansa2
1y ago
> [T-strings] are the pythonic parallel to JavaScript’s tagged templates.
227.
▲
by
pansa2
1y ago
Yes, Python 3.0 was released 17 years ago. But the transition from Python 2.x was only completed with 2.7’s end-of-life, 5 years ago.
228.
▲
by
pansa2
1y ago
Yeah, Python hasn’t been a simple language for a long time, if ever. That’s probably the biggest misconception about the language - that its friendly syntax implies simple semantics. It’s not true at all.
229.
▲
by
pansa2
1y ago
Yes that makes sense, thanks. Also, my comment was about the amount of boilerplate required, but that can be vastly reduced by writing `process_template` in a more functional style instead of the highly-imperative (Golang-like?) style used
230.
▲
by
pansa2
1y ago
I don't think things would be very different if Guido were still BDFL. He's second-author of the t-strings PEP, and has been an author of most other major PEPs in recent releases (including the walrus operator, PEG parser, and pat
231.
▲
by
pansa2
1y ago
> t-strings evaluate to a new type, `string.templatelib.Template` > To support processing, `Template`s give developers access to the string and its interpolated values before* they are combined into a final string.* Are there any
232.
▲
by
pansa2
1y ago
One difference is that Python's type system is unsound. You can write code that passes `mypy --strict` but still contains functions that, for example, claim to return an `int` but actually return a `list` [0]. AFAIK it's not possi
233.
▲
by
pansa2
1y ago
Interesting, thanks!
234.
▲
by
pansa2
1y ago
Are there any other programming languages designed by Pontifical Catholic Universities?
235.
▲
by
pansa2
1y ago
Yeah, that's a common argument for dynamic typing. You're writing tests anyway (right?), and those will catch type errors and many other kinds of error. Why bother with a separate level of checking just for type errors? I personal
236.
▲
by
pansa2
1y ago
> somebody decided that with Python 3.13 there would be no more precompiled wheels of numpy < 2 Wow. NumPy 2.0 was released less than a year ago and they're already starting to drop support for 1.x?! It only supports Python ver
237.
▲
by
pansa2
1y ago
Yeah, this presentation by Roberto Ierusalimschy (one of Lua's three authors) lists over 50 games that use Lua (slide #9): https://www.inf.puc-rio.br/~roberto/talks/curryon2017.pdf
238.
▲
by
pansa2
1y ago
It might be. CPython doesn't support sandboxing Python code, so the only option is to run the whole interpreter within a sandbox.
239.
▲
by
pansa2
1y ago
Bottom-left corner
240.
▲
by
pansa2
2y ago
Bottom-left corner
More ›