Quick background: I am designing a Pythonic language that I want to be as powerful as Lisp while remaining easy to use. And by "powerful", I mean "flexible and expressive".
I've just been introduced to Python function decorators, and I like them. I found this question that suggests decorators are not as powerful as Lisp macros. The third answer to this question says that the reason they're not is because they can only operate on functions.
But what if you could use decorators on arbitrary expressions? (In my language, expressions are first-class, just like functions and everything else, so doing that would be fairly natural.) Would that make decorators as powerful as Lisp macros? Or would I have to use syntax rules, like Racket and Honu, or some other technique?
EDIT
I was asked to provide an example of the syntactic construct. For an "expression decorator", it would simply be a decorator on an expression (where "$(...)" creates an expression object):
@Decorator("Params")
$(if (true):
printf("Was true")
else:
printf("Wasn't true"))
Also, if I do need to use syntax rules, as mentioned above, it would use a pattern matching syntax:
# Match a bool expression, a comma, and a string.
macro assert(expr:bool lit string) { e , s }:
if (!e):
error s
else:
printf("All good")
The above would match this:
assert i == 0, "i should have been 0"
That's a rough sketch, but it should give you an idea.