Changeset 4c8f29ff for doc/theses/jiada_liang_MMath
- Timestamp:
- Jun 12, 2024, 9:14:47 AM (6 months ago)
- Branches:
- master
- Children:
- 736a38d
- Parents:
- 3eb5f993
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/intro.tex
r3eb5f993 r4c8f29ff 8 8 In theory, there are an infinite set of constant names per type representing an infinite set of values. 9 9 10 It is common in mathematics, engineering and computer science to alias new constants to existing constants so they have the same value, \eg $\pi$, $\tau$ (2$\pi$), $\phi$ (golden ratio), K(k), M, G, T for powers of 2\footnote{Overloaded with SI powers of 10.} often prefixing bits (b) or bytes (B), \eg Gb, MB, and in general situations, \eg specific times (noon, New Years), cities (Big Apple), flowers (Lily), \etc.10 It is common in mathematics, engineering, and computer science to alias new constants to existing constants so they have the same value, \eg $\pi$, $\tau$ (2$\pi$), $\phi$ (golden ratio), K(k), M, G, T for powers of 2\footnote{Overloaded with SI powers of 10.} often prefixing bits (b) or bytes (B), \eg Gb, MB, and in general situations, \eg specific times (noon, New Years), cities (Big Apple), flowers (Lily), \etc. 11 11 An alias can bind to another alias, which transitively binds it to the specified constant. 12 12 Multiple aliases can represent the same value, \eg eighth note and quaver, giving synonyms. … … 80 80 \end{tabular} 81 81 \end{cquote} 82 Here, the enumeration @Week@ defines the enumerator constant @Mon@, @Tue@, @Wed@, @Thu@, @Fri@, @Sat@and @Sun@.82 Here, the enumeration @Week@ defines the enumerator constants @Mon@, @Tue@, @Wed@, @Thu@, @Fri@, @Sat@, and @Sun@. 83 83 The implicit ordering implies the successor of @Tue@ is @Mon@ and the predecessor of @Tue@ is @Wed@, independent of any associated enumerator values. 84 84 The value is the implicitly/explicitly assigned constant to support any enumeration operations; … … 204 204 \begin{cfa} 205 205 void foo( void ); 206 struct unit {} u; // empty type206 struct unit {} u; $\C[1.5in]{// empty type}$ 207 207 unit bar( unit ); 208 foo( foo() ); // void argument does not match with void parameter209 bar( bar( u ) ); // unit argument does match with unit parameter208 foo( foo() ); $\C{// void argument does not match with void parameter}$ 209 bar( bar( u ) ); $\C{// unit argument does match with unit parameter}\CRT$ 210 210 \end{cfa} 211 211 … … 252 252 253 253 The key observation is the dichotomy between an ADT and enumeration: the ADT uses the associated type resulting in a union-like data structure, and the enumeration does not use the associated type, and hence, is not a union. 254 While theenumeration is constructed using the ADT mechanism, it is so restricted it is not an ADT.254 While an enumeration is constructed using the ADT mechanism, it is so restricted it is not an ADT. 255 255 Furthermore, a general ADT cannot be an enumeration because the constructors generate different values making enumerating meaningless. 256 256 While functional programming languages regularly repurpose the ADT type into an enumeration type, this process seems contrived and confusing. … … 277 277 inheritance 278 278 \end{enumerate} 279 280 281 \begin{comment} 282 Date: Wed, 1 May 2024 13:41:58 -0400 283 Subject: Re: Enumeration 284 To: "Peter A. Buhr" <pabuhr@uwaterloo.ca> 285 From: Gregor Richards <gregor.richards@uwaterloo.ca> 286 287 I think I have only one comment and one philosophical quibble to make: 288 289 Comment: I really can't agree with putting MB in the same category as the 290 others. MB is both a quantity and a unit, and the suggestion that MB *is* one 291 million evokes the rather disgusting comparison 1MB = 1000km. Unit types are 292 not in the scope of this work. 293 294 Philosophical quibble: Pi *is* 3.14159...etc. Monday is not 0; associating 295 Monday with 0 is just a consequence of the language. The way this is written 296 suggests that the intentional part is subordinate to the implementation detail, 297 which seems backwards to me. Calling the number "primary" and the name 298 "secondary" feels like you're looking out from inside of the compiler, instead 299 of looking at the language from the outside. And, calling secondary values 300 without visible primary values "opaque"-which yes, I realize is my own term 301 ;)-suggests that you insist that the primary value is a part of the design, or 302 at least mental model, of the program. Although as a practical matter there is 303 some system value associated with the constructor/tag of an ADT, that value is 304 not part of the mental model, and so calling it "primary" and calling the name 305 "secondary" and "opaque" seems either (a) very odd or (b) very C-biased. Or 306 both. 307 308 With valediction, 309 - Gregor Richards 310 311 312 Date: Thu, 30 May 2024 23:15:23 -0400 313 Subject: Re: Meaning? 314 To: "Peter A. Buhr" <pabuhr@uwaterloo.ca> 315 CC: <ajbeach@uwaterloo.ca>, <j82liang@uwaterloo.ca> 316 From: Gregor Richards <gregor.richards@uwaterloo.ca> 317 318 I have to disagree with this being agreeing to disagree, since we agree 319 here. My core point was that it doesn't matter whether you enumerate over the 320 names or the values. This is a distinction without a difference in any case 321 that matters. If any of the various ways of looking at it are actually 322 different from each other, then that's because the enumeration has failed to be 323 an enumeration in some other way, not because of the actual process of 324 enumeration. Your flag enum is a 1-to-1 map of names and values, so whether you 325 walk through names or walk through values is not an actual distinction. It 326 could be distinct in the *order* that it walks through, but that doesn't 327 actually matter, it's just a choice that has to be made. Walking through entire 328 range of machine values, including ones that aren't part of the enumeration, 329 would be bizarre in any case. 330 331 Writing these out has crystallized some thoughts, albeit perhaps not in a way 332 that's any help to y'all. An enumeration is a set of names; ideally an ordered 333 set of names. The state of enumerations in programming languages muddies things 334 because they often expose the machine value underlying those names, resulting 335 in a possibly ordered set of names and a definitely ordered set of values. And, 336 muddying things further, because those underlying values are exposed, enums are 337 used in ways that *depend* on the underlying values being exposed, making that 338 a part of the definition. But, an enumeration is conceptually just *one* set, 339 not both. So much of the difficulty is that you're trying to find a way to make 340 a concept that should be a single set agree with an implementation that's two 341 sets. If those sets have a 1-to-1 mapping, then who cares, they're just 342 aliases. It's the possibility of the map being surjective (having multiple 343 names for the same underlying values) that breaks everything. Personally, I 344 think that an enum with aliases isn't an enumeration anyway, so who cares about 345 the rest; if you're not wearing the gourd as a shoe, then it's not an 346 enumeration. 347 348 With valediction, 349 - Gregor Richards 350 \end{comment}
Note: See TracChangeset
for help on using the changeset viewer.