Changeset 4c8f29ff


Ignore:
Timestamp:
Jun 12, 2024, 9:14:47 AM (3 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
736a38d
Parents:
3eb5f993
Message:

address Gregor's comment about quantity and a unit in examples, add emails as latex comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/jiada_liang_MMath/intro.tex

    r3eb5f993 r4c8f29ff  
    88In theory, there are an infinite set of constant names per type representing an infinite set of values.
    99
    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.
     10It 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.
    1111An alias can bind to another alias, which transitively binds it to the specified constant.
    1212Multiple aliases can represent the same value, \eg eighth note and quaver, giving synonyms.
     
    8080\end{tabular}
    8181\end{cquote}
    82 Here, the enumeration @Week@ defines the enumerator constant @Mon@, @Tue@, @Wed@, @Thu@, @Fri@, @Sat@ and @Sun@.
     82Here, the enumeration @Week@ defines the enumerator constants @Mon@, @Tue@, @Wed@, @Thu@, @Fri@, @Sat@, and @Sun@.
    8383The implicit ordering implies the successor of @Tue@ is @Mon@ and the predecessor of @Tue@ is @Wed@, independent of any associated enumerator values.
    8484The value is the implicitly/explicitly assigned constant to support any enumeration operations;
     
    204204\begin{cfa}
    205205void foo( void );
    206 struct unit {} u;  // empty type
     206struct unit {} u;       $\C[1.5in]{// empty type}$
    207207unit bar( unit );
    208 foo( foo() );        // void argument does not match with void parameter
    209 bar( bar( u ) );   // unit argument does match with unit parameter
     208foo( foo() );           $\C{// void argument does not match with void parameter}$
     209bar( bar( u ) );        $\C{// unit argument does match with unit parameter}\CRT$
    210210\end{cfa}
    211211
     
    252252
    253253The 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 the enumeration is constructed using the ADT mechanism, it is so restricted it is not an ADT.
     254While an enumeration is constructed using the ADT mechanism, it is so restricted it is not an ADT.
    255255Furthermore, a general ADT cannot be an enumeration because the constructors generate different values making enumerating meaningless.
    256256While functional programming languages regularly repurpose the ADT type into an enumeration type, this process seems contrived and confusing.
     
    277277inheritance
    278278\end{enumerate}
     279
     280
     281\begin{comment}
     282Date: Wed, 1 May 2024 13:41:58 -0400
     283Subject: Re: Enumeration
     284To: "Peter A. Buhr" <pabuhr@uwaterloo.ca>
     285From: Gregor Richards <gregor.richards@uwaterloo.ca>
     286
     287I think I have only one comment and one philosophical quibble to make:
     288
     289Comment: I really can't agree with putting MB in the same category as the
     290others. MB is both a quantity and a unit, and the suggestion that MB *is* one
     291million evokes the rather disgusting comparison 1MB = 1000km.  Unit types are
     292not in the scope of this work.
     293
     294Philosophical quibble: Pi *is* 3.14159...etc. Monday is not 0; associating
     295Monday with 0 is just a consequence of the language. The way this is written
     296suggests that the intentional part is subordinate to the implementation detail,
     297which 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
     299of looking at the language from the outside. And, calling secondary values
     300without 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
     302at least mental model, of the program. Although as a practical matter there is
     303some system value associated with the constructor/tag of an ADT, that value is
     304not 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
     306both.
     307
     308With valediction,
     309  - Gregor Richards
     310
     311
     312Date: Thu, 30 May 2024 23:15:23 -0400
     313Subject: Re: Meaning?
     314To: "Peter A. Buhr" <pabuhr@uwaterloo.ca>
     315CC: <ajbeach@uwaterloo.ca>, <j82liang@uwaterloo.ca>
     316From: Gregor Richards <gregor.richards@uwaterloo.ca>
     317
     318I have to disagree with this being agreeing to disagree, since we agree
     319here. My core point was that it doesn't matter whether you enumerate over the
     320names or the values. This is a distinction without a difference in any case
     321that matters. If any of the various ways of looking at it are actually
     322different from each other, then that's because the enumeration has failed to be
     323an enumeration in some other way, not because of the actual process of
     324enumeration. Your flag enum is a 1-to-1 map of names and values, so whether you
     325walk through names or walk through values is not an actual distinction. It
     326could be distinct in the *order* that it walks through, but that doesn't
     327actually matter, it's just a choice that has to be made. Walking through entire
     328range of machine values, including ones that aren't part of the enumeration,
     329would be bizarre in any case.
     330
     331Writing these out has crystallized some thoughts, albeit perhaps not in a way
     332that's any help to y'all. An enumeration is a set of names; ideally an ordered
     333set of names. The state of enumerations in programming languages muddies things
     334because they often expose the machine value underlying those names, resulting
     335in a possibly ordered set of names and a definitely ordered set of values. And,
     336muddying things further, because those underlying values are exposed, enums are
     337used in ways that *depend* on the underlying values being exposed, making that
     338a part of the definition. But, an enumeration is conceptually just *one* set,
     339not both. So much of the difficulty is that you're trying to find a way to make
     340a concept that should be a single set agree with an implementation that's two
     341sets. If those sets have a 1-to-1 mapping, then who cares, they're just
     342aliases. It's the possibility of the map being surjective (having multiple
     343names for the same underlying values) that breaks everything. Personally, I
     344think that an enum with aliases isn't an enumeration anyway, so who cares about
     345the rest; if you're not wearing the gourd as a shoe, then it's not an
     346enumeration.
     347
     348With valediction,
     349  - Gregor Richards
     350\end{comment}
Note: See TracChangeset for help on using the changeset viewer.