History variables: Difference between revisions

Content added Content deleted
Line 551: Line 551:
</lang>
</lang>
=={{header|Elena}}==
=={{header|Elena}}==
ELENA 3.2 :
ELENA 3.4 :
<lang elena>import extensions.
<lang elena>import extensions.
import system'collections.
import system'collections.
import system'routines.
import system'routines.
import extensions'routines.
import extensions'routines.

class HistoryVariable
class HistoryVariable
{
{
T<Stack> _previous := Stack new.
object prop Value :: _value.
object prop Value :: _value.
stack _previous := Stack new.

set Value:v
set Value:v
[
[
if ($nil != _value)
if (nil != _value)
[
[
_previous push(_value)
_previous push(_value)
].
].
_value := v
_value := v
]
]
undo
undo
[
[
Line 579: Line 580:
];
];
[
[
_value := $nil
_value := nilValue
]
]
]
]
enumerator => _previous.
enumerator => _previous.
dispatch => _value.
T<literal> literal => _value.
}
}

program =
public program
[
[
var o := HistoryVariable new.
var o := HistoryVariable new.
Line 594: Line 595:
o Value := "foo".
o Value := "foo".
o Value := o Value + "bar".
o Value := o Value + "bar".
console printLine(o).
console printLine(o).
o forEach:printingLn.
o forEach:printingLn.
o undo; undo; undo.
o undo; undo; undo.
console printLine(o Value).
console printLine(o Value).
].</lang>
]</lang>
{{out}}
{{out}}
<pre>
<pre>