[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: highly parametric interfaces

This page is part of the web mail archives of SRFI 89 from before July 7th, 2015. The new archives for SRFI 89 contain all messages, not just those from before July 7th, 2015.

Alex Shinn scripsit:

>   Perl effectively uses the latter, passing
>   hash-tables as arguments to complex functions, but Perl's
>   hash-table syntax makes this feel more like a keyword interface,
>   discussed below.

Lua, which only has hashtables (the constructor is { ... }) allows
calls of the form foo{bar=baz, zam=quux}, which passes a single
hashtable argument, although parentheses are normally required
around all arguments.

> * Efficiency-oriented OOP - "Just set the parameters in the calling
>   object."  This person of course assumes there are no functions,
>   only methods, and only for a single calling object.  This is where
>   you get:
>     (define fmt (make-number-formatter))
>     (number-formatter-set-complex-behavior! fmt O_POLAR)
>     (number-formatter-set-magnitude-style! fmt O_FLOAT)
>     (number-formatter-set-magnitude-places! fmt 2)
>     (number-formatter-set-magnitude-radix! fmt 8)
>     (number-formatter-set-angle-style! fmt O_FLOAT)
>     (number-formatter-set-angle-radix! fmt 10)
>     (number-formatter-format fmt n)

As I pointed out earlier, you actually don't:  you get
some variant of (fmt 'complex-behavior-set! O_POLAR) or
(fmt 'set! 'complex-behavior O_POLAR).

>   [Alists are] fully general, and can express nested formats like the
>   polar example naturally.  Unfortunately, for more typical examples
>   this is usually going to involve backquotes and commas
>     (button `((text . ,(gettext "OK")) (action . ,quit)))

Which is why my proposal #2 uses keyword syntax as an alternative
representation of an alist or plist backquoted.

While staying with the Asonu, I met a man from      John Cowan
the Candensian plane, which is very much like       cowan@ccil.org
ours, only more of it consists of Toronto.          http://:www.ccil.org/~cowan
        --Ursula K. Le Guin, Changing Planes