|
|
|
|
|
by beagle3
4453 days ago
|
|
Well, it is kind of pointless to look at the K<->C interface without knowing K. If you read the Python.h it would be about as understandable (assume you don't know what a "class" is when studying the Python.h file - because K does a lot of things in ways different enough from most languages). To elaborate: K uses one letter mnemonic codes for all of it's basic storage types: G = General = 8-bit unsigned int
H = sHort = 16-bit signed int
I = Integer = 32-bit signed int
J = bigger integer = 64-bit signed int
(Note how G,H,I,J follow each other?) E = 32-bit floating point "rEal"
F = 64-bit Floating point
(Again, they are near each other) S = Symbol
K = "general list type", the central K language type
And that's mostly it; the last unnamed union (with fields "n" and "G0") is for vectors, n being the length and G0 being the data.The only other field you are ever going to need is "t" for type (saying whether which union member is actually in use). The rest are internal implementation details, but are also easy to remember: r=reference count; u=flags; m and a have something to do with memory mapping and allocation). There are a few more basic types: b=boolean, t=time,d=date,p=datetime,u=month - but they are merely different interpretations of the EFGHIJSK members above; to access data from C, all you need is the list given above. |
|
My thoughts on this area have changed a bunch, I think when I was young I was a lot more about cleverness and conciseness.
Now that I'm older and I've worked on a large variety of software systems, I am starting to believe that readability of code is one of the most important values. After all, you read the code a lot more than you write it.
I can say definitively that: - i have often regretted using single letter variables (outside of loop 'i') - I have very regretted using non-descriptive names - I have never regretted using longer variable/method names
Now a days in an IDE environment, longer names doesn't even convey a typing penalty. Yeah yeah I know Java, but it's a safe language, and in a world where I want to deliver working, correct, bug free code, safety is more important than single letter expressiveness.
After all, I don't think people hold up APL as good code.