[racket-dev] Racket2 suggestion: Attaching properties to operators

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun May 5 12:44:13 EDT 2013

C++ has tried this tack for some time. I can see doing for built-ins but how would you go about programmer-created operations? Trust the programmer? -- Matthias





On May 5, 2013, at 11:00 AM, Laurent wrote:

> Speaking of invariants, from time to time I would like Racket to know some properties about its usual operators, so that some usual treatments get simplified and can be easily generalized.
> 
> For example, considering group theory, properties like 'identity-element', 'absorbing-elements', 'inverse-operator', 'commutative?', 'associative?' and such could be attached to operators like `+', `*', `max', `string-append', `hc-append', etc.
> Forms like `for/op' could use this information to know how to loop and accumulate, and even possibly to optimize the code, even for newly created operators.
> In the simple case of + and such, one also only needs to define the binary operator, and the multi-argument procedure can be generated automatically.
> 
> Of course it needs not be tied to group/category/mathematical theory. It can be about whatever is useful.
> 
> It's only an idea, in case this resonates for someone.
> 
> Laurent
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev



Posted on the dev mailing list.