2 ms·
This heavily reminds me of old Microsoft's COM's QueryInterface approach, which acted basically the same: interfaces/traits were types. Your code would be like:
by theamk 4y ago
This heavily reminds me of old Microsoft's COM's QueryInterface approach, which acted basically the same: interfaces/traits were types. Your code would be like:
CDisplayInterface* louis = NULL;
HRESULT hr = friend.Friend("Louis")->QueryInterface(CLSID_DISPLAYINTERFACE, &louis)
CheckError(hr)
io.println(louis->format(DisplayOptions(...)))
basically the same thing as Gleam does, but more verbose and without all that safety.
(I think anyone advocating "going back to basics" would benefit from actually going back to basics and spending some time on those systems. I hope I will never have to touch COM in my life again, but my experience working with it was very helpful. GLib/GObject and Linux VFS are other class-like technologies which are worth experimenting with)