average-vr-56795
01/07/2020, 2:13 PM@rule
decorator?average-vr-56795
01/07/2020, 2:14 PMhundreds-father-404
01/07/2020, 2:30 PMname='run this rule'
though
I think this is worth considering, although bias towards keeping it for documentation purposes.hundreds-father-404
01/07/2020, 2:42 PMaverage-vr-56795
01/07/2020, 2:55 PM"""
Uses Zinc to compile scala code to bytecode.
This rule values speed over correctness. Sometimes, things may go badly.
Display name: Compiling scala with zinc.
"""
average-vr-56795
01/07/2020, 2:55 PMhundreds-father-404
01/07/2020, 3:02 PMhundreds-breakfast-49010
01/07/2020, 6:22 PMhundreds-breakfast-49010
01/07/2020, 6:23 PMhundreds-breakfast-49010
01/07/2020, 6:24 PM@rule
so that pants doesn't try to do this for every functionaverage-vr-56795
01/07/2020, 8:14 PMrules()
in a register.py
average-vr-56795
01/07/2020, 8:14 PMaloof-angle-91616
01/07/2020, 8:45 PM@rule
decorator means we do tons of stuff like ast
introspection and calling inspect.stack()
or whatever at import timealoof-angle-91616
01/07/2020, 8:45 PMaloof-angle-91616
01/07/2020, 8:45 PMaloof-angle-91616
01/07/2020, 8:46 PMreturn
or yield
calls)aloof-angle-91616
01/07/2020, 8:53 PM@rule
decoratoraloof-angle-91616
01/07/2020, 8:54 PM@rule
decorator (the process of attaching metadata to a rule) from the ast
manipulation process which is needed to use it in the enginehundreds-breakfast-49010
01/07/2020, 8:54 PMregister.py
aloof-angle-91616
01/07/2020, 8:54 PM@rule
decorator can be easier to implement maybehundreds-breakfast-49010
01/07/2020, 8:54 PMaloof-angle-91616
01/07/2020, 8:54 PMaloof-angle-91616
01/07/2020, 8:54 PMaloof-angle-91616
01/07/2020, 8:55 PMaloof-angle-91616
01/07/2020, 8:55 PMwitty-crayon-22786
01/07/2020, 10:37 PM@rule
... are useful as seperate conceptswitty-crayon-22786
01/07/2020, 10:37 PMwitty-crayon-22786
01/07/2020, 10:37 PMhundreds-father-404
01/07/2020, 10:39 PMaverage-vr-56795
01/07/2020, 10:49 PMI like the decorators for the proximity of knowing what is a normal function and what is a rule.Why is this distinction important? imo it would be really nice to be able to transparently use any function, sync or async, as you naturally would in Python, and every place you actually care about whether it’s a rule or not is a usability bug… (ETA: Not sure how much I believe this vs devils advocating, I’ve felt both ways on this one in the past)
average-vr-56795
01/07/2020, 10:50 PMhundreds-father-404
01/07/2020, 10:51 PMaverage-vr-56795
01/07/2020, 10:52 PMaverage-vr-56795
01/07/2020, 10:53 PMwitty-crayon-22786
01/07/2020, 10:54 PMhundreds-father-404
01/07/2020, 10:55 PMAnd imagine if dependency injection worked wherever you wanted it to…I wouldn’t want this. It requires extra thinking for me to reason with dependency injection. I like the simplicity of normal pure python functions and how small the surface area is for understanding them. Dependency injection is neat, but extra magic, and we lose some ability to reason if now every single function might use that magic but might not
average-vr-56795
01/07/2020, 10:57 PMI gave the reason for the decorator above: I’d like my code to be validated, even if it isn’t registered anywhereAha! Somehow I negated something in there when I read it! What validation do we do on `@rule`s without knowing the full graph?
witty-crayon-22786
01/07/2020, 10:58 PMwitty-crayon-22786
01/07/2020, 10:59 PMaverage-vr-56795
01/07/2020, 10:59 PMI wouldn’t want this. It requires extra thinking for me to reason with dependency injection. I like the simplicity of normal pure python functions and how small the surface area is for understanding them. Dependency injection is neat, but extra magic, and we lose some ability to reason if now every single function might use that magic but might notWhy is that different for rules? I understand that the transitive graph navigation thing is useful (“I have an Address, the rule for computing this needs a HydratedTarget, do the magic”), and I can see that dependency injection helps to make you not need to care about intermediate rules, but don’t you have the same complaint about extra arguments to rules you’re directly calling being magically populated by context? (Which is currently actually a source of real bugs…)
average-vr-56795
01/07/2020, 11:04 PMThe validity of the parseability of your yield statementsLooking at the implementation, this feels like something that could maybe roughly be offloaded into the realms of MyPy? It’s effectively type-checking the arguments to
Get
in a slightly meta-typey way?hundreds-breakfast-49010
01/07/2020, 11:37 PMwitty-crayon-22786
01/07/2020, 11:39 PM@rule
as a marker on rules still seems useful, both as a marker, and as a place for additional arguments like name
to be specified with minimal magic.witty-crayon-22786
01/07/2020, 11:40 PM@rule
, and then work from there into the rest (which are likely "private" functions, essentially... or at least implementation details of the rules)aloof-angle-91616
01/08/2020, 9:20 PMaloof-angle-91616
01/08/2020, 9:21 PMwitty-crayon-22786
01/08/2020, 9:22 PMwitty-crayon-22786
01/08/2020, 9:23 PM@rule
and its exposed types are the actual API of an extension/plugin.aloof-angle-91616
01/08/2020, 9:25 PM