I was playing around with the new anonymous delegates feature of the Visual Studio 2005 (widbey), I wondered if i could use the this to write for age old data structures in different way, and here is the result!
class ADStack<T>
{
delegate T popdelegate();
private popdelegate popper=null;
public T Pop()
{
return popper();
}
public void Push(T value)
{
popdelegate oldpopper = popper;
popper = delegate{
popper = oldpopper;
return value;
};
}
}