3 ms·
That doesn't match my experience with the usage of a labeling or prefatory colon (continuing with my ad hoc terminology). I'd read it as Here's an x: X. – whi
by agalunar 3y ago
That doesn't match my experience with the usage of a labeling or prefatory colon (continuing with my ad hoc terminology). I'd read it as
Here's an x: X.
– which is nonsensical (the type X is not an example of the instance x; indeed, it's the other way round), or as
It's the case that x: more detailed things that explain or follow from x are X.
– which is also backward (since a type is a more general thing than one of many specific instances of the type), or as
Here's a quick premise x: the main point is X.
– which is wrong because x is more relevant (because it's a local variable, whereas X is likely global and shows up in many places; indeed, within a particular scope many variables may simultaneously have the same type, but a name refers unambiguously to a particular variable), or as
Label x: thing X.
– which is wrong because x is not a name for X.
- sophacles 3y agoYou are telling the compiler: Set aside a chunk of memory x. Use the details you call X for operations with it. The computer itself doesn't know anything about types or anything else - its just some detail for the compiler to use while generating instructions. A type isn't a thing - it's not an object. It's just a set of constraints that detail valid and invalid uses for the variable.
- agalunar 3y agoWe may simply differ here – for me, types are as real as objects. Or, perhaps more accurately, types are as illusory as objects ^_^
- teo_zero 3y agoI always read the colon as separating a term (introduced for the first time) and its definition. Just compare the characters list in literature: Hercule Poirot: an investigator Linnet Doyle: a rich heiress ... with the list of variables at the beginning of a function: x: TypeX y: TypeY It makes perfect sense to me.
- agalunar 3y agoI think I would completely agree for you if it were a definition and not a type annotation! That is, "x: 5" instead of "x = 5" (or "x ← 5", &c) looks fine to my eyes. And of course, that's how values for the members of a struct are in fact defined in many languages (such as Rust). I suppose the underlying point is that has-type is a relation, not a definition. Asymmetrical space around a binary relation violates (my) experience, but it's also a bit confusing to use the same syntax for definition and type annotation.
- teo_zero 3y agoYou may have a broader scenario in mind, but my experience is limited to languages like Rust and C where the type is linked to an object the moment that object is declared for the first time, and can't be changed later. These languages do use the same syntax for definition and type annotation. I will remember this conversation when I encounter a language that allows this (declaration in the first line, type annotations follow): var x x : Integer x = 5 ... x : String x = "hello"
- deleted 3y ago[deleted]