3 ms·
Sure, but my point is that "Okay" things are not as good as "Great" things like spelled out type definitions. For example look at this object declaration in Ad
by 0xDEEPFAC 8y ago
Sure, but my point is that "Okay" things are not as good as "Great" things like spelled out type definitions.
For example look at this object declaration in Ada - you may not know Ada and the symbols associated with pointers but you will know exactly what it is:
type My_Arr is array (1..10) of Natural;
My_Fancy_Obj : not null access My_Arr :=
new My_Arr'(1..4 => 0, others => 1234);
- DonaldPShimoda 8y agotype My_Arr is array (1..10) of Natural; Speaking as someone who works in PL research (but keeping in mind that I'm still low on the totem pole, i.e., I don't have a PhD)... I don't know what this is supposed to mean. Based on the first word being `type`, I'm guessing this is a type declaration for a new type named `My_Arr`. And `is array` makes me think that this is an array of some kind. But then I get to `(1..10)` and I'm lost. Is this a dependent type? Is it an initialized value? I'm genuinely not sure. The `of Natural` at the end tells me that `My_Arr` is an array of natural numbers, I guess, but I'm lost on the `(1..10)` bit. I figure it could either be: a) `My_Arr` is the type of arrays of natural numbers of length 1..10 (is that inclusive? exclusive? unsure) or b) `My_Arr` is the type of arrays consisting of only the natural numbers 1..10 (again, unsure whether inclusive or exclusive) Or I guess it could be something else, though I'm not sure exactly what that'd be. My_Fancy_Obj : not null access My_Arr := ... I guess this is defining an... object? It can't be a type declaration because there's no `type` keyword (which I had previously assumed to indicate the beginning of a type declaration). But this syntax is strange. I assume `My_Fancy_Obj` is the name of the instance in question, so `x : y := z` must mean "create an object named x of type y and store the result of evaluating z there". (I'm guessing based on what I know of other languages.) `not null access` is weird to me. I mean, "not null" is straightforward enough (`My_Fancy_Obj` can never have a null value), but I'm not sure what "access" means. Is it a reference type? Like a pointer? Or something? I dunno what else it could be. So `My_Fancy_Obj` is really a box (reference/pointer) containing a `My_Arr`, and it can never be null. Now... looking at the initialization... ... new My_Arr'(1..4 => 0, others => 1234); I'm so lost haha. I guess the values 1..4 (inclusive? exclusive? shrug) are initialized to zero. And the "others" are initialized to... the value 1,234? I guess? But how long is this array? The presence of an `others` keyword (I'm assuming it's a keyword, or an initialization argument I suppose) tells me that it must be obvious to the interpreter/compiler exactly how many values there are. So... I guess that means `My_Arr` is actually an array of exactly length 10? Why on earth would they have the `array (1..10)` syntax for that, instead of like `array 10` or `array(10)` or something. That's confusing. So I guess we end up with something like `[0, 0, 0, 0, 1234, 1234, 1234, 1234, 1234, 1234]`? Anyway, this example did not achieve your desired result — at least, not from my perspective.
- 0xDEEPFAC 8y agoVery good, the code is not even valid indeed. Thanks for making me think :)
- DonaldPShimoda 8y agoNo harm meant, friend. :)
- Verdex 8y ago"type", "array", and "Natural" are all specialized computer science or mathematical terms. "My_Arr" is just as mysterious as the rest of them and unless you're familiar with variable binding, you'll just lump that symbol in with the rest of them (some unknown sigil of magical power). I suspect most people will have a good idea of what "is" is and of what "of" is. I bet most people would also understand ranges, so 1..10 is probably fine as well. So, what your first line should be if we were really spelling things out: classification definition named: "My_Arr" is: "list (1..10)" which will contain: "numbers zero and greater but without decimals" But you aren't spelling things out. You're using specialized terms to reduce the amount of typing you have to do because the terms in question happen to come up frequently. Welcome to the club.