Generics (Γενικότθτα)

Σχετικά έγγραφα
Goals of this Lecture. Generics(Γενικότητα) Generic Data Structures Example. Generic Data Structures Example

The Simply Typed Lambda Calculus

Χαρακτηριστικά ενοτήτων

2 Composition. Invertible Mappings

Instruction Execution Times

HY150a Φροντιστήριο 3 24/11/2017

Other Test Constructions: Likelihood Ratio & Bayes Tests

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

EE512: Error Control Coding

Finite Field Problems: Solutions

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

Μηχανική Μάθηση Hypothesis Testing

derivation of the Laplacian from rectangular to spherical coordinates

SOAP API. Table of Contents

Models for Probabilistic Programs with an Adversary

ΔΟΜΕΣ ΔΕΔΟΜΕΝΩΝ & ΑΛΓΟΡΙΘΜΟΙ ΕΡΓΑΣΤΗΡΙΟ

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

TMA4115 Matematikk 3

Lecture 2. Soundness and completeness of propositional logic

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

About these lecture notes. Simply Typed λ-calculus. Types

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Μορφοποίηση υπό όρους : Μορφή > Μορφοποίηση υπό όρους/γραμμές δεδομένων/μορφοποίηση μόο των κελιών που περιέχουν/

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

Section 8.3 Trigonometric Equations

Homework 3 Solutions

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

Φροντιςτήριο. Linked-List

Test Data Management in Practice

Example Sheet 3 Solutions

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Statistical Inference I Locally most powerful tests

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

Lab 1: C/C++ Pointers and time.h. Panayiotis Charalambous 1

4.6 Autoregressive Moving Average Model ARMA(1,1)

Στοίβες - Ουρές. Στοίβα (stack) Γιάννης Θεοδωρίδης, Νίκος Πελέκης, Άγγελος Πικράκης Τµήµα Πληροφορικής

ST5224: Advanced Statistical Theory II

The challenges of non-stable predicates

Every set of first-order formulas is equivalent to an independent set

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

Modbus basic setup notes for IO-Link AL1xxx Master Block

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Lecture 34 Bootstrap confidence intervals

Fractional Colorings and Zykov Products of graphs

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

ΕΙΣΑΓΩΓΗ ΣΤΟN ΠΡΟΓΡΑΜΜΑΤΙΣΜΟ ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΑΤΡΩΝ ΠΟΛΥΤΕΧΝΙΚΗ ΣΧΟΛΗ ΤΜΗΜΑ ΜΗΧΑΝΙΚΩΝ Η/Υ ΚΑΙ ΠΛΗΡΟΦΟΡΙΚΗΣ

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Συστήματα Διαχείρισης Βάσεων Δεδομένων

Exercises 10. Find a fundamental matrix of the given system of equations. Also find the fundamental matrix Φ(t) satisfying Φ(0) = I. 1.

ΑΦAΙΡΕΤΙΚΟΣ (ή ΑΦΗΡΗΜΕΝΟΣ) ΤΥΠΟΣ ΔΕΔΟΜΕΝΩΝ (ΑΤΔ) (Abstract Data Type-ADT) - σύνολο δεδομένων (data, objects) - σύνολο πράξεων στα δεδομένα

Concrete Mathematics Exercises from 30 September 2016

6.3 Forecasting ARMA processes

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

( ) 2 and compare to M.

C.S. 430 Assignment 6, Sample Solutions

Section 7.6 Double and Half Angle Formulas

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Διδάσκων: Κωνσταντίνος Κώστα Διαφάνειες: Δημήτρης Ζεϊναλιπούρ

ΤΥΠΟΣ ΔΕΔΟΜΕΝΩΝ (ΑΤΔ) (Abstract Data Type-ADT)

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Solutions to the Schrodinger equation atomic orbitals. Ψ 1 s Ψ 2 s Ψ 2 px Ψ 2 py Ψ 2 pz

Code Breaker. TEACHER s NOTES

Ανάπτυξη Μεγάλων Εφαρµογών στη Γλώσσα C (2)

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

Section 9.2 Polar Equations and Graphs

SUPERPOSITION, MEASUREMENT, NORMALIZATION, EXPECTATION VALUES. Reading: QM course packet Ch 5 up to 5.6

Paper Reference. Paper Reference(s) 1776/04 Edexcel GCSE Modern Greek Paper 4 Writing. Thursday 21 May 2009 Afternoon Time: 1 hour 15 minutes

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

ΠΛΗ111. Ανοιξη Μάθηµα 4 ο. Στοίβα. Τµήµα Ηλεκτρονικών Μηχανικών και Μηχανικών Υπολογιστών Πολυτεχνείο Κρήτης

Εισαγωγή στην Γλώσσα Προγραμματισμού Python. 12/10/16 1

Numerical Analysis FMN011

Κατανεμημένα Συστήματα. Javascript LCR example

Bounding Nonsplitting Enumeration Degrees

Block Ciphers Modes. Ramki Thurimella

Overview. Transition Semantics. Configurations and the transition relation. Executions and computation

Πανεπιστήμιο Δυτικής Μακεδονίας. Τμήμα Μηχανικών Πληροφορικής & Τηλεπικοινωνιών. Ηλεκτρονική Υγεία

Σημειώσεις όγδοης εβδομάδας

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Web Data Mining ΕΡΓΑΣΤΗΡΙΟ 2 & 3. Prepared by Costantinos Costa Edited by George Nikolaides. EPL Data Mining on the Web

(C) 2010 Pearson Education, Inc. All rights reserved.

Προγραμματισμός Ι. Δομές Δεδομένων. Δημήτρης Μιχαήλ. Ακ. Έτος Τμήμα Πληροφορικής και Τηλεματικής Χαροκόπειο Πανεπιστήμιο

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

Chapter 29. Adjectival Participle

Démographie spatiale/spatial Demography

ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΕΙΡΑΙΑ ΤΜΗΜΑ ΝΑΥΤΙΛΙΑΚΩΝ ΣΠΟΥΔΩΝ ΠΡΟΓΡΑΜΜΑ ΜΕΤΑΠΤΥΧΙΑΚΩΝ ΣΠΟΥΔΩΝ ΣΤΗΝ ΝΑΥΤΙΛΙΑ

Inverse trigonometric functions & General Solution of Trigonometric Equations

Διάλεξη 14: Δομές Δεδομένων ΙΙI (Λίστες και Παραδείγματα)

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

ΑΥΤΟΜΑΤΟΠΟΙΗΣΗ ΜΟΝΑΔΑΣ ΘΡΑΥΣΤΗΡΑ ΜΕ ΧΡΗΣΗ P.L.C. AUTOMATION OF A CRUSHER MODULE USING P.L.C.

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

Reminders: linear functions

forms This gives Remark 1. How to remember the above formulas: Substituting these into the equation we obtain with

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

Matrices and Determinants

Transcript:

Generics (Γενικότθτα) Μποροφμε να καταςκευάςουμε ΑΤΔ που επιτρζπει χριςθ με διαφορετικοφσ Τφπουσ Δεδομζνων ςτο ίδιο πρόγραμμα; Π.χ. Μια ςτοίβα με char* και μια με int 1

Goals of this Lecture Help you learn about: Generic modules Data structures that can store multiple types of data Functions that can work on multiple types of data How to create generic modules in C Which wasn t designed with generic modules in mind! Why? Reusing existing code is easier/cheaper than writing new code; reuse reduces software costs Generic modules are more reusable than non-generic ones A power programmer knows how to create generic modules A power programmer knows how to use existing generic modules to create large programs 2

Generic Data Structures Example Stack /* stack.h */ typedef struct Stack *Stack_T; Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const char *item); char *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); Items are strings (type char*) 3

Generic Data Structures Example Stack operations (push, pop, top, etc.) make sense for items other than strings too So Stack module could (and maybe should) be generic Problem: How to make Stack module generic? How to define Stack module such that a Stack object can store items of any type? 4

Generic Data Structures via typedef Solution 1: Let clients define item type (G2) /* client.c */ struct Item { char *str; /* Or whatever is appropriate */ ; Stack_T s; struct Item item; item.str = "hello"; s = Stack_new(); Stack_push(s, item); /* stack.h */ typedef struct Item *Item_T; typedef struct Stack *Stack_T; Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, Item_T item); Item_T Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); 5

Generic Data Structures via typedef Problem: Awkward for client to define structure type and create structures of that type Problem: Client (or some other module in same program) might already use Item_T for some other purpose! Problem: Client might need two Stack objects holding different types of data!!! We need another approach 6

Generic Data Structures via void* Solution 2: The generic pointer (void*) (G3) /* stack.h */ typedef struct Stack *Stack_T; Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const void *item); void *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); 7

Generic Data Structures via void* Can assign a pointer of any type to a void /* client.c */ pointer Stack_T s; s = Stack_new(); Stack_push(s, "hello"); /* stack.h */ typedef struct Stack *Stack_T; OK to match an actual parameter of type char* with a formal parameter of type void* Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const void *item); void *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); 8

Generic Data Structures via void* Can assign a void pointer to a pointer of any type /* client.c */ char *str; Stack_T s; s = Stack_new(); Stack_push(s, "hello"); /* stack.h */ str = Stack_top(s); typedef struct Stack *Stack_T; OK to assign a void* return value to a char* Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const void *item); void *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); 9

Generic Data Structures via void* Problem: Client must know what type of data a void pointer is pointing to /* client.c */ int *i; Stack_T s; s = Stack_new(); Stack_push(s, "hello"); i = Stack_top(s); Client pushes a string Client considers retrieved value to be a pointer to an int! Legal!!! Trouble!!! Solution: None Void pointers subvert the compiler s type checking Programmer s responsibility to avoid type mismatches 10

Generic Data Structures via void* Problem: Stack items must be pointers E.g. Stack items cannot be of primitive types (int, double, etc.) /* client.c */ int i = 5; Stack_T s; s = Stack_new(); Stack_push(s, 5); Stack_push(s, &i); Not OK to match an actual parameter of type int with a formal parameter of type void* OK, but Solution: none awkward In C, there is no mechanism to create truly generic data structures (In C++: Use template classes and template functions) (In Java: Use generic classes) 11

Generic Algorithms Example Suppose we wish to add another function to the Stack module /* stack.h */ typedef struct Stack *Stack_T; Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const void *item); void *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); int Stack_areEqual(Stack_T s1, Stack_T s2); Returns 1 (TRUE) iff s1 and s2 are equal, that is, contain equal items in the same order 12

Generic Algorithm Attempt 1 Attempt 1 /* stack.c */ int Stack_areEqual(Stack_T s1, Stack_T s2) { return s1 == s2; Returns 0 (FALSE) Incorrect! /* client.c */ char str1[] = "hi"; char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); if (Stack_areEqual(s1,s2)) { Checks if s1 and s2 are identical, not equal Compares pointers, not items That s not what we want 13

Addresses vs. Values Suppose two locations in memory have the same value int i=5; int j=5; 5 The addresses of the variables are not the same That is (&i == &j) is FALSE Need to compare the values themselves That is (i == j) is TRUE Unfortunately, comparison operation is type specific The == works for integers and floating-point numbers But not for strings and more complex data structures i j 5 14

Generic Algorithm Attempt 2 Attempt 2 /* stack.c */ int Stack_areEqual(Stack_T s1, Stack_T s2) { struct Node *p1 = s1->first; struct Node *p2 = s2->first; while ((p1!= NULL) && (p2!= NULL)) { if (p1!= p2) return 0; p1 = p1->next; p2 = p2->next; if ((p1!= NULL) (p2!= NULL)) return 0; return 1; Checks if nodes are identical Compares pointers, not items That is still not what we want /* client.c */ char str1[] = "hi"; char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); if (Stack_areEqual(s1,s2)) { Returns 0 (FALSE) Incorrect! 15

Generic Algorithm Attempt 3 Attempt 3 /* stack.c */ int Stack_areEqual(Stack_T s1, Stack_T s2) { struct Node *p1 = s1->first; struct Node *p2 = s2->first; while ((p1!= NULL) && (p2!= NULL)) { if (p1->item!= p2->item) return 0; p1 = p1->next; p2 = p2->next; if ((p1!= NULL) (p2!= NULL)) return 0; return 1; /* client.c */ Checks if items are identical Compares pointers to items, not items themselves That is still not what we want char str1[] = "hi"; char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); if (Stack_areEqual(s1,s2)) { Returns 0 (FALSE) Incorrect! 16

Attempt 4 Generic Algorithm Attempt 4 /* stack.c */ int Stack_areEqual(Stack_T s1, Stack_T s2) { struct Node *p1 = s1->first; struct Node *p2 = s2->first; while ((p1!= NULL) && (p2!= NULL)) { if (strcmp(p1->item, p2->item)!= 0) return 0; p1 = p1->next; p2 = p2->next; if ((p1!= NULL) (p2!= NULL)) return 0; /* client.c */ return Checks 1; if items are equal That s what we want But strcmp() works only if items are strings! We need Stack_areEqual() to be generic How to compare values when we don t know their type? char str1[] = "hi"; char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); if (Stack_areEqual(s1,s2)) { Returns 1 (TRUE) Correct! 17

Generic Algorithm via Function Pointer Approach 5 /* stack.h */ typedef struct Stack *Stack_T; Stack_T Stack_new(void); void Stack_free(Stack_T s); void Stack_push(Stack_T s, const void *item); void *Stack_top(Stack_T s); void Stack_pop(Stack_T s); int Stack_isEmpty(Stack_T s); int Stack_areEqual(Stack_T s1, Stack_T s2, int (*cmp)(const void *item1, const void *item2)); Add parameter to Stack_areEqual() Pointer to a compare function, which Accepts two const void * parameters, and Returns an int Allows client to supply the function that Stack_areEqual() should call to compare items 18

Generic Algorithm via Function Pointer Approach 5 (cont.) /* stack.c */ int Stack_areEqual(Stack_T s1, Stack_T s2, int (*cmp)(const void *item1, const void *item2)) { struct Node *p1 = s1->first; struct Node *p2 = s2->first; while ((p1!= NULL) && (p2!= NULL)) { if ((*cmp)(p1->item, p2->item)!= 0) return 0; p1 = p1->next; p2 = p2->next; if ((p1!= NULL) (p2!= NULL)) return 0; return 1; Definition of Stack_areEqual() uses the function pointer to call the clientsupplied compare function Stack_areEqual() calls back into client code 19

Generic Algorithm via Function Pointer Approach 5 (cont.) /* client.c */ int strcompare(const void *item1, const void *item2) { char *str1 = item1; char *str2 = item2; return strcmp(str1, str2); char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); if (Stack_areEqual(s1,s2,strCompare)) { Returns 1 (TRUE) Correct! Client passes address of strcompare() to Stack_areEqual() Client defines callback function, and passes pointer to it to Stack_areEqual() Callback function must match Stack_areEqual() parameter exactly 20

Generic Algorithm via Function Pointer Alternative: Client defines more natural callback function, and casts it to match Stack_areEqual() parameter Approach 5 (cont.) /* client.c */ int strcompare(const char *str1, const char *str2) { return strcmp(str1, str2); char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); Cast operator if (Stack_areEqual(s1, s2, (int (*)(const void*, const void*))strcompare)) { 21

Generic Algorithm via Function Pointer Approach 5 (cont.) /* client.c */ char str2[] = "hi"; Stack_T s1 = Stack_new(); Stack_T s2 = Stack_new(); Stack_push(s1, str1); Stack_push(s2, str2); Cast operator if (Stack_areEqual(s1, s2, (int (*)(const void*, const void*))strcmp)) { Alternative (for string comparisons only): Simply use strcmp() with cast! 22

Summary Generic data structures Via item typedef Safe, but not realistic Via the generic pointer (void*) Limiting: items must be pointers Dangerous: subverts compiler type checking The best we can do in C (See C++ template classes and Java generics for other approaches) Generic algorithms Via function pointers and callback functions 23

Genericity Υλοποίθςθ Ενοτιτων (Modules) ςτθν C και Γενικότθτα (Genericity) Modularity No Modularity (0) Απόκρυψθ Πράξεων (ΜΑ) (1) Απόκρυψθ Δεδομζνων και Πράξεων (ΠΑ)(2,3) + - ΤΣ κακοριςμζνοσ ςτον κϊδικα, χωρίσ αφαίρεςθ ΌΧΙ (Demo Mod 0) ΌΧΙ λόγω G (Demo Mod 1) ΌΧΙ λόγω G (Demo Mod 3+2) ζλεγχοσ μεταγλϊττιςθσ 1 μόνο ΤΣ, Αλλαγι ΤΣ απαιτεί Αλλαγι Υλοποίθςθσ ΑΤΔ, απαιτεί recompilation ΤΣ #include ςε.h (και αντίςτοιχο.c) ΌΧΙ λόγω Modularity NAI με Προςοχι όπωσ ουρά 1θσ άςκθςθσ Αλλαγι ΤΣ δεν απαιτεί αλλαγι ΝΑΙ (απλό με πολλά πλεονεκτιματα) υλοποίθςθσ ΑΤΔ, ζλεγχοσ ουρά 2θσ άςκθςθσ μεταγλϊττιςθσ 1 μόνο ΤΣ, Αλλαγι ΤΑ απαιτεί recompilation ΤΣ (Πλιρθσ απόκρυψθ και ΤΣ *Τ)(παράμετροι ςυναρτιςεων και data του ΑΤΔ είναι *Τ) ΌΧΙ λόγω Modularity Χωρίσ ιδιαίτερο όφελοσ ΝΑΙ, απαιτεί καλι χριςθ δεικτϊν Mod 3 Gen 1-T (SetValue απλουςτεφεται)(compare) Αλλαγι ΤΣ δεν απαιτεί αλλαγι υλοποίθςθσ ΑΤΔ, δεν απαιτεί recompilation, ζλεγχοσ μεταγλϊττιςθσ 1 μόνο ΤΣ ΤΣ (Πλιρθσ απόκρυψθ ΤΣ *Τ)(παράμετροι ςυναρτιςεων και data του ΑΤΔ είναι void*) ΌΧΙ λόγω Modularity Χωρίσ ιδιαίτερο όφελοσ Χριςιμθ για βιβλιοκικεσ, απαιτεί πολλά-τσ, ςτακερι υλοποίθςθ ΑΤΔ, καλοφσ ελζγχουσ. Mod 3 Gen n-type δεν απαιτεί recompilation (compare) χωρίσ ζλεγχο μεταγλϊττιςθσ + Καλι προςζγγιςθ, προςοχι ςτθν άμεςθ χριςθ ςτον Τφπο. Η καλφτερθ απόκρυψθ 1 ΤΣ μπορεί να καλφπτει πολλοφσ τφπουσ με union Να αποφεφγεται εντελϊσ, καμία - απόκρυψθ Κίνδυνοι άμεςθσ πρόςβαςθσ ςτον ΤΑ, αλλοίωςθ απόκρυψθσ Διαχειριηόμαςτε δείκτεσ και όχι structs 24