Ugly! Ugly! Ugly!

HRESULT IShellExtInit::Initialize (
    LPCITEMIDLIST pidlFolder,
    LPDATAOBJECT pDataObj,
    HKEY hProgID );

Piddlefolder indeed.

The notational conventions used in MFC (and, here, ATL) programming do convey useful information about the values being referred to, but they convey it in such an utterly graceless way that I think I’d rather not know.

class ShellExtInit a where
   Initialize :: a -> IORef [Item] -> IORef DataObject -> ProgId -> IO ResultCode

That’s better.

One Response to “Ugly! Ugly! Ugly!”

  1. Dominic Says:

    It’s Haskell. It defines a typeclass, ShellExtInit, members of which can be operated on using the operator Initialize. The separator…heh…the separator indicates the return value of the function, but Haskell supports partial application such that

    foo :: a -> a -> a
    foo x y = x + y
    

    is like this (in Python):

    def foo(x):
    ...def _foo(y):
    ......return x * y
    ...return _foo
    

    and foo x y (Haskell) is like foo(x)(y) (Python).

    Other notation: IORef a is the type of a mutable cell of type a (IORef a is a parameterised type, it’s a bit like saying IORef<a> in C++). [a] is the type of a list of a.

    You would declare an actual type to be an instance of this typeclass like this:

    instance ShellExtInit MyShellExtension where
       initialize :: myShellExt items dataObject progId = [...implementation goes here...]
    

    It’s another world really. But I kinda like it there.

Leave a Reply