Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
ArtistA beautiful purple-haired woman wearing a long purple velvet ankle-length dress with flouncy sleeves and purple suede high heels. She is driving a bulldozer on a building site.
Say we have class Foo :
Foo <:: (a=1, b=2 c=MyConstructor);
When we instantiate it, field a is initialised to 1, b to 2, and c to the return value of the local function MyConstructor();. If we want to do some computation during instantiation, we can do it in the MyConstructor() function.
Now suppose we want to undo that computation when our object passes out of scope or ceases to exist. We use a function called "~" (tilde), as in
Foo <:: (a=1, b=2, c=MyConstructor, ~);
Note this is similar to C++, except C++ names the constructor "Foo()" and the destructor "~Foo()". Since ::SHE+ILA:: is a lambda-oriented language, the class can be named independently of its elements, so the destructor is just called "~". If we want to define it separately from its class definition, we can use namespaces :
Foo::~ <:: { ttyout(" Destructor called", CRLF)};
Since ::SHE+ILA:: has built-in garbage collection, destructors are rarely needed.
Note that this "overloading" of the tilde operator does not conflict with its use as monadic ones complement (~a) or dyadic absolute difference (a~b), since these usages only occur in expressions.