Computer Science Canada Enum and Union |
Author: | AsianSensation [ Sun Jul 20, 2003 9:09 pm ] |
Post subject: | Enum and Union |
I'm having trouble understanding enum and union syntax, what do they do, and how do I use them efficently? |
Author: | Dan [ Mon Jul 21, 2003 5:26 pm ] | ||
Post subject: | |||
well the enum things is a litte odd in turing. here is an expale i made to output colors:
honstety i dont realy see the point of them, in most progames this whould be realy needed. (can do same thing esaer with an array of strings). As for union: turing doc's say this about them: A union type (also called a variant record) is like a record in which there is a run time choice among sets of accessible fields. This choice is made by the tag statement, which deletes the current set of fields and activates a new set. basicly they have to do with recoreds, i dont know much about them since i have never used them in turing. |
Author: | AsianSensation [ Mon Jul 21, 2003 6:38 pm ] |
Post subject: | |
I just wanted to check on this union thing, because I was reading a tutorial somewhere, here, http://www.doc.ic.ac.uk/lab/firstyear/turing_lecture_notes/turing_lecture_9.html to be exact, and it says that union could be used to simulate polymorphism. Except the example was to confusing, hopefully someone will explain it to me. |
Author: | Catalyst [ Mon Jul 21, 2003 8:00 pm ] |
Post subject: | |
u dont have to simulate polymorphism in turing it can be implemented using the deferred key word |
Author: | rizzix [ Tue Jul 22, 2003 1:09 am ] |
Post subject: | |
well technincally the union is not used too often in the mordern world. it was used in the past, since at that time memory was an issue. a union lets u declare different variables to use a common memory area. well at least thats what a union means in c |