Author abarry
Recipients Guido.van.Rossum, abarry, benjamin.peterson, berker.peksag, dirn, eric.araujo, eric.smith, eric.snow, gvanrossum, infinity0, james, ncoghlan, peyton
Date 2016-08-01.01:16:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1470014172.0.0.143172132823.issue19660@psf.upfronthosting.co.za>
In-reply-to
Content
Sure, here goes; this is an IRC game bot which I contribute to. Apologies for the long links, it's the only way to make sure this consistently points to the same place regardless of future commits.

The 'cmd' decorator we use is defined at https://github.com/lykoss/lykos/blob/1852bf2c442d707ba0cbc16e8c9e012bcbc4fcc5/src/decorators.py#L67 - we use its __call__ method to add the function to it; see next link.

How it's used: https://github.com/lykoss/lykos/blob/1852bf2c442d707ba0cbc16e8c9e012bcbc4fcc5/src/wolfgame.py#L9113 - ideally, a syntax such as the following would be nice for these definitions:

­@cmd("myrole", <keyword arguments here>).set
def myrole(cli, nick, chan, rest):
    # ... do stuff here ...

Historically (we used an arcane closure-based version that no one understood), we could call that function after directly, like any normal function. Now, though, we have to call it like this: https://github.com/lykoss/lykos/blob/1852bf2c442d707ba0cbc16e8c9e012bcbc4fcc5/src/wolfgame.py#L764

I'd like to state again that, while we'd use this new syntax, we've already worked around this lack of syntax. Whatever comes out of this, we won't be negatively affected, but decorators are meant to bring whatever alters the function right where it starts, so having syntax that eases that would make sense (to me, anyway).
History
Date User Action Args
2016-08-01 01:16:12abarrysetrecipients: + abarry, gvanrossum, ncoghlan, eric.smith, benjamin.peterson, eric.araujo, infinity0, eric.snow, berker.peksag, dirn, Guido.van.Rossum, james, peyton
2016-08-01 01:16:12abarrysetmessageid: <1470014172.0.0.143172132823.issue19660@psf.upfronthosting.co.za>
2016-08-01 01:16:11abarrylinkissue19660 messages
2016-08-01 01:16:10abarrycreate