User Tools

Site Tools


assignments:a2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
assignments:a2 [2009/04/02 03:21] jonathanassignments:a2 [2009/04/05 02:11] (current) – removed jonathan
Line 1: Line 1:
-====== Assignment 2 ====== 
- 
- 
-Download the file a2-money.zip in ''Assignments'' in the SVN. Instructions are in the PDF file ''W09-a2-money-spec.pdf''. 
- 
-Since your code will be executed and checked with a script, you must follow the instructions precisely. Your work is in a directory ''a2-money'' (with ecf file as is, in this folder). You must do a written report which you must include in this directory. 
- 
-Before submitting, eclean and do a fresh compile and execute to make sure that you get a green bar. Then eclean the directory ''a2-money'' again (to get rid of the EIFGEN's) and submit it: 
- 
-   submit -l 3311 a2 a2-money 
- 
-Don't forget to also hand in your written report at the 3311 drop box in the CSE building. 
- 
----- 
----- 
- 
-===== void safety and HASH_TABLE [?G, ?K]===== 
- 
-  * We would like to use HASH_TABLE[G, H] to implement the efficient version of MAP when we can rely on hashable keys.  
-  * Eiffelstudio 6.3 is in transition to implementing void safety (which means that the compiler will always catch errors of the type ''t.f(x)'' where ''t = Void''). As part of the transition, a type with a question mark in front of it (?T) is detachable (allowed to be Void) whereas a type with an exclamation mark (!T) is an attached type (is never allowed to be void).  
-  * The latest version of HASH_TABLE inherits from TABLE [?G, ?K], i.e. the generic parameters are allowed to be attached to Void. So, to use HASH_TABLE in HASHABLE_MAP, we can proceed as follows: 
- 
-<code eiffel> 
-class  
-   HASHABLE_MAP [KEY -> {HASHABLE,COMPARABLE}, VAL] 
-inherit 
-   MAP[?KEY,?VAL]  
-create 
-   make 
-feature  
-   has (k: ?KEY):BOOLEAN  ... 
- 
-   item alias "[]" (k: ?KEY): ?VAL assign override ... 
- 
-   has_tuple(t: TUPLE[k:?KEY; v:?VAL]): BOOLEAN ... 
- 
-   domain: ARRAY[?KEY] 
- 
-feature{NONE} 
-   map_imp: HASH_TABLE[VAL, KEY] 
-end 
-</code> 
- 
-The question mark will ensure that the keys and values can be Void. you may sometimes have to do the following to obtain a correct tuple type: 
- 
-<code eiffel> 
-t: TUPLE[KEY,VAL] 
- 
-t ?= [map_imp.key_for_iteration, map_imp.item_for_iteration] 
-</code> 
- 
-"?=" is assignment attempt and is discussed in the text book OOSC2. 
- 
-In the next version of EiffelStudio, the default will be that when you declare 
-<code eiffel> 
-t: T 
-</code> 
-t is attached. You will have to explicitly say 
- 
-<code eiffel> 
-t: ?T 
-</code> 
-if you want to allow ''t = Void''. 
- 
  
assignments/a2.1238642467.txt.gz · Last modified: 2009/04/02 03:21 by jonathan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki