« first day (492 days earlier)      last day (145 days later) » 

00:31
Python has Union[T, U, ...] rather than T | U | ... which makes me wonder if Union[T, Union[U, ...]] is treated differently... then again, the annotations are just an IDE hint and mean nothing at runtime
00:46
Python has Union[T, U, ...] as well as T | U | ..., and nested unions collapse to their members
They are retrievable at run time now, so you actually can make them semantic when you want to
 
9 hours later…
09:48
0
Q: How does the tokenizer in the C-like languages (having both labels and ternary conditional operator) know whether `:` belongs to a label or the `?:`?

FlatAssemblerSo, today, I've added the support for the ternary conditional operator ?: to my PicoBlaze assembler written in JavaScript. Very soon, I ran into a problem: how to explain to the tokenizer that : is sometimes a part of a label (so that label: should be one single token) and sometimes a token by it...

 
12 hours later…
21:37
@MichaelHomer I tried T | U the other day and got an error for calling a method that didn't exist
(Keep in mind I'm stuck on 3.9 for now)
% python3
Python 3.9.6 (default, Dec  7 2023, 05:42:47)
[Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x: int | str = 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for |: 'type' and 'type'
Though I just tried it on a different machine that has 3.10 and it worked, so TIL
yeah that overload is a newish feature
22:14
>>> def f(x : int | str | (bool | int)): pass
...
>>> f.__annotations__
{'x': int | str | bool}
Oddly typing.Union[x,y] and x | y are still different types for reasons I don't understand, but they're mutually compatible
 
1 hour later…
23:29
Today I learnt how powerful echo is.

« first day (492 days earlier)      last day (145 days later) »