I find it easier to think of them as transforms which turn "a function which accepts/returns plain values" into a "function which accepts and returns a type which embeds plain values". map :: (a -> b) -> (t a -> t b) --…
It's not learning. The description says it does a maximal munch, which is obviously going to be wrong a lot of the time. Should probably use MeCab, which parses this correctly.
There's also function composition (h . g . f) x Or for LtR, with Control.Category (f >>> g >>> h) x Could combine with the forward pipe for x |> (f >>> g >>> h)
typedef struct { double value; int error; } maybe_double; Is most efficient on x86-64 SYSV, because the ABI supports the `error` being returned in a GP register (rax), and the `value` in a vector register (xmm0). When…
Returning 2 values can be more performant than returning one and assigning to another as an "out parameter". Eg: typedef struct { bool has_value; int value; } option_int_t; option_int_t foo() { if (somecond) return…
Sum types in the set theoretic approach can be made with `(A & ¬B) | (¬A & B)`, or equivalently `(A | B) & (¬A | ¬B)`. There's no mainstream language with negation types, but a few good research languages with them, eg…
If you do: typedef struct { int status; float value; } div_result_t; div_result_t divide(float a, float b) { if (b = 0.0) return (div_result_t){ E_DIVZERO }; return (div_result_t){ 0, a / b }; } On SYSV: The `status`…
That's an implementation choice. The standard makes no such guarantees. > An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, may not be correctly…
Partial register stalls occurred when you assigned something to say `eax`, then read `ax`, or vice versa - if you wrote `ax` then read `eax`. If you wrote to `ax` then read `ax`, there was no stall. This was due to the…
If you want to know how bad it can be, only need to take a look at GCC's implementation of `stddef.h` for `size_t` and `ptrdiff_t` etc. https://github.com/gcc-mirror/gcc/blob/master/gcc/ginclude/s... There's a simpler…
It's safe to dereference in the same thread. A `thread_local`'s actual virtual address is not merely what the pointer contains - it's an offset from some other virtual address stored in the FS or GS register (on…
Maybe you are talking past grandparent, but I think they meant "it's safe to assume float and double are IEEE-754," which is not mandated by the C standard.
`int` being 32-bits on amd64 was the correct decision, even in hindsight. If you are familiar with the ISA you will understand this. Existing 32-bit code just worked on the 64-bit chip, because the instruction encodings…
Yeah, in GCC for example, we can define exact width types without including `<stdint.h>`. typedef unsigned __attribute__((mode(HI))) uint16_t; typedef signed __attribute__((mode(SI))) int32_t; Of course, the mode needs…
Yeah, but my point is that two pointers can compare equal but point to different addresses, thus it's not necessarily a safe operation to dereference a pointer cast from `intptr_r`.
I think backward compatibility was the main aim. Intel tried redesigning the architecture as 64-bit native (Itanium), but AMD done a better job at backward compatibility - and intel eventually adopted it as x86-64. The…
> int is basically the signed version of size_t aka a word sized data type. It's not meant to have a fixed size. It isn't. `int` is at least as large as `short` and at least 16-bits. On modern systems `int` is still…
What is the size of a pointer though? On Intel 286 we had a 16-bit machine word and 24-bit addresses. A pointer wasn't just two machine words concatenated - the upper 8 bits were stored somewhere else - a segment…
PEGs aren't contained within the context-free languages, so it's not really intuitive that they're weaker, particularly as nobody has yet come up with a context-free language that a PEG cannot parse. They're capable of…
Worth looking into nested words aka visibly pushdown languages. They're a proper superset of regular languages and a proper subset of deterministic context-free languages, but they retain many of the nice properties of…
I made a mini example in C. It's awkward to do get right because you need an indirect pointer whose address remains fixed, but points to another pointer which can change (and is volatile). While it might be possible to…
I think parent was after base+offset+index rather than just base+index. Examples would be eg, `string_view` or `ArraySegment`. They hold some offset relative to a base allocation, and when we index the string_view or…
That's Fat pointers, not Far pointers. A fat pointer is a pointer with some other associated data which is stored in the pointer itself - typically by widening the number of bits used to hold a pointer value. The…
Far pointers are for accessing memory in different segments. They're basically obsolete now. They were necessary in older machines with limited sized pointers or address spaces. GCC still supports `__seg_fs` and…
The poorest in society are the lowest CO2 emitters - they don't fly often, many don't own a car and use public transport - they can't afford meat in every meal. Conversely, the wealthiest are frequent flyers, are…
I find it easier to think of them as transforms which turn "a function which accepts/returns plain values" into a "function which accepts and returns a type which embeds plain values". map :: (a -> b) -> (t a -> t b) --…
It's not learning. The description says it does a maximal munch, which is obviously going to be wrong a lot of the time. Should probably use MeCab, which parses this correctly.
There's also function composition (h . g . f) x Or for LtR, with Control.Category (f >>> g >>> h) x Could combine with the forward pipe for x |> (f >>> g >>> h)
typedef struct { double value; int error; } maybe_double; Is most efficient on x86-64 SYSV, because the ABI supports the `error` being returned in a GP register (rax), and the `value` in a vector register (xmm0). When…
Returning 2 values can be more performant than returning one and assigning to another as an "out parameter". Eg: typedef struct { bool has_value; int value; } option_int_t; option_int_t foo() { if (somecond) return…
Sum types in the set theoretic approach can be made with `(A & ¬B) | (¬A & B)`, or equivalently `(A | B) & (¬A | ¬B)`. There's no mainstream language with negation types, but a few good research languages with them, eg…
If you do: typedef struct { int status; float value; } div_result_t; div_result_t divide(float a, float b) { if (b = 0.0) return (div_result_t){ E_DIVZERO }; return (div_result_t){ 0, a / b }; } On SYSV: The `status`…
That's an implementation choice. The standard makes no such guarantees. > An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, may not be correctly…
Partial register stalls occurred when you assigned something to say `eax`, then read `ax`, or vice versa - if you wrote `ax` then read `eax`. If you wrote to `ax` then read `ax`, there was no stall. This was due to the…
If you want to know how bad it can be, only need to take a look at GCC's implementation of `stddef.h` for `size_t` and `ptrdiff_t` etc. https://github.com/gcc-mirror/gcc/blob/master/gcc/ginclude/s... There's a simpler…
It's safe to dereference in the same thread. A `thread_local`'s actual virtual address is not merely what the pointer contains - it's an offset from some other virtual address stored in the FS or GS register (on…
Maybe you are talking past grandparent, but I think they meant "it's safe to assume float and double are IEEE-754," which is not mandated by the C standard.
`int` being 32-bits on amd64 was the correct decision, even in hindsight. If you are familiar with the ISA you will understand this. Existing 32-bit code just worked on the 64-bit chip, because the instruction encodings…
Yeah, in GCC for example, we can define exact width types without including `<stdint.h>`. typedef unsigned __attribute__((mode(HI))) uint16_t; typedef signed __attribute__((mode(SI))) int32_t; Of course, the mode needs…
Yeah, but my point is that two pointers can compare equal but point to different addresses, thus it's not necessarily a safe operation to dereference a pointer cast from `intptr_r`.
I think backward compatibility was the main aim. Intel tried redesigning the architecture as 64-bit native (Itanium), but AMD done a better job at backward compatibility - and intel eventually adopted it as x86-64. The…
> int is basically the signed version of size_t aka a word sized data type. It's not meant to have a fixed size. It isn't. `int` is at least as large as `short` and at least 16-bits. On modern systems `int` is still…
What is the size of a pointer though? On Intel 286 we had a 16-bit machine word and 24-bit addresses. A pointer wasn't just two machine words concatenated - the upper 8 bits were stored somewhere else - a segment…
PEGs aren't contained within the context-free languages, so it's not really intuitive that they're weaker, particularly as nobody has yet come up with a context-free language that a PEG cannot parse. They're capable of…
Worth looking into nested words aka visibly pushdown languages. They're a proper superset of regular languages and a proper subset of deterministic context-free languages, but they retain many of the nice properties of…
I made a mini example in C. It's awkward to do get right because you need an indirect pointer whose address remains fixed, but points to another pointer which can change (and is volatile). While it might be possible to…
I think parent was after base+offset+index rather than just base+index. Examples would be eg, `string_view` or `ArraySegment`. They hold some offset relative to a base allocation, and when we index the string_view or…
That's Fat pointers, not Far pointers. A fat pointer is a pointer with some other associated data which is stored in the pointer itself - typically by widening the number of bits used to hold a pointer value. The…
Far pointers are for accessing memory in different segments. They're basically obsolete now. They were necessary in older machines with limited sized pointers or address spaces. GCC still supports `__seg_fs` and…
The poorest in society are the lowest CO2 emitters - they don't fly often, many don't own a car and use public transport - they can't afford meat in every meal. Conversely, the wealthiest are frequent flyers, are…