in reply to Re: [DSL] disabling packages in Perl?
in thread [DSL] disabling packages in Perl?

> like "or" and "and" short-circuiting:

Thanks, I'm fully aware of this! :)

My initial plan was to patch B::Deparse in a way to take the op-tree of the code-block and to produce SQL instead of Perl (or rather a semantically correct intermediate Perl representation which produces SQL)

> flattening of "(" and ")"

likewise, true lists are flattened but precedence is still visible in the op-tree

BUT for the moment I'm rather inclined to create subs OR() and AND() for a quick prototype.

That is taking multiple expressions after a prefixed operator.

WHERE { OR ( number EQ 3, AND ( customer LIKE '%...%', name IN qw/John Jane/, ) ) }

Thats not really much overhead, because when mixing AND and OR parens should always be applied to highlight precedence.

I'm very busy ATM but I'll show a proof of concept after next weekend.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^3: [DSL] disabling packages in Perl?
by mlawren (Sexton) on Apr 19, 2016 at 21:14 UTC

    > Thats not really much overhead, because when mixing AND and OR parens should always be applied to highlight precedence.

    I would agree about the parens but there is a certain cognitive overhead in disassembling (or creating) the reverse polish notation which I have always shied away from. In the end for complicated expressions I think (I would have to check as it's been a while) I went for a mix of arrayrefs and hashrefs (implicit AND):

    select => [qw/expr1 expr2/], from => 'table', where => [ { number => 3 }, OR, { 'customer LIKE' => '%...%', name => [qw/John Jane/] }, },

    I'm looking forward to seeing what you come up with. Please post it!