day@grand.UUCP (Dave Yost) (12/22/88)
From: Kim Rochat <kimr@tekcrl.tek.com>
Date: Mon, 7 Nov 88 13:59:10 PST
In translating some Smalltalk-80 code to Eiffel, I found myself needing
reminders on how to translate various expressions. I include my translation
sheet below. I'd be interested in comments on other ways to write
enumerating loops (or generators) in Eiffel. I've written the Smalltalk-80
assignment operator as ":=" instead of "_".
Kim Rochat
kimr@tekcrl.tek.com
Smalltalk to Eiffel Dictionary
Smalltalk Eiffel
--------- -------
instance variables and methods feature
instance variable attribute
method routine
<language constructs>
self Current
b at: i b.entry(i)
b at: i put: j b.enter(i,j)
b := <type> new b.Create
b isNil b.Void
b := nil b.Forget
a := b copy b.Clone(a)
| a | local a: INTEGER
anArray := Array new:10 anArray.Create(1,10);
<send a message "msg" to each object in an array>
anArray do: [: each | each msg] from i := anArray.lower
until i > anArray.upper
loop
anArray.entry(i).msg
i := i + 1;
end
<send a message "msg" to each object in a list>
[aStream atEnd] whileFalse: from aList.start
[aStream next msg] until aList.islast
<or> loop
aCollection do: [: a | a msg ] alist.value.msg;
aList.forth
end
<for loop>
1 to: 10 do: [: i | <code>] from i := 1 until i > 10 loop
<code>;
i := i + 1
end