Changeset e00b10d for doc/theses
- Timestamp:
- Mar 23, 2024, 7:01:05 PM (6 months ago)
- Branches:
- master
- Children:
- caf2cba
- Parents:
- 4094d05a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/jiada_liang_MMath/relatedwork.tex
r4094d05a re00b10d 2587 2587 With valediction, 2588 2588 - Gregor Richards 2589 2590 Date: Wed, 20 Mar 2024 18:16:44 -0400 2591 Subject: Re: 2592 To: "Peter A. Buhr" <pabuhr@uwaterloo.ca> 2593 From: Gregor Richards <gregor.richards@uwaterloo.ca> 2594 2595 2596 On 3/20/24 17:26, Peter A. Buhr wrote: 2597 > Gregor, everyone at this end would like a definition of "enumerability". Can 2598 > you formulate one? 2599 2600 According to the OED (emphasis added to the meaning I'm after): 2601 2602 enumerate (verb, transitive). To count, ascertain the number of; **more 2603 usually, to mention (a number of things or persons) separately, as if for the 2604 purpose of counting**; to specify as in a list or catalogue. 2605 2606 With C enums, if you know the lowest and highest value, you can simply loop 2607 over them in a for loop (this is, of course, why so many enums come with an 2608 ENUM_WHATEVER_LAST value). But, I would be hesitant to use the word "loop" to 2609 describe enumerability, since in functional languages, you would recurse for 2610 such a purpose. 2611 2612 In Haskell, in order to do something with every member of an "enumeration", you 2613 would have to explicitly list them all. The type system will help a bit since 2614 it knows if you haven't listed them all, but you would have to statically have 2615 every element in the enumeration. If somebody added new elements to the 2616 enumeration later, your code to enumerate over them would no longer work 2617 correctly, because you can't simply say "for each member of this enumeration do 2618 X". In Haskell that's because there aren't actually enumerations; what they use 2619 as enumerations are a degenerate form of algebraic datatypes, and ADTs are 2620 certainly not enumerable. In OCaml, you've demonstrated that they impose 2621 comparability, but I would still assume that you can't make a loop over every 2622 member of an enumeration. (But, who knows!) 2623 2624 Since that's literally what "enumerate" means, it seems like a rather important 2625 property for enumerations to have ;) 2626 2627 With valediction, 2628 - Gregor Richards 2629 2630 2631 From: Andrew James Beach <ajbeach@uwaterloo.ca> 2632 To: Gregor Richards <gregor.richards@uwaterloo.ca>, Peter Buhr <pabuhr@uwaterloo.ca> 2633 CC: Michael Leslie Brooks <mlbrooks@uwaterloo.ca>, Fangren Yu <f37yu@uwaterloo.ca>, 2634 Jiada Liang <j82liang@uwaterloo.ca> 2635 Subject: Re: Re: 2636 Date: Thu, 21 Mar 2024 14:26:36 +0000 2637 2638 Does this mean that not all enum declarations in C create enumerations? If you 2639 declare an enumeration like: 2640 2641 enum Example { 2642 Label, 2643 Name = 10, 2644 Tag = 3, 2645 }; 2646 2647 I don't think there is any way to enumerate (iterate, loop, recurse) over these 2648 values without listing all of them. 2649 2650 2651 Date: Thu, 21 Mar 2024 10:31:49 -0400 2652 Subject: Re: 2653 To: Andrew James Beach <ajbeach@uwaterloo.ca>, Peter Buhr <pabuhr@uwaterloo.ca> 2654 CC: Michael Leslie Brooks <mlbrooks@uwaterloo.ca>, Fangren Yu <f37yu@uwaterloo.ca>, 2655 Jiada Liang <j82liang@uwaterloo.ca> 2656 From: Gregor Richards <gregor.richards@uwaterloo.ca> 2657 2658 I consider this conclusion reasonable. C enums can be nothing more than const 2659 ints, and if used in that way, I personally wouldn't consider them as 2660 enumerations in any meaningful sense, particularly since the type checker 2661 essentially does nothing for you there. Then they're a way of writing consts 2662 repeatedly with some textual indicator that these definitions are related; more 2663 namespace, less enum. 2664 2665 When somebody writes bitfield members as an enum, is that *really* an 2666 enumeration, or just a use of the syntax for enums to keep related definitions 2667 together? 2668 2669 With valediction, 2670 - Gregor Richards 2589 2671 \end{comment} 2590 2672
Note: See TracChangeset
for help on using the changeset viewer.