in reply to Implementing named infix operators with parser hook?

Just out of curiosity, did you consider something like: is 2 => between(1,3)? There's still the need for a comma* (or arrow) between the left operand and "infix" operator, but it's a little less scary looking than 2->$BETWEEN(1, 3). Also it's quite easy to implement, &is would just call the closure returned by &between. And closures are good.

*Unless you want to write that as is { 2 } between 1, 3;, personally I don't like that version.

Replies are listed 'Best First'.
Re^2: Implementing named infix operators with parser hook?
by LanX (Saint) on Aug 17, 2018 at 10:52 UTC
    > did you consider something like: is 2 => between(1,3)?

    Yes I did. :)

    > closures

    I'm using objects.

    I have a very good solution yet, using indirect method calls and constants as operands.

    col BETWEEN 1,2

    I just need an alternative for the cases where the LHS is not a constant, which is rare in most SQL statements.

    Maybe its time to show a proof of concept...

    Cheers Rolf
    , (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      Don't you mean it's rare for LHS to be a constant in SQL statements. Or is the problem that 'rare in most' as opposed to just saying 'rare' can be satisfied by a 51% hit rate (most can be 50.5%, with rare being say 1.5% inside that, but by saying nothing about the other 49.5% allows them all to be hits). One has to be rigorous with verbal expression of statistical propositions.

      One world, one people

        Rare = significantly less than 5 %.

        Columns are represented as Perl constants in my DSL.

        Cheers Rolf
        under (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice