Actually, you'd be better off asking on the PostgreSQL site about stuff like that.
However, IIRC, PostgresSQL triggers do have to be in the form of a function.
Don't assume that function == inefficient. First of all, most modern-day language implementations do significant optimizations. Secondly, proportionally, the overhead of a stock function call to straightline code is a miniscule fraction of what it was 30 years ago. <advice>NEVER "KNOW" where ineficiency is. You'll be wrong. MEASURE it.</advice>
Finally, realize that database operations are thousands of times slower than program operations. So the time taken for the trigger to to its cascade delete (as you seem to be showing) or do foreign key operations or whatever is far more significant the overhead of a function call.
Science is the process of replacing what we "know" with what is TRUE. Politics, alas, often prefers to be the opposite.
I didn't say it. I'm just telling you what this tiny ad said.